diff --git a/owl-bot-staging/google-cloud-compute/v1/.eslintignore b/owl-bot-staging/google-cloud-compute/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-compute/v1/.eslintrc.json b/owl-bot-staging/google-cloud-compute/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-compute/v1/.gitignore b/owl-bot-staging/google-cloud-compute/v1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-compute/v1/.jsdoc.js b/owl-bot-staging/google-cloud-compute/v1/.jsdoc.js new file mode 100644 index 00000000000..c5da8b74584 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 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'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2023 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/compute', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-compute/v1/.mocharc.js b/owl-bot-staging/google-cloud-compute/v1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 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. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/google-cloud-compute/v1/.prettierrc.js b/owl-bot-staging/google-cloud-compute/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 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. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-compute/v1/README.md b/owl-bot-staging/google-cloud-compute/v1/README.md new file mode 100644 index 00000000000..3383cb94ba5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/README.md @@ -0,0 +1 @@ +Compute: Nodejs Client diff --git a/owl-bot-staging/google-cloud-compute/v1/linkinator.config.json b/owl-bot-staging/google-cloud-compute/v1/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/google-cloud-compute/v1/package.json b/owl-bot-staging/google-cloud-compute/v1/package.json new file mode 100644 index 00000000000..6a286e3d88b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/package.json @@ -0,0 +1,152 @@ +{ + "name": "@google-cloud/compute", + "version": "0.1.0", + "description": "Compute client for Node.js", + "repository": "googleapis/nodejs-compute", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google compute", + "compute", + "accelerator types", + "addresses", + "autoscalers", + "backend buckets", + "backend services", + "disks", + "disk types", + "external vpn gateways", + "firewall policies", + "firewalls", + "forwarding rules", + "global addresses", + "global forwarding rules", + "global network endpoint groups", + "global operations", + "global organization operations", + "global public delegated prefixes", + "health checks", + "image family views", + "images", + "instance group managers", + "instance groups", + "instances", + "instance templates", + "interconnect attachments", + "interconnect locations", + "interconnects", + "license codes", + "licenses", + "machine images", + "machine types", + "network attachments", + "network edge security services", + "network endpoint groups", + "network firewall policies", + "networks", + "node groups", + "node templates", + "node types", + "packet mirrorings", + "projects", + "public advertised prefixes", + "public delegated prefixes", + "region autoscalers", + "region backend services", + "region commitments", + "region disks", + "region disk types", + "region health checks", + "region health check services", + "region instance group managers", + "region instance groups", + "region instances", + "region instance templates", + "region network endpoint groups", + "region network firewall policies", + "region notification endpoints", + "region operations", + "regions", + "region security policies", + "region ssl certificates", + "region ssl policies", + "region target http proxies", + "region target https proxies", + "region target tcp proxies", + "region url maps", + "reservations", + "resource policies", + "routers", + "routes", + "security policies", + "service attachments", + "snapshots", + "ssl certificates", + "ssl policies", + "subnetworks", + "target grpc proxies", + "target http proxies", + "target https proxies", + "target instances", + "target pools", + "target ssl proxies", + "target tcp proxies", + "target vpn gateways", + "url maps", + "vpn gateways", + "vpn tunnels", + "zone operations", + "zones" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/protos/google/cloud/compute/v1/compute.proto b/owl-bot-staging/google-cloud-compute/v1/protos/google/cloud/compute/v1/compute.proto new file mode 100644 index 00000000000..dc2e066fc37 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/protos/google/cloud/compute/v1/compute.proto @@ -0,0 +1,38065 @@ +// Copyright 2023 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. + +// Generated by the disco-to-proto3-converter. DO NOT EDIT! +// Source Discovery file: compute.v1.json +// Source file revision: 20230307 +// API name: compute +// API version: v1 + +syntax = "proto3"; + +package google.cloud.compute.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/extended_operations.proto"; + +// +// File Options +// +option csharp_namespace = "Google.Cloud.Compute.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/compute/v1;compute"; +option java_multiple_files = true; +option java_package = "com.google.cloud.compute.v1"; +option php_namespace = "Google\\Cloud\\Compute\\V1"; +option ruby_package = "Google::Cloud::Compute::V1"; + +// +// Messages +// +// A request message for InstanceGroupManagers.AbandonInstances. See the method description for details. +message AbandonInstancesInstanceGroupManagerRequest { + // The name of the managed instance group. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstanceGroupManagersAbandonInstancesRequest instance_group_managers_abandon_instances_request_resource = 320929016 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where the managed instance group is located. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for RegionInstanceGroupManagers.AbandonInstances. See the method description for details. +message AbandonInstancesRegionInstanceGroupManagerRequest { + // Name of the managed instance group. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionInstanceGroupManagersAbandonInstancesRequest region_instance_group_managers_abandon_instances_request_resource = 488499491 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A specification of the type and number of accelerator cards attached to the instance. +message AcceleratorConfig { + // The number of the guest accelerator cards exposed to this instance. + optional int32 accelerator_count = 504879675; + + // Full or partial URL of the accelerator type resource to attach to this instance. For example: projects/my-project/zones/us-central1-c/acceleratorTypes/nvidia-tesla-p100 If you are creating an instance template, specify only the accelerator name. See GPUs on Compute Engine for a full list of accelerator types. + optional string accelerator_type = 138031246; + +} + +// Represents an Accelerator Type resource. Google Cloud Platform provides graphics processing units (accelerators) that you can add to VM instances to improve or accelerate performance when working with intensive workloads. For more information, read GPUs on Compute Engine. +message AcceleratorType { + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // [Output Only] The deprecation status associated with this accelerator type. + optional DeprecationStatus deprecated = 515138995; + + // [Output Only] An optional textual description of the resource. + optional string description = 422937596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] The type of the resource. Always compute#acceleratorType for accelerator types. + optional string kind = 3292052; + + // [Output Only] Maximum number of accelerator cards allowed per instance. + optional int32 maximum_cards_per_instance = 263814482; + + // [Output Only] Name of the resource. + optional string name = 3373707; + + // [Output Only] Server-defined, fully qualified URL for this resource. + optional string self_link = 456214797; + + // [Output Only] The name of the zone where the accelerator type resides, such as us-central1-a. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string zone = 3744684; + +} + +// +message AcceleratorTypeAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of AcceleratorTypesScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#acceleratorTypeAggregatedList for aggregated lists of accelerator types. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of accelerator types. +message AcceleratorTypeList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of AcceleratorType resources. + repeated AcceleratorType items = 100526016; + + // [Output Only] Type of resource. Always compute#acceleratorTypeList for lists of accelerator types. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message AcceleratorTypesScopedList { + // [Output Only] A list of accelerator types contained in this scope. + repeated AcceleratorType accelerator_types = 520872357; + + // [Output Only] An informational warning that appears when the accelerator types list is empty. + optional Warning warning = 50704284; + +} + +// +message Accelerators { + // Number of accelerator cards exposed to the guest. + optional int32 guest_accelerator_count = 479079316; + + // The accelerator type resource name, not a full URL, e.g. 'nvidia-tesla-k80'. + optional string guest_accelerator_type = 293064725; + +} + +// An access configuration attached to an instance's network interface. Only one access config per instance is supported. +message AccessConfig { + // This signifies the networking tier used for configuring this access configuration and can only take the following values: PREMIUM, STANDARD. If an AccessConfig is specified without a valid external IP address, an ephemeral IP will be created with this networkTier. If an AccessConfig with a valid external IP address is specified, it must match that of the networkTier associated with the Address resource owning that IP. + enum NetworkTier { + // A value indicating that the enum field is not set. + UNDEFINED_NETWORK_TIER = 0; + + // Public internet quality with fixed bandwidth. + FIXED_STANDARD = 310464328; + + // High quality, Google-grade network tier, support for all networking products. + PREMIUM = 399530551; + + // Public internet quality, only limited support for other networking products. + STANDARD = 484642493; + + // (Output only) Temporary tier for FIXED_STANDARD when fixed standard tier is expired or not configured. + STANDARD_OVERRIDES_FIXED_STANDARD = 465847234; + + } + + // The type of configuration. The default and only option is ONE_TO_ONE_NAT. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + DIRECT_IPV6 = 4397213; + + ONE_TO_ONE_NAT = 84090205; + + } + + // The first IPv6 address of the external IPv6 range associated with this instance, prefix length is stored in externalIpv6PrefixLength in ipv6AccessConfig. To use a static external IP address, it must be unused and in the same region as the instance's zone. If not specified, Google Cloud will automatically assign an external IPv6 address from the instance's subnetwork. + optional string external_ipv6 = 532703707; + + // The prefix length of the external IPv6 range. + optional int32 external_ipv6_prefix_length = 425672143; + + // [Output Only] Type of the resource. Always compute#accessConfig for access configs. + optional string kind = 3292052; + + // The name of this access configuration. The default and recommended name is External NAT, but you can use any arbitrary string, such as My external IP or Network Access. + optional string name = 3373707; + + // An external IP address associated with this instance. Specify an unused static external IP address available to the project or leave this field undefined to use an IP from a shared ephemeral IP address pool. If you specify a static external IP address, it must live in the same region as the zone of the instance. + optional string nat_i_p = 117634556; + + // This signifies the networking tier used for configuring this access configuration and can only take the following values: PREMIUM, STANDARD. If an AccessConfig is specified without a valid external IP address, an ephemeral IP will be created with this networkTier. If an AccessConfig with a valid external IP address is specified, it must match that of the networkTier associated with the Address resource owning that IP. + // Check the NetworkTier enum for the list of possible values. + optional string network_tier = 517397843; + + // The DNS domain name for the public PTR record. You can set this field only if the `setPublicPtr` field is enabled in accessConfig. If this field is unspecified in ipv6AccessConfig, a default PTR record will be createc for first IP in associated external IPv6 range. + optional string public_ptr_domain_name = 316599167; + + // Specifies whether a public DNS 'PTR' record should be created to map the external IP address of the instance to a DNS domain name. This field is not used in ipv6AccessConfig. A default PTR record will be created if the VM has external IPv6 range associated. + optional bool set_public_ptr = 523870229; + + // The type of configuration. The default and only option is ONE_TO_ONE_NAT. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// A request message for Instances.AddAccessConfig. See the method description for details. +message AddAccessConfigInstanceRequest { + // The body resource for this request + AccessConfig access_config_resource = 387825552 [(google.api.field_behavior) = REQUIRED]; + + // The instance name for this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The name of the network interface to add to this instance. + string network_interface = 365387880 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for FirewallPolicies.AddAssociation. See the method description for details. +message AddAssociationFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + FirewallPolicyAssociation firewall_policy_association_resource = 259546170 [(google.api.field_behavior) = REQUIRED]; + + // Indicates whether or not to replace it if an association of the attachment already exists. This is false by default, in which case an error will be returned if an association already exists. + optional bool replace_existing_association = 209541240; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for NetworkFirewallPolicies.AddAssociation. See the method description for details. +message AddAssociationNetworkFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + FirewallPolicyAssociation firewall_policy_association_resource = 259546170 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Indicates whether or not to replace it if an association of the attachment already exists. This is false by default, in which case an error will be returned if an association already exists. + optional bool replace_existing_association = 209541240; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionNetworkFirewallPolicies.AddAssociation. See the method description for details. +message AddAssociationRegionNetworkFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + FirewallPolicyAssociation firewall_policy_association_resource = 259546170 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // Indicates whether or not to replace it if an association already exists. This is false by default, in which case an error will be returned if an association already exists. + optional bool replace_existing_association = 209541240; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for TargetPools.AddHealthCheck. See the method description for details. +message AddHealthCheckTargetPoolRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the target pool to add a health check to. + string target_pool = 62796298 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TargetPoolsAddHealthCheckRequest target_pools_add_health_check_request_resource = 269573412 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetPools.AddInstance. See the method description for details. +message AddInstanceTargetPoolRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetPool resource to add instances to. + string target_pool = 62796298 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TargetPoolsAddInstanceRequest target_pools_add_instance_request_resource = 428796404 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InstanceGroups.AddInstances. See the method description for details. +message AddInstancesInstanceGroupRequest { + // The name of the instance group where you are adding instances. + string instance_group = 81095253 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstanceGroupsAddInstancesRequest instance_groups_add_instances_request_resource = 453713246 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where the instance group is located. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for NodeGroups.AddNodes. See the method description for details. +message AddNodesNodeGroupRequest { + // Name of the NodeGroup resource. + string node_group = 469958146 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + NodeGroupsAddNodesRequest node_groups_add_nodes_request_resource = 131263288 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Networks.AddPeering. See the method description for details. +message AddPeeringNetworkRequest { + // Name of the network resource to add peering to. + string network = 232872494 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + NetworksAddPeeringRequest networks_add_peering_request_resource = 388810421 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Disks.AddResourcePolicies. See the method description for details. +message AddResourcePoliciesDiskRequest { + // The disk name for this request. + string disk = 3083677 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + DisksAddResourcePoliciesRequest disks_add_resource_policies_request_resource = 496483363 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Instances.AddResourcePolicies. See the method description for details. +message AddResourcePoliciesInstanceRequest { + // The instance name for this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstancesAddResourcePoliciesRequest instances_add_resource_policies_request_resource = 489351963 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for RegionDisks.AddResourcePolicies. See the method description for details. +message AddResourcePoliciesRegionDiskRequest { + // The disk name for this request. + string disk = 3083677 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionDisksAddResourcePoliciesRequest region_disks_add_resource_policies_request_resource = 284196750 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for FirewallPolicies.AddRule. See the method description for details. +message AddRuleFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + FirewallPolicyRule firewall_policy_rule_resource = 250523523 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for NetworkFirewallPolicies.AddRule. See the method description for details. +message AddRuleNetworkFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + FirewallPolicyRule firewall_policy_rule_resource = 250523523 [(google.api.field_behavior) = REQUIRED]; + + // When rule.priority is not specified, auto choose a unused priority between minPriority and maxPriority>. This field is exclusive with rule.priority. + optional int32 max_priority = 329635359; + + // When rule.priority is not specified, auto choose a unused priority between minPriority and maxPriority>. This field is exclusive with rule.priority. + optional int32 min_priority = 267190513; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionNetworkFirewallPolicies.AddRule. See the method description for details. +message AddRuleRegionNetworkFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + FirewallPolicyRule firewall_policy_rule_resource = 250523523 [(google.api.field_behavior) = REQUIRED]; + + // When rule.priority is not specified, auto choose a unused priority between minPriority and maxPriority>. This field is exclusive with rule.priority. + optional int32 max_priority = 329635359; + + // When rule.priority is not specified, auto choose a unused priority between minPriority and maxPriority>. This field is exclusive with rule.priority. + optional int32 min_priority = 267190513; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for SecurityPolicies.AddRule. See the method description for details. +message AddRuleSecurityPolicyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the security policy to update. + string security_policy = 171082513 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + SecurityPolicyRule security_policy_rule_resource = 402693443 [(google.api.field_behavior) = REQUIRED]; + + // If true, the request will not be committed. + optional bool validate_only = 242744629; + +} + +// A request message for BackendBuckets.AddSignedUrlKey. See the method description for details. +message AddSignedUrlKeyBackendBucketRequest { + // Name of the BackendBucket resource to which the Signed URL Key should be added. The name should conform to RFC1035. + string backend_bucket = 91714037 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + SignedUrlKey signed_url_key_resource = 457625985 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for BackendServices.AddSignedUrlKey. See the method description for details. +message AddSignedUrlKeyBackendServiceRequest { + // Name of the BackendService resource to which the Signed URL Key should be added. The name should conform to RFC1035. + string backend_service = 306946058 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + SignedUrlKey signed_url_key_resource = 457625985 [(google.api.field_behavior) = REQUIRED]; + +} + +// Represents an IP Address resource. Google Compute Engine has two IP Address resources: * [Global (external and internal)](https://cloud.google.com/compute/docs/reference/rest/v1/globalAddresses) * [Regional (external and internal)](https://cloud.google.com/compute/docs/reference/rest/v1/addresses) For more information, see Reserving a static external IP address. +message Address { + // The type of address to reserve, either INTERNAL or EXTERNAL. If unspecified, defaults to EXTERNAL. + enum AddressType { + // A value indicating that the enum field is not set. + UNDEFINED_ADDRESS_TYPE = 0; + + // A publicly visible external IP address. + EXTERNAL = 35607499; + + // A private network IP address, for use with an Instance or Internal Load Balancer forwarding rule. + INTERNAL = 279295677; + + UNSPECIFIED_TYPE = 53933922; + + } + + // The IP version that will be used by this address. Valid options are IPV4 or IPV6. This can only be specified for a global address. + enum IpVersion { + // A value indicating that the enum field is not set. + UNDEFINED_IP_VERSION = 0; + + IPV4 = 2254341; + + IPV6 = 2254343; + + UNSPECIFIED_VERSION = 21850000; + + } + + // The endpoint type of this address, which should be VM or NETLB. This is used for deciding which type of endpoint this address can be used after the external IPv6 address reservation. + enum Ipv6EndpointType { + // A value indicating that the enum field is not set. + UNDEFINED_IPV6_ENDPOINT_TYPE = 0; + + // Reserved IPv6 address can be used on network load balancer. + NETLB = 74173363; + + // Reserved IPv6 address can be used on VM. + VM = 2743; + + } + + // This signifies the networking tier used for configuring this address and can only take the following values: PREMIUM or STANDARD. Internal IP addresses are always Premium Tier; global external IP addresses are always Premium Tier; regional external IP addresses can be either Standard or Premium Tier. If this field is not specified, it is assumed to be PREMIUM. + enum NetworkTier { + // A value indicating that the enum field is not set. + UNDEFINED_NETWORK_TIER = 0; + + // Public internet quality with fixed bandwidth. + FIXED_STANDARD = 310464328; + + // High quality, Google-grade network tier, support for all networking products. + PREMIUM = 399530551; + + // Public internet quality, only limited support for other networking products. + STANDARD = 484642493; + + // (Output only) Temporary tier for FIXED_STANDARD when fixed standard tier is expired or not configured. + STANDARD_OVERRIDES_FIXED_STANDARD = 465847234; + + } + + // The purpose of this resource, which can be one of the following values: - GCE_ENDPOINT for addresses that are used by VM instances, alias IP ranges, load balancers, and similar resources. - DNS_RESOLVER for a DNS resolver address in a subnetwork for a Cloud DNS inbound forwarder IP addresses (regional internal IP address in a subnet of a VPC network) - VPC_PEERING for global internal IP addresses used for private services access allocated ranges. - NAT_AUTO for the regional external IP addresses used by Cloud NAT when allocating addresses using automatic NAT IP address allocation. - IPSEC_INTERCONNECT for addresses created from a private IP range that are reserved for a VLAN attachment in an *HA VPN over Cloud Interconnect* configuration. These addresses are regional resources. - `SHARED_LOADBALANCER_VIP` for an internal IP address that is assigned to multiple internal forwarding rules. - `PRIVATE_SERVICE_CONNECT` for a private network address that is used to configure Private Service Connect. Only global internal addresses can use this purpose. + enum Purpose { + // A value indicating that the enum field is not set. + UNDEFINED_PURPOSE = 0; + + // DNS resolver address in the subnetwork. + DNS_RESOLVER = 476114556; + + // VM internal/alias IP, Internal LB service IP, etc. + GCE_ENDPOINT = 230515243; + + // A regional internal IP address range reserved for the VLAN attachment that is used in HA VPN over Cloud Interconnect. This regional internal IP address range must not overlap with any IP address range of subnet/route in the VPC network and its peering networks. After the VLAN attachment is created with the reserved IP address range, when creating a new VPN gateway, its interface IP address is allocated from the associated VLAN attachment’s IP address range. + IPSEC_INTERCONNECT = 340437251; + + // External IP automatically reserved for Cloud NAT. + NAT_AUTO = 163666477; + + // A private network IP address that can be used to configure Private Service Connect. This purpose can be specified only for GLOBAL addresses of Type INTERNAL + PRIVATE_SERVICE_CONNECT = 48134724; + + // A regional internal IP address range reserved for Serverless. + SERVERLESS = 270492508; + + // A private network IP address that can be shared by multiple Internal Load Balancer forwarding rules. + SHARED_LOADBALANCER_VIP = 294447572; + + // IP range for peer networks. + VPC_PEERING = 400800170; + + } + + // [Output Only] The status of the address, which can be one of RESERVING, RESERVED, or IN_USE. An address that is RESERVING is currently in the process of being reserved. A RESERVED address is currently reserved and available to use. An IN_USE address is currently being used by another resource and is not available. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // Address is being used by another resource and is not available. + IN_USE = 17393485; + + // Address is reserved and available to use. + RESERVED = 432241448; + + // Address is being reserved. + RESERVING = 514587225; + + } + + // The static IP address represented by this resource. + optional string address = 462920692; + + // The type of address to reserve, either INTERNAL or EXTERNAL. If unspecified, defaults to EXTERNAL. + // Check the AddressType enum for the list of possible values. + optional string address_type = 264307877; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this field when you create the resource. + optional string description = 422937596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // The IP version that will be used by this address. Valid options are IPV4 or IPV6. This can only be specified for a global address. + // Check the IpVersion enum for the list of possible values. + optional string ip_version = 294959552; + + // The endpoint type of this address, which should be VM or NETLB. This is used for deciding which type of endpoint this address can be used after the external IPv6 address reservation. + // Check the Ipv6EndpointType enum for the list of possible values. + optional string ipv6_endpoint_type = 97501004; + + // [Output Only] Type of the resource. Always compute#address for addresses. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`. The first character must be a lowercase letter, and all following characters (except for the last character) must be a dash, lowercase letter, or digit. The last character must be a lowercase letter or digit. + optional string name = 3373707; + + // The URL of the network in which to reserve the address. This field can only be used with INTERNAL type with the VPC_PEERING purpose. + optional string network = 232872494; + + // This signifies the networking tier used for configuring this address and can only take the following values: PREMIUM or STANDARD. Internal IP addresses are always Premium Tier; global external IP addresses are always Premium Tier; regional external IP addresses can be either Standard or Premium Tier. If this field is not specified, it is assumed to be PREMIUM. + // Check the NetworkTier enum for the list of possible values. + optional string network_tier = 517397843; + + // The prefix length if the resource represents an IP range. + optional int32 prefix_length = 453565747; + + // The purpose of this resource, which can be one of the following values: - GCE_ENDPOINT for addresses that are used by VM instances, alias IP ranges, load balancers, and similar resources. - DNS_RESOLVER for a DNS resolver address in a subnetwork for a Cloud DNS inbound forwarder IP addresses (regional internal IP address in a subnet of a VPC network) - VPC_PEERING for global internal IP addresses used for private services access allocated ranges. - NAT_AUTO for the regional external IP addresses used by Cloud NAT when allocating addresses using automatic NAT IP address allocation. - IPSEC_INTERCONNECT for addresses created from a private IP range that are reserved for a VLAN attachment in an *HA VPN over Cloud Interconnect* configuration. These addresses are regional resources. - `SHARED_LOADBALANCER_VIP` for an internal IP address that is assigned to multiple internal forwarding rules. - `PRIVATE_SERVICE_CONNECT` for a private network address that is used to configure Private Service Connect. Only global internal addresses can use this purpose. + // Check the Purpose enum for the list of possible values. + optional string purpose = 316407070; + + // [Output Only] The URL of the region where a regional address resides. For regional addresses, you must specify the region as a path parameter in the HTTP request URL. *This field is not applicable to global addresses.* + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] The status of the address, which can be one of RESERVING, RESERVED, or IN_USE. An address that is RESERVING is currently in the process of being reserved. A RESERVED address is currently reserved and available to use. An IN_USE address is currently being used by another resource and is not available. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // The URL of the subnetwork in which to reserve the address. If an IP address is specified, it must be within the subnetwork's IP range. This field can only be used with INTERNAL type with a GCE_ENDPOINT or DNS_RESOLVER purpose. + optional string subnetwork = 307827694; + + // [Output Only] The URLs of the resources that are using this address. + repeated string users = 111578632; + +} + +// +message AddressAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of AddressesScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#addressAggregatedList for aggregated lists of addresses. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of addresses. +message AddressList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Address resources. + repeated Address items = 100526016; + + // [Output Only] Type of resource. Always compute#addressList for lists of addresses. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message AddressesScopedList { + // [Output Only] A list of addresses contained in this scope. + repeated Address addresses = 337673122; + + // [Output Only] Informational warning which replaces the list of addresses when the list is empty. + optional Warning warning = 50704284; + +} + +// Specifies options for controlling advanced machine features. Options that would traditionally be configured in a BIOS belong here. Features that require operating system support may have corresponding entries in the GuestOsFeatures of an Image (e.g., whether or not the OS in the Image supports nested virtualization being enabled or disabled). +message AdvancedMachineFeatures { + // Whether to enable nested virtualization or not (default is false). + optional bool enable_nested_virtualization = 16639365; + + // Whether to enable UEFI networking for instance creation. + optional bool enable_uefi_networking = 334485668; + + // The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed. + optional int32 threads_per_core = 352611671; + + // The number of physical cores to expose to an instance. Multiply by the number of threads per core to compute the total number of virtual CPUs to expose to the instance. If unset, the number of cores is inferred from the instance's nominal CPU count and the underlying platform's SMT width. + optional int32 visible_core_count = 193198684; + +} + +// A request message for AcceleratorTypes.AggregatedList. See the method description for details. +message AggregatedListAcceleratorTypesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Addresses.AggregatedList. See the method description for details. +message AggregatedListAddressesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Autoscalers.AggregatedList. See the method description for details. +message AggregatedListAutoscalersRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for BackendServices.AggregatedList. See the method description for details. +message AggregatedListBackendServicesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Name of the project scoping this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for DiskTypes.AggregatedList. See the method description for details. +message AggregatedListDiskTypesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Disks.AggregatedList. See the method description for details. +message AggregatedListDisksRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for ForwardingRules.AggregatedList. See the method description for details. +message AggregatedListForwardingRulesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for GlobalOperations.AggregatedList. See the method description for details. +message AggregatedListGlobalOperationsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for HealthChecks.AggregatedList. See the method description for details. +message AggregatedListHealthChecksRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Name of the project scoping this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for InstanceGroupManagers.AggregatedList. See the method description for details. +message AggregatedListInstanceGroupManagersRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for InstanceGroups.AggregatedList. See the method description for details. +message AggregatedListInstanceGroupsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for InstanceTemplates.AggregatedList. See the method description for details. +message AggregatedListInstanceTemplatesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Name of the project scoping this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Instances.AggregatedList. See the method description for details. +message AggregatedListInstancesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for InterconnectAttachments.AggregatedList. See the method description for details. +message AggregatedListInterconnectAttachmentsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for MachineTypes.AggregatedList. See the method description for details. +message AggregatedListMachineTypesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for NetworkAttachments.AggregatedList. See the method description for details. +message AggregatedListNetworkAttachmentsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for NetworkEdgeSecurityServices.AggregatedList. See the method description for details. +message AggregatedListNetworkEdgeSecurityServicesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Name of the project scoping this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for NetworkEndpointGroups.AggregatedList. See the method description for details. +message AggregatedListNetworkEndpointGroupsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for NodeGroups.AggregatedList. See the method description for details. +message AggregatedListNodeGroupsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for NodeTemplates.AggregatedList. See the method description for details. +message AggregatedListNodeTemplatesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for NodeTypes.AggregatedList. See the method description for details. +message AggregatedListNodeTypesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for PacketMirrorings.AggregatedList. See the method description for details. +message AggregatedListPacketMirroringsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for PublicDelegatedPrefixes.AggregatedList. See the method description for details. +message AggregatedListPublicDelegatedPrefixesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Name of the project scoping this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionCommitments.AggregatedList. See the method description for details. +message AggregatedListRegionCommitmentsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Reservations.AggregatedList. See the method description for details. +message AggregatedListReservationsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for ResourcePolicies.AggregatedList. See the method description for details. +message AggregatedListResourcePoliciesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Routers.AggregatedList. See the method description for details. +message AggregatedListRoutersRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for SecurityPolicies.AggregatedList. See the method description for details. +message AggregatedListSecurityPoliciesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Name of the project scoping this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for ServiceAttachments.AggregatedList. See the method description for details. +message AggregatedListServiceAttachmentsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Name of the project scoping this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for SslCertificates.AggregatedList. See the method description for details. +message AggregatedListSslCertificatesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Name of the project scoping this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for SslPolicies.AggregatedList. See the method description for details. +message AggregatedListSslPoliciesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Name of the project scoping this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Subnetworks.AggregatedList. See the method description for details. +message AggregatedListSubnetworksRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for TargetHttpProxies.AggregatedList. See the method description for details. +message AggregatedListTargetHttpProxiesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Name of the project scoping this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for TargetHttpsProxies.AggregatedList. See the method description for details. +message AggregatedListTargetHttpsProxiesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Name of the project scoping this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for TargetInstances.AggregatedList. See the method description for details. +message AggregatedListTargetInstancesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for TargetPools.AggregatedList. See the method description for details. +message AggregatedListTargetPoolsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for TargetTcpProxies.AggregatedList. See the method description for details. +message AggregatedListTargetTcpProxiesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Name of the project scoping this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for TargetVpnGateways.AggregatedList. See the method description for details. +message AggregatedListTargetVpnGatewaysRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for UrlMaps.AggregatedList. See the method description for details. +message AggregatedListUrlMapsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Name of the project scoping this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for VpnGateways.AggregatedList. See the method description for details. +message AggregatedListVpnGatewaysRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for VpnTunnels.AggregatedList. See the method description for details. +message AggregatedListVpnTunnelsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// An alias IP range attached to an instance's network interface. +message AliasIpRange { + // The IP alias ranges to allocate for this interface. This IP CIDR range must belong to the specified subnetwork and cannot contain IP addresses reserved by system or used by other network interfaces. This range may be a single IP address (such as 10.2.3.4), a netmask (such as /24) or a CIDR-formatted string (such as 10.1.2.0/24). + optional string ip_cidr_range = 98117322; + + // The name of a subnetwork secondary IP range from which to allocate an IP alias range. If not specified, the primary range of the subnetwork is used. + optional string subnetwork_range_name = 387995966; + +} + +// [Output Only] Contains output only fields. +message AllocationResourceStatus { + // Allocation Properties of this reservation. + optional AllocationResourceStatusSpecificSKUAllocation specific_sku_allocation = 196231151; + +} + +// Contains Properties set for the reservation. +message AllocationResourceStatusSpecificSKUAllocation { + // ID of the instance template used to populate reservation properties. + optional string source_instance_template_id = 111196154; + +} + +// +message AllocationSpecificSKUAllocationAllocatedInstancePropertiesReservedDisk { + // Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. The default is SCSI. For performance characteristics of SCSI over NVMe, see Local SSD performance. + enum Interface { + // A value indicating that the enum field is not set. + UNDEFINED_INTERFACE = 0; + + NVME = 2408800; + + SCSI = 2539686; + + } + + // Specifies the size of the disk in base-2 GB. + optional int64 disk_size_gb = 316263735; + + // Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. The default is SCSI. For performance characteristics of SCSI over NVMe, see Local SSD performance. + // Check the Interface enum for the list of possible values. + optional string interface = 502623545; + +} + +// Properties of the SKU instances being reserved. Next ID: 9 +message AllocationSpecificSKUAllocationReservedInstanceProperties { + // Specifies accelerator type and count. + repeated AcceleratorConfig guest_accelerators = 463595119; + + // Specifies amount of local ssd to reserve with each instance. The type of disk is local-ssd. + repeated AllocationSpecificSKUAllocationAllocatedInstancePropertiesReservedDisk local_ssds = 229951299; + + // An opaque location hint used to place the allocation close to other resources. This field is for use by internal tools that use the public API. + optional string location_hint = 350519505; + + // Specifies type of machine (name only) which has fixed number of vCPUs and fixed amount of memory. This also includes specifying custom machine type following custom-NUMBER_OF_CPUS-AMOUNT_OF_MEMORY pattern. + optional string machine_type = 227711026; + + // Minimum cpu platform the reservation. + optional string min_cpu_platform = 242912759; + +} + +// This reservation type allows to pre allocate specific instance configuration. Next ID: 6 +message AllocationSpecificSKUReservation { + // [Output Only] Indicates how many instances are actually usable currently. + optional int64 assured_count = 281197645; + + // Specifies the number of resources that are allocated. + optional int64 count = 94851343; + + // [Output Only] Indicates how many instances are in use. + optional int64 in_use_count = 493458877; + + // The instance properties for the reservation. + optional AllocationSpecificSKUAllocationReservedInstanceProperties instance_properties = 215355165; + + // Specifies the instance template to create the reservation. If you use this field, you must exclude the instanceProperties field. This field is optional, and it can be a full or partial URL. For example, the following are all valid URLs to an instance template: - https://www.googleapis.com/compute/v1/projects/project /global/instanceTemplates/instanceTemplate - projects/project/global/instanceTemplates/instanceTemplate - global/instanceTemplates/instanceTemplate + optional string source_instance_template = 332423616; + +} + +// +message Allowed { + // The IP protocol to which this rule applies. The protocol type is required when creating a firewall rule. This value can either be one of the following well known protocol strings (tcp, udp, icmp, esp, ah, ipip, sctp) or the IP protocol number. + optional string I_p_protocol = 488094525; + + // An optional list of ports to which this rule applies. This field is only applicable for the UDP or TCP protocol. Each entry must be either an integer or a range. If not specified, this rule applies to connections through any port. Example inputs include: ["22"], ["80","443"], and ["12345-12349"]. + repeated string ports = 106854418; + +} + +// A request message for InstanceGroupManagers.ApplyUpdatesToInstances. See the method description for details. +message ApplyUpdatesToInstancesInstanceGroupManagerRequest { + // The name of the managed instance group, should conform to RFC1035. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstanceGroupManagersApplyUpdatesRequest instance_group_managers_apply_updates_request_resource = 259242835 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The name of the zone where the managed instance group is located. Should conform to RFC1035. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for RegionInstanceGroupManagers.ApplyUpdatesToInstances. See the method description for details. +message ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest { + // The name of the managed instance group, should conform to RFC1035. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request, should conform to RFC1035. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionInstanceGroupManagersApplyUpdatesRequest region_instance_group_managers_apply_updates_request_resource = 76248318 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Instances.AttachDisk. See the method description for details. +message AttachDiskInstanceRequest { + // The body resource for this request + AttachedDisk attached_disk_resource = 90605845 [(google.api.field_behavior) = REQUIRED]; + + // Whether to force attach the regional disk even if it's currently attached to another instance. If you try to force attach a zonal disk to an instance, you will receive an error. + optional bool force_attach = 142758425; + + // The instance name for this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for GlobalNetworkEndpointGroups.AttachNetworkEndpoints. See the method description for details. +message AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest { + // The body resource for this request + GlobalNetworkEndpointGroupsAttachEndpointsRequest global_network_endpoint_groups_attach_endpoints_request_resource = 30691563 [(google.api.field_behavior) = REQUIRED]; + + // The name of the network endpoint group where you are attaching network endpoints to. It should comply with RFC1035. + string network_endpoint_group = 433907078 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for NetworkEndpointGroups.AttachNetworkEndpoints. See the method description for details. +message AttachNetworkEndpointsNetworkEndpointGroupRequest { + // The name of the network endpoint group where you are attaching network endpoints to. It should comply with RFC1035. + string network_endpoint_group = 433907078 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + NetworkEndpointGroupsAttachEndpointsRequest network_endpoint_groups_attach_endpoints_request_resource = 531079 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where the network endpoint group is located. It should comply with RFC1035. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// An instance-attached disk resource. +message AttachedDisk { + // [Output Only] The architecture of the attached disk. Valid values are ARM64 or X86_64. + enum Architecture { + // A value indicating that the enum field is not set. + UNDEFINED_ARCHITECTURE = 0; + + // Default value indicating Architecture is not set. + ARCHITECTURE_UNSPECIFIED = 394750507; + + // Machines with architecture ARM64 + ARM64 = 62547450; + + // Machines with architecture X86_64 + X86_64 = 425300551; + + } + + // Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. For most machine types, the default is SCSI. Local SSDs can use either NVME or SCSI. In certain configurations, persistent disks can use NVMe. For more information, see About persistent disks. + enum Interface { + // A value indicating that the enum field is not set. + UNDEFINED_INTERFACE = 0; + + NVME = 2408800; + + SCSI = 2539686; + + } + + // The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode. + enum Mode { + // A value indicating that the enum field is not set. + UNDEFINED_MODE = 0; + + // Attaches this disk in read-only mode. Multiple virtual machines can use a disk in read-only mode at a time. + READ_ONLY = 91950261; + + // *[Default]* Attaches this disk in read-write mode. Only one virtual machine at a time can be attached to a disk in read-write mode. + READ_WRITE = 173607894; + + } + + // Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, the default is PERSISTENT. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + PERSISTENT = 460683927; + + SCRATCH = 496778970; + + } + + // [Output Only] The architecture of the attached disk. Valid values are ARM64 or X86_64. + // Check the Architecture enum for the list of possible values. + optional string architecture = 302803283; + + // Specifies whether the disk will be auto-deleted when the instance is deleted (but not when the disk is detached from the instance). + optional bool auto_delete = 464761403; + + // Indicates that this is a boot disk. The virtual machine will use the first partition of the disk for its root filesystem. + optional bool boot = 3029746; + + // Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* tree of a Linux operating system running within the instance. This name can be used to reference the device for mounting, resizing, and so on, from within the instance. If not specified, the server chooses a default device name to apply to this disk, in the form persistent-disk-x, where x is a number assigned by Google Compute Engine. This field is only applicable for persistent disks. + optional string device_name = 67541716; + + // Encrypts or decrypts a disk using a customer-supplied encryption key. If you are creating a new disk, this field encrypts the new disk using an encryption key that you provide. If you are attaching an existing disk that is already encrypted, this field decrypts the disk using the customer-supplied encryption key. If you encrypt a disk using a customer-supplied key, you must provide the same key again when you attempt to use this resource at a later time. For example, you must provide the key when you create a snapshot or an image from the disk or when you attach the disk to a virtual machine instance. If you do not provide an encryption key, then the disk will be encrypted using an automatically generated key and you do not need to provide a key to use the disk later. Instance templates do not store customer-supplied encryption keys, so you cannot use your own keys to encrypt disks in a managed instance group. + optional CustomerEncryptionKey disk_encryption_key = 271660677; + + // The size of the disk in GB. + optional int64 disk_size_gb = 316263735; + + // [Input Only] Whether to force attach the regional disk even if it's currently attached to another instance. If you try to force attach a zonal disk to an instance, you will receive an error. + optional bool force_attach = 142758425; + + // A list of features to enable on the guest operating system. Applicable only for bootable images. Read Enabling guest operating system features to see a list of available options. + repeated GuestOsFeature guest_os_features = 79294545; + + // [Output Only] A zero-based index to this disk, where 0 is reserved for the boot disk. If you have many disks attached to an instance, each disk would have a unique index number. + optional int32 index = 100346066; + + // [Input Only] Specifies the parameters for a new disk that will be created alongside the new instance. Use initialization parameters to create boot disks or local SSDs attached to the new instance. This property is mutually exclusive with the source property; you can only define one or the other, but not both. + optional AttachedDiskInitializeParams initialize_params = 17697045; + + // Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. For most machine types, the default is SCSI. Local SSDs can use either NVME or SCSI. In certain configurations, persistent disks can use NVMe. For more information, see About persistent disks. + // Check the Interface enum for the list of possible values. + optional string interface = 502623545; + + // [Output Only] Type of the resource. Always compute#attachedDisk for attached disks. + optional string kind = 3292052; + + // [Output Only] Any valid publicly visible licenses. + repeated string licenses = 337642578; + + // The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode. + // Check the Mode enum for the list of possible values. + optional string mode = 3357091; + + // [Output Only] shielded vm initial state stored on disk + optional InitialStateConfig shielded_instance_initial_state = 192356867; + + // Specifies a valid partial or full URL to an existing Persistent Disk resource. When creating a new instance, one of initializeParams.sourceImage or initializeParams.sourceSnapshot or disks.source is required except for local SSD. If desired, you can also attach existing non-root persistent disks using this property. This field is only applicable for persistent disks. Note that for InstanceTemplate, specify the disk name for zonal disk, and the URL for regional disk. + optional string source = 177235995; + + // Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, the default is PERSISTENT. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// [Input Only] Specifies the parameters for a new disk that will be created alongside the new instance. Use initialization parameters to create boot disks or local SSDs attached to the new instance. This field is persisted and returned for instanceTemplate and not returned in the context of instance. This property is mutually exclusive with the source property; you can only define one or the other, but not both. +message AttachedDiskInitializeParams { + // The architecture of the attached disk. Valid values are arm64 or x86_64. + enum Architecture { + // A value indicating that the enum field is not set. + UNDEFINED_ARCHITECTURE = 0; + + // Default value indicating Architecture is not set. + ARCHITECTURE_UNSPECIFIED = 394750507; + + // Machines with architecture ARM64 + ARM64 = 62547450; + + // Machines with architecture X86_64 + X86_64 = 425300551; + + } + + // Specifies which action to take on instance update with this disk. Default is to use the existing disk. + enum OnUpdateAction { + // A value indicating that the enum field is not set. + UNDEFINED_ON_UPDATE_ACTION = 0; + + // Always recreate the disk. + RECREATE_DISK = 494767853; + + // Recreate the disk if source (image, snapshot) of this disk is different from source of existing disk. + RECREATE_DISK_IF_SOURCE_CHANGED = 398099712; + + // Use the existing disk, this is the default behaviour. + USE_EXISTING_DISK = 232682233; + + } + + // The architecture of the attached disk. Valid values are arm64 or x86_64. + // Check the Architecture enum for the list of possible values. + optional string architecture = 302803283; + + // An optional description. Provide this property when creating the disk. + optional string description = 422937596; + + // Specifies the disk name. If not specified, the default is to use the name of the instance. If a disk with the same name already exists in the given region, the existing disk is attached to the new instance and the new disk is not created. + optional string disk_name = 92807149; + + // Specifies the size of the disk in base-2 GB. The size must be at least 10 GB. If you specify a sourceImage, which is required for boot disks, the default size is the size of the sourceImage. If you do not specify a sourceImage, the default disk size is 500 GB. + optional int64 disk_size_gb = 316263735; + + // Specifies the disk type to use to create the instance. If not specified, the default is pd-standard, specified using the full URL. For example: https://www.googleapis.com/compute/v1/projects/project/zones/zone /diskTypes/pd-standard For a full list of acceptable values, see Persistent disk types. If you specify this field when creating a VM, you can provide either the full or partial URL. For example, the following values are valid: - https://www.googleapis.com/compute/v1/projects/project/zones/zone /diskTypes/diskType - projects/project/zones/zone/diskTypes/diskType - zones/zone/diskTypes/diskType If you specify this field when creating or updating an instance template or all-instances configuration, specify the type of the disk, not the URL. For example: pd-standard. + optional string disk_type = 93009052; + + // Labels to apply to this disk. These can be later modified by the disks.setLabels method. This field is only applicable for persistent disks. + map labels = 500195327; + + // A list of publicly visible licenses. Reserved for Google's use. + repeated string licenses = 337642578; + + // Specifies which action to take on instance update with this disk. Default is to use the existing disk. + // Check the OnUpdateAction enum for the list of possible values. + optional string on_update_action = 202451980; + + // Indicates how many IOPS to provision for the disk. This sets the number of I/O operations per second that the disk can handle. Values must be between 10,000 and 120,000. For more details, see the Extreme persistent disk documentation. + optional int64 provisioned_iops = 186769108; + + // Resource manager tags to be bound to the disk. Tag keys and values have the same definition as resource manager tags. Keys must be in the format `tagKeys/{tag_key_id}`, and values are in the format `tagValues/456`. The field is ignored (both PUT & PATCH) when empty. + map resource_manager_tags = 377671164; + + // Resource policies applied to this disk for automatic snapshot creations. Specified using the full or partial URL. For instance template, specify only the resource policy name. + repeated string resource_policies = 22220385; + + // The source image to create this disk. When creating a new instance, one of initializeParams.sourceImage or initializeParams.sourceSnapshot or disks.source is required except for local SSD. To create a disk with one of the public operating system images, specify the image by its family name. For example, specify family/debian-9 to use the latest Debian 9 image: projects/debian-cloud/global/images/family/debian-9 Alternatively, use a specific version of a public operating system image: projects/debian-cloud/global/images/debian-9-stretch-vYYYYMMDD To create a disk with a custom image that you created, specify the image name in the following format: global/images/my-custom-image You can also specify a custom image by its image family, which returns the latest version of the image in that family. Replace the image name with family/family-name: global/images/family/my-image-family If the source image is deleted later, this field will not be set. + optional string source_image = 50443319; + + // The customer-supplied encryption key of the source image. Required if the source image is protected by a customer-supplied encryption key. InstanceTemplate and InstancePropertiesPatch do not store customer-supplied encryption keys, so you cannot create disks for instances in a managed instance group if the source images are encrypted with your own keys. + optional CustomerEncryptionKey source_image_encryption_key = 381503659; + + // The source snapshot to create this disk. When creating a new instance, one of initializeParams.sourceSnapshot or initializeParams.sourceImage or disks.source is required except for local SSD. To create a disk with a snapshot that you created, specify the snapshot name in the following format: global/snapshots/my-backup If the source snapshot is deleted later, this field will not be set. + optional string source_snapshot = 126061928; + + // The customer-supplied encryption key of the source snapshot. + optional CustomerEncryptionKey source_snapshot_encryption_key = 303679322; + +} + +// Specifies the audit configuration for a service. The configuration determines which permission types are logged, and what identities, if any, are exempted from logging. An AuditConfig must have one or more AuditLogConfigs. If there are AuditConfigs for both `allServices` and a specific service, the union of the two AuditConfigs is used for that service: the log_types specified in each AuditConfig are enabled, and the exempted_members in each AuditLogConfig are exempted. Example Policy with multiple AuditConfigs: { "audit_configs": [ { "service": "allServices", "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" }, { "log_type": "ADMIN_READ" } ] }, { "service": "sampleservice.googleapis.com", "audit_log_configs": [ { "log_type": "DATA_READ" }, { "log_type": "DATA_WRITE", "exempted_members": [ "user:aliya@example.com" ] } ] } ] } For sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ logging. It also exempts jose@example.com from DATA_READ logging, and aliya@example.com from DATA_WRITE logging. +message AuditConfig { + // The configuration for logging of each type of permission. + repeated AuditLogConfig audit_log_configs = 488420626; + + // This is deprecated and has no effect. Do not use. + repeated string exempted_members = 232615576; + + // Specifies a service that will be enabled for audit logging. For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` is a special value that covers all services. + optional string service = 373540533; + +} + +// Provides the configuration for logging a type of permissions. Example: { "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" } ] } This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting jose@example.com from DATA_READ logging. +message AuditLogConfig { + // The log type that this config enables. + enum LogType { + // A value indicating that the enum field is not set. + UNDEFINED_LOG_TYPE = 0; + + // Admin reads. Example: CloudIAM getIamPolicy + ADMIN_READ = 128951462; + + // Data reads. Example: CloudSQL Users list + DATA_READ = 305224971; + + // Data writes. Example: CloudSQL Users create + DATA_WRITE = 340181738; + + // Default case. Should never be this. + LOG_TYPE_UNSPECIFIED = 154527053; + + } + + // Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members. + repeated string exempted_members = 232615576; + + // This is deprecated and has no effect. Do not use. + optional bool ignore_child_exemptions = 70141850; + + // The log type that this config enables. + // Check the LogType enum for the list of possible values. + optional string log_type = 403115861; + +} + +// This is deprecated and has no effect. Do not use. +message AuthorizationLoggingOptions { + // This is deprecated and has no effect. Do not use. + enum PermissionType { + // A value indicating that the enum field is not set. + UNDEFINED_PERMISSION_TYPE = 0; + + // This is deprecated and has no effect. Do not use. + ADMIN_READ = 128951462; + + // This is deprecated and has no effect. Do not use. + ADMIN_WRITE = 244412079; + + // This is deprecated and has no effect. Do not use. + DATA_READ = 305224971; + + // This is deprecated and has no effect. Do not use. + DATA_WRITE = 340181738; + + // This is deprecated and has no effect. Do not use. + PERMISSION_TYPE_UNSPECIFIED = 440313346; + + } + + // This is deprecated and has no effect. Do not use. + // Check the PermissionType enum for the list of possible values. + optional string permission_type = 525978538; + +} + +// Represents an Autoscaler resource. Google Compute Engine has two Autoscaler resources: * [Zonal](/compute/docs/reference/rest/v1/autoscalers) * [Regional](/compute/docs/reference/rest/v1/regionAutoscalers) Use autoscalers to automatically add or delete instances from a managed instance group according to your defined autoscaling policy. For more information, read Autoscaling Groups of Instances. For zonal managed instance groups resource, use the autoscaler resource. For regional managed instance groups, use the regionAutoscalers resource. +message Autoscaler { + // [Output Only] The status of the autoscaler configuration. Current set of possible values: - PENDING: Autoscaler backend hasn't read new/updated configuration. - DELETING: Configuration is being deleted. - ACTIVE: Configuration is acknowledged to be effective. Some warnings might be present in the statusDetails field. - ERROR: Configuration has errors. Actionable for users. Details are present in the statusDetails field. New values might be added in the future. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // Configuration is acknowledged to be effective + ACTIVE = 314733318; + + // Configuration is being deleted + DELETING = 528602024; + + // Configuration has errors. Actionable for users. + ERROR = 66247144; + + // Autoscaler backend hasn't read new/updated configuration + PENDING = 35394935; + + } + + // The configuration parameters for the autoscaling algorithm. You can define one or more signals for an autoscaler: cpuUtilization, customMetricUtilizations, and loadBalancingUtilization. If none of these are specified, the default will be to autoscale based on cpuUtilization to 0.6 or 60%. + optional AutoscalingPolicy autoscaling_policy = 221950041; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#autoscaler for autoscalers. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // [Output Only] Target recommended MIG size (number of instances) computed by autoscaler. Autoscaler calculates the recommended MIG size even when the autoscaling policy mode is different from ON. This field is empty when autoscaler is not connected to an existing managed instance group or autoscaler did not generate its prediction. + optional int32 recommended_size = 257915749; + + // [Output Only] URL of the region where the instance group resides (for autoscalers living in regional scope). + optional string region = 138946292; + + // [Output Only] Status information of existing scaling schedules. + map scaling_schedule_status = 465950178; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] The status of the autoscaler configuration. Current set of possible values: - PENDING: Autoscaler backend hasn't read new/updated configuration. - DELETING: Configuration is being deleted. - ACTIVE: Configuration is acknowledged to be effective. Some warnings might be present in the statusDetails field. - ERROR: Configuration has errors. Actionable for users. Details are present in the statusDetails field. New values might be added in the future. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // [Output Only] Human-readable details about the current state of the autoscaler. Read the documentation for Commonly returned status messages for examples of status messages you might encounter. + repeated AutoscalerStatusDetails status_details = 363353845; + + // URL of the managed instance group that this autoscaler will scale. This field is required when creating an autoscaler. + optional string target = 192835985; + + // [Output Only] URL of the zone where the instance group resides (for autoscalers living in zonal scope). + optional string zone = 3744684; + +} + +// +message AutoscalerAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of AutoscalersScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#autoscalerAggregatedList for aggregated lists of autoscalers. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. end_interface: MixerListResponseWithEtagBuilder + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of Autoscaler resources. +message AutoscalerList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Autoscaler resources. + repeated Autoscaler items = 100526016; + + // [Output Only] Type of resource. Always compute#autoscalerList for lists of autoscalers. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message AutoscalerStatusDetails { + // The type of error, warning, or notice returned. Current set of possible values: - ALL_INSTANCES_UNHEALTHY (WARNING): All instances in the instance group are unhealthy (not in RUNNING state). - BACKEND_SERVICE_DOES_NOT_EXIST (ERROR): There is no backend service attached to the instance group. - CAPPED_AT_MAX_NUM_REPLICAS (WARNING): Autoscaler recommends a size greater than maxNumReplicas. - CUSTOM_METRIC_DATA_POINTS_TOO_SPARSE (WARNING): The custom metric samples are not exported often enough to be a credible base for autoscaling. - CUSTOM_METRIC_INVALID (ERROR): The custom metric that was specified does not exist or does not have the necessary labels. - MIN_EQUALS_MAX (WARNING): The minNumReplicas is equal to maxNumReplicas. This means the autoscaler cannot add or remove instances from the instance group. - MISSING_CUSTOM_METRIC_DATA_POINTS (WARNING): The autoscaler did not receive any data from the custom metric configured for autoscaling. - MISSING_LOAD_BALANCING_DATA_POINTS (WARNING): The autoscaler is configured to scale based on a load balancing signal but the instance group has not received any requests from the load balancer. - MODE_OFF (WARNING): Autoscaling is turned off. The number of instances in the group won't change automatically. The autoscaling configuration is preserved. - MODE_ONLY_UP (WARNING): Autoscaling is in the "Autoscale only out" mode. The autoscaler can add instances but not remove any. - MORE_THAN_ONE_BACKEND_SERVICE (ERROR): The instance group cannot be autoscaled because it has more than one backend service attached to it. - NOT_ENOUGH_QUOTA_AVAILABLE (ERROR): There is insufficient quota for the necessary resources, such as CPU or number of instances. - REGION_RESOURCE_STOCKOUT (ERROR): Shown only for regional autoscalers: there is a resource stockout in the chosen region. - SCALING_TARGET_DOES_NOT_EXIST (ERROR): The target to be scaled does not exist. - UNSUPPORTED_MAX_RATE_LOAD_BALANCING_CONFIGURATION (ERROR): Autoscaling does not work with an HTTP/S load balancer that has been configured for maxRate. - ZONE_RESOURCE_STOCKOUT (ERROR): For zonal autoscalers: there is a resource stockout in the chosen zone. For regional autoscalers: in at least one of the zones you're using there is a resource stockout. New values might be added in the future. Some of the values might not be available in all API versions. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + // All instances in the instance group are unhealthy (not in RUNNING state). + ALL_INSTANCES_UNHEALTHY = 404965477; + + // There is no backend service attached to the instance group. + BACKEND_SERVICE_DOES_NOT_EXIST = 191417626; + + // Autoscaler recommends a size greater than maxNumReplicas. + CAPPED_AT_MAX_NUM_REPLICAS = 518617; + + // The custom metric samples are not exported often enough to be a credible base for autoscaling. + CUSTOM_METRIC_DATA_POINTS_TOO_SPARSE = 328964659; + + // The custom metric that was specified does not exist or does not have the necessary labels. + CUSTOM_METRIC_INVALID = 204430550; + + // The minNumReplicas is equal to maxNumReplicas. This means the autoscaler cannot add or remove instances from the instance group. + MIN_EQUALS_MAX = 2821361; + + // The autoscaler did not receive any data from the custom metric configured for autoscaling. + MISSING_CUSTOM_METRIC_DATA_POINTS = 94885086; + + // The autoscaler is configured to scale based on a load balancing signal but the instance group has not received any requests from the load balancer. + MISSING_LOAD_BALANCING_DATA_POINTS = 509858898; + + // Autoscaling is turned off. The number of instances in the group won't change automatically. The autoscaling configuration is preserved. + MODE_OFF = 164169907; + + // Autoscaling is in the "Autoscale only scale out" mode. Instances in the group will be only added. + MODE_ONLY_SCALE_OUT = 3840994; + + // Autoscaling is in the "Autoscale only out" mode. Instances in the group will be only added. + MODE_ONLY_UP = 100969842; + + // The instance group cannot be autoscaled because it has more than one backend service attached to it. + MORE_THAN_ONE_BACKEND_SERVICE = 151922141; + + // There is insufficient quota for the necessary resources, such as CPU or number of instances. + NOT_ENOUGH_QUOTA_AVAILABLE = 403101631; + + // Showed only for regional autoscalers: there is a resource stockout in the chosen region. + REGION_RESOURCE_STOCKOUT = 528622846; + + // The target to be scaled does not exist. + SCALING_TARGET_DOES_NOT_EXIST = 122636699; + + // For some scaling schedules minRequiredReplicas is greater than maxNumReplicas. Autoscaler always recommends at most maxNumReplicas instances. + SCHEDULED_INSTANCES_GREATER_THAN_AUTOSCALER_MAX = 29275586; + + // For some scaling schedules minRequiredReplicas is less than minNumReplicas. Autoscaler always recommends at least minNumReplicas instances. + SCHEDULED_INSTANCES_LESS_THAN_AUTOSCALER_MIN = 398287669; + + UNKNOWN = 433141802; + + // Autoscaling does not work with an HTTP/S load balancer that has been configured for maxRate. + UNSUPPORTED_MAX_RATE_LOAD_BALANCING_CONFIGURATION = 330845009; + + // For zonal autoscalers: there is a resource stockout in the chosen zone. For regional autoscalers: in at least one of the zones you're using there is a resource stockout. + ZONE_RESOURCE_STOCKOUT = 210200502; + + } + + // The status message. + optional string message = 418054151; + + // The type of error, warning, or notice returned. Current set of possible values: - ALL_INSTANCES_UNHEALTHY (WARNING): All instances in the instance group are unhealthy (not in RUNNING state). - BACKEND_SERVICE_DOES_NOT_EXIST (ERROR): There is no backend service attached to the instance group. - CAPPED_AT_MAX_NUM_REPLICAS (WARNING): Autoscaler recommends a size greater than maxNumReplicas. - CUSTOM_METRIC_DATA_POINTS_TOO_SPARSE (WARNING): The custom metric samples are not exported often enough to be a credible base for autoscaling. - CUSTOM_METRIC_INVALID (ERROR): The custom metric that was specified does not exist or does not have the necessary labels. - MIN_EQUALS_MAX (WARNING): The minNumReplicas is equal to maxNumReplicas. This means the autoscaler cannot add or remove instances from the instance group. - MISSING_CUSTOM_METRIC_DATA_POINTS (WARNING): The autoscaler did not receive any data from the custom metric configured for autoscaling. - MISSING_LOAD_BALANCING_DATA_POINTS (WARNING): The autoscaler is configured to scale based on a load balancing signal but the instance group has not received any requests from the load balancer. - MODE_OFF (WARNING): Autoscaling is turned off. The number of instances in the group won't change automatically. The autoscaling configuration is preserved. - MODE_ONLY_UP (WARNING): Autoscaling is in the "Autoscale only out" mode. The autoscaler can add instances but not remove any. - MORE_THAN_ONE_BACKEND_SERVICE (ERROR): The instance group cannot be autoscaled because it has more than one backend service attached to it. - NOT_ENOUGH_QUOTA_AVAILABLE (ERROR): There is insufficient quota for the necessary resources, such as CPU or number of instances. - REGION_RESOURCE_STOCKOUT (ERROR): Shown only for regional autoscalers: there is a resource stockout in the chosen region. - SCALING_TARGET_DOES_NOT_EXIST (ERROR): The target to be scaled does not exist. - UNSUPPORTED_MAX_RATE_LOAD_BALANCING_CONFIGURATION (ERROR): Autoscaling does not work with an HTTP/S load balancer that has been configured for maxRate. - ZONE_RESOURCE_STOCKOUT (ERROR): For zonal autoscalers: there is a resource stockout in the chosen zone. For regional autoscalers: in at least one of the zones you're using there is a resource stockout. New values might be added in the future. Some of the values might not be available in all API versions. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// +message AutoscalersScopedList { + // [Output Only] A list of autoscalers contained in this scope. + repeated Autoscaler autoscalers = 465771644; + + // [Output Only] Informational warning which replaces the list of autoscalers when the list is empty. + optional Warning warning = 50704284; + +} + +// Cloud Autoscaler policy. +message AutoscalingPolicy { + // Defines operating mode for this policy. + enum Mode { + // A value indicating that the enum field is not set. + UNDEFINED_MODE = 0; + + // Do not automatically scale the MIG in or out. The recommended_size field contains the size of MIG that would be set if the actuation mode was enabled. + OFF = 78159; + + // Automatically scale the MIG in and out according to the policy. + ON = 2527; + + // Automatically create VMs according to the policy, but do not scale the MIG in. + ONLY_SCALE_OUT = 152713670; + + // Automatically create VMs according to the policy, but do not scale the MIG in. + ONLY_UP = 478095374; + + } + + // The number of seconds that the autoscaler waits before it starts collecting information from a new instance. This prevents the autoscaler from collecting information when the instance is initializing, during which the collected usage would not be reliable. The default time autoscaler waits is 60 seconds. Virtual machine initialization times might vary because of numerous factors. We recommend that you test how long an instance may take to initialize. To do this, create an instance and time the startup process. + optional int32 cool_down_period_sec = 107692954; + + // Defines the CPU utilization policy that allows the autoscaler to scale based on the average CPU utilization of a managed instance group. + optional AutoscalingPolicyCpuUtilization cpu_utilization = 381211147; + + // Configuration parameters of autoscaling based on a custom metric. + repeated AutoscalingPolicyCustomMetricUtilization custom_metric_utilizations = 131972850; + + // Configuration parameters of autoscaling based on load balancer. + optional AutoscalingPolicyLoadBalancingUtilization load_balancing_utilization = 429746403; + + // The maximum number of instances that the autoscaler can scale out to. This is required when creating or updating an autoscaler. The maximum number of replicas must not be lower than minimal number of replicas. + optional int32 max_num_replicas = 62327375; + + // The minimum number of replicas that the autoscaler can scale in to. This cannot be less than 0. If not provided, autoscaler chooses a default value depending on maximum number of instances allowed. + optional int32 min_num_replicas = 535329825; + + // Defines operating mode for this policy. + // Check the Mode enum for the list of possible values. + optional string mode = 3357091; + + optional AutoscalingPolicyScaleInControl scale_in_control = 527670872; + + // Scaling schedules defined for an autoscaler. Multiple schedules can be set on an autoscaler, and they can overlap. During overlapping periods the greatest min_required_replicas of all scaling schedules is applied. Up to 128 scaling schedules are allowed. + map scaling_schedules = 355416580; + +} + +// CPU utilization policy. +message AutoscalingPolicyCpuUtilization { + // Indicates whether predictive autoscaling based on CPU metric is enabled. Valid values are: * NONE (default). No predictive method is used. The autoscaler scales the group to meet current demand based on real-time metrics. * OPTIMIZE_AVAILABILITY. Predictive autoscaling improves availability by monitoring daily and weekly load patterns and scaling out ahead of anticipated demand. + enum PredictiveMethod { + // A value indicating that the enum field is not set. + UNDEFINED_PREDICTIVE_METHOD = 0; + + // No predictive method is used. The autoscaler scales the group to meet current demand based on real-time metrics + NONE = 2402104; + + // Predictive autoscaling improves availability by monitoring daily and weekly load patterns and scaling out ahead of anticipated demand. + OPTIMIZE_AVAILABILITY = 11629437; + + } + + // Indicates whether predictive autoscaling based on CPU metric is enabled. Valid values are: * NONE (default). No predictive method is used. The autoscaler scales the group to meet current demand based on real-time metrics. * OPTIMIZE_AVAILABILITY. Predictive autoscaling improves availability by monitoring daily and weekly load patterns and scaling out ahead of anticipated demand. + // Check the PredictiveMethod enum for the list of possible values. + optional string predictive_method = 390220737; + + // The target CPU utilization that the autoscaler maintains. Must be a float value in the range (0, 1]. If not specified, the default is 0.6. If the CPU level is below the target utilization, the autoscaler scales in the number of instances until it reaches the minimum number of instances you specified or until the average CPU of your instances reaches the target utilization. If the average CPU is above the target utilization, the autoscaler scales out until it reaches the maximum number of instances you specified or until the average utilization reaches the target utilization. + optional double utilization_target = 215905870; + +} + +// Custom utilization metric policy. +message AutoscalingPolicyCustomMetricUtilization { + // Defines how target utilization value is expressed for a Stackdriver Monitoring metric. Either GAUGE, DELTA_PER_SECOND, or DELTA_PER_MINUTE. + enum UtilizationTargetType { + // A value indicating that the enum field is not set. + UNDEFINED_UTILIZATION_TARGET_TYPE = 0; + + // Sets the utilization target value for a cumulative or delta metric, expressed as the rate of growth per minute. + DELTA_PER_MINUTE = 87432861; + + // Sets the utilization target value for a cumulative or delta metric, expressed as the rate of growth per second. + DELTA_PER_SECOND = 255180029; + + // Sets the utilization target value for a gauge metric. The autoscaler will collect the average utilization of the virtual machines from the last couple of minutes, and compare the value to the utilization target value to perform autoscaling. + GAUGE = 67590361; + + } + + // A filter string, compatible with a Stackdriver Monitoring filter string for TimeSeries.list API call. This filter is used to select a specific TimeSeries for the purpose of autoscaling and to determine whether the metric is exporting per-instance or per-group data. For the filter to be valid for autoscaling purposes, the following rules apply: - You can only use the AND operator for joining selectors. - You can only use direct equality comparison operator (=) without any functions for each selector. - You can specify the metric in both the filter string and in the metric field. However, if specified in both places, the metric must be identical. - The monitored resource type determines what kind of values are expected for the metric. If it is a gce_instance, the autoscaler expects the metric to include a separate TimeSeries for each instance in a group. In such a case, you cannot filter on resource labels. If the resource type is any other value, the autoscaler expects this metric to contain values that apply to the entire autoscaled instance group and resource label filtering can be performed to point autoscaler at the correct TimeSeries to scale upon. This is called a *per-group metric* for the purpose of autoscaling. If not specified, the type defaults to gce_instance. Try to provide a filter that is selective enough to pick just one TimeSeries for the autoscaled group or for each of the instances (if you are using gce_instance resource type). If multiple TimeSeries are returned upon the query execution, the autoscaler will sum their respective values to obtain its scaling value. + optional string filter = 336120696; + + // The identifier (type) of the Stackdriver Monitoring metric. The metric cannot have negative values. The metric must have a value type of INT64 or DOUBLE. + optional string metric = 533067184; + + // If scaling is based on a per-group metric value that represents the total amount of work to be done or resource usage, set this value to an amount assigned for a single instance of the scaled group. Autoscaler keeps the number of instances proportional to the value of this metric. The metric itself does not change value due to group resizing. A good metric to use with the target is for example pubsub.googleapis.com/subscription/num_undelivered_messages or a custom metric exporting the total number of requests coming to your instances. A bad example would be a metric exporting an average or median latency, since this value can't include a chunk assignable to a single instance, it could be better used with utilization_target instead. + optional double single_instance_assignment = 504768064; + + // The target value of the metric that autoscaler maintains. This must be a positive value. A utilization metric scales number of virtual machines handling requests to increase or decrease proportionally to the metric. For example, a good metric to use as a utilization_target is https://www.googleapis.com/compute/v1/instance/network/received_bytes_count. The autoscaler works to keep this value constant for each of the instances. + optional double utilization_target = 215905870; + + // Defines how target utilization value is expressed for a Stackdriver Monitoring metric. Either GAUGE, DELTA_PER_SECOND, or DELTA_PER_MINUTE. + // Check the UtilizationTargetType enum for the list of possible values. + optional string utilization_target_type = 340169355; + +} + +// Configuration parameters of autoscaling based on load balancing. +message AutoscalingPolicyLoadBalancingUtilization { + // Fraction of backend capacity utilization (set in HTTP(S) load balancing configuration) that the autoscaler maintains. Must be a positive float value. If not defined, the default is 0.8. + optional double utilization_target = 215905870; + +} + +// Configuration that allows for slower scale in so that even if Autoscaler recommends an abrupt scale in of a MIG, it will be throttled as specified by the parameters below. +message AutoscalingPolicyScaleInControl { + // Maximum allowed number (or %) of VMs that can be deducted from the peak recommendation during the window autoscaler looks at when computing recommendations. Possibly all these VMs can be deleted at once so user service needs to be prepared to lose that many VMs in one step. + optional FixedOrPercent max_scaled_in_replicas = 180710123; + + // How far back autoscaling looks when computing recommendations to include directives regarding slower scale in, as described above. + optional int32 time_window_sec = 36405300; + +} + +// Scaling based on user-defined schedule. The message describes a single scaling schedule. A scaling schedule changes the minimum number of VM instances an autoscaler can recommend, which can trigger scaling out. +message AutoscalingPolicyScalingSchedule { + // A description of a scaling schedule. + optional string description = 422937596; + + // A boolean value that specifies whether a scaling schedule can influence autoscaler recommendations. If set to true, then a scaling schedule has no effect. This field is optional, and its value is false by default. + optional bool disabled = 270940796; + + // The duration of time intervals, in seconds, for which this scaling schedule is to run. The minimum allowed value is 300. This field is required. + optional int32 duration_sec = 212356902; + + // The minimum number of VM instances that the autoscaler will recommend in time intervals starting according to schedule. This field is required. + optional int32 min_required_replicas = 365514414; + + // The start timestamps of time intervals when this scaling schedule is to provide a scaling signal. This field uses the extended cron format (with an optional year field). The expression can describe a single timestamp if the optional year is set, in which case the scaling schedule runs once. The schedule is interpreted with respect to time_zone. This field is required. Note: These timestamps only describe when autoscaler starts providing the scaling signal. The VMs need additional time to become serving. + optional string schedule = 375820951; + + // The time zone to use when interpreting the schedule. The value of this field must be a time zone name from the tz database: http://en.wikipedia.org/wiki/Tz_database. This field is assigned a default value of “UTC” if left empty. + optional string time_zone = 36848094; + +} + +// Message containing information of one individual backend. +message Backend { + // Specifies how to determine whether the backend of a load balancer can handle additional traffic or is fully loaded. For usage guidelines, see Connection balancing mode. Backends must use compatible balancing modes. For more information, see Supported balancing modes and target capacity settings and Restrictions and guidance for instance groups. Note: Currently, if you use the API to configure incompatible balancing modes, the configuration might be accepted even though it has no impact and is ignored. Specifically, Backend.maxUtilization is ignored when Backend.balancingMode is RATE. In the future, this incompatible combination will be rejected. + enum BalancingMode { + // A value indicating that the enum field is not set. + UNDEFINED_BALANCING_MODE = 0; + + // Balance based on the number of simultaneous connections. + CONNECTION = 246311646; + + // Balance based on requests per second (RPS). + RATE = 2508000; + + // Balance based on the backend utilization. + UTILIZATION = 157008386; + + } + + // Specifies how to determine whether the backend of a load balancer can handle additional traffic or is fully loaded. For usage guidelines, see Connection balancing mode. Backends must use compatible balancing modes. For more information, see Supported balancing modes and target capacity settings and Restrictions and guidance for instance groups. Note: Currently, if you use the API to configure incompatible balancing modes, the configuration might be accepted even though it has no impact and is ignored. Specifically, Backend.maxUtilization is ignored when Backend.balancingMode is RATE. In the future, this incompatible combination will be rejected. + // Check the BalancingMode enum for the list of possible values. + optional string balancing_mode = 430286217; + + // A multiplier applied to the backend's target capacity of its balancing mode. The default value is 1, which means the group serves up to 100% of its configured capacity (depending on balancingMode). A setting of 0 means the group is completely drained, offering 0% of its available capacity. The valid ranges are 0.0 and [0.1,1.0]. You cannot configure a setting larger than 0 and smaller than 0.1. You cannot configure a setting of 0 when there is only one backend attached to the backend service. Not available with backends that don't support using a balancingMode. This includes backends such as global internet NEGs, regional serverless NEGs, and PSC NEGs. + optional float capacity_scaler = 315958157; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // This field designates whether this is a failover backend. More than one failover backend can be configured for a given BackendService. + optional bool failover = 138892530; + + // The fully-qualified URL of an instance group or network endpoint group (NEG) resource. To determine what types of backends a load balancer supports, see the [Backend services overview](https://cloud.google.com/load-balancing/docs/backend-service#backends). You must use the *fully-qualified* URL (starting with https://www.googleapis.com/) to specify the instance group or NEG. Partial URLs are not supported. + optional string group = 98629247; + + // Defines a target maximum number of simultaneous connections. For usage guidelines, see Connection balancing mode and Utilization balancing mode. Not available if the backend's balancingMode is RATE. + optional int32 max_connections = 110652154; + + // Defines a target maximum number of simultaneous connections. For usage guidelines, see Connection balancing mode and Utilization balancing mode. Not available if the backend's balancingMode is RATE. + optional int32 max_connections_per_endpoint = 216904604; + + // Defines a target maximum number of simultaneous connections. For usage guidelines, see Connection balancing mode and Utilization balancing mode. Not available if the backend's balancingMode is RATE. + optional int32 max_connections_per_instance = 104671900; + + // Defines a maximum number of HTTP requests per second (RPS). For usage guidelines, see Rate balancing mode and Utilization balancing mode. Not available if the backend's balancingMode is CONNECTION. + optional int32 max_rate = 408035035; + + // Defines a maximum target for requests per second (RPS). For usage guidelines, see Rate balancing mode and Utilization balancing mode. Not available if the backend's balancingMode is CONNECTION. + optional float max_rate_per_endpoint = 129832283; + + // Defines a maximum target for requests per second (RPS). For usage guidelines, see Rate balancing mode and Utilization balancing mode. Not available if the backend's balancingMode is CONNECTION. + optional float max_rate_per_instance = 17599579; + + // Optional parameter to define a target capacity for the UTILIZATION balancing mode. The valid range is [0.0, 1.0]. For usage guidelines, see Utilization balancing mode. + optional float max_utilization = 148192199; + +} + +// Represents a Cloud Storage Bucket resource. This Cloud Storage bucket resource is referenced by a URL map of a load balancer. For more information, read Backend Buckets. +message BackendBucket { + // Compress text responses using Brotli or gzip compression, based on the client's Accept-Encoding header. + enum CompressionMode { + // A value indicating that the enum field is not set. + UNDEFINED_COMPRESSION_MODE = 0; + + // Automatically uses the best compression based on the Accept-Encoding header sent by the client. + AUTOMATIC = 165298699; + + // Disables compression. Existing compressed responses cached by Cloud CDN will not be served to clients. + DISABLED = 516696700; + + } + + // Cloud Storage bucket name. + optional string bucket_name = 283610048; + + // Cloud CDN configuration for this BackendBucket. + optional BackendBucketCdnPolicy cdn_policy = 213976452; + + // Compress text responses using Brotli or gzip compression, based on the client's Accept-Encoding header. + // Check the CompressionMode enum for the list of possible values. + optional string compression_mode = 95520988; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // Headers that the HTTP/S load balancer should add to proxied responses. + repeated string custom_response_headers = 387539094; + + // An optional textual description of the resource; provided by the client when the resource is created. + optional string description = 422937596; + + // [Output Only] The resource URL for the edge security policy associated with this backend bucket. + optional string edge_security_policy = 41036943; + + // If true, enable Cloud CDN for this BackendBucket. + optional bool enable_cdn = 282942321; + + // [Output Only] Unique identifier for the resource; defined by the server. + optional uint64 id = 3355; + + // Type of the resource. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + +} + +// Message containing Cloud CDN configuration for a backend bucket. +message BackendBucketCdnPolicy { + // Specifies the cache setting for all responses from this backend. The possible values are: USE_ORIGIN_HEADERS Requires the origin to set valid caching headers to cache content. Responses without these headers will not be cached at Google's edge, and will require a full trip to the origin on every request, potentially impacting performance and increasing load on the origin server. FORCE_CACHE_ALL Cache all content, ignoring any "private", "no-store" or "no-cache" directives in Cache-Control response headers. Warning: this may result in Cloud CDN caching private, per-user (user identifiable) content. CACHE_ALL_STATIC Automatically cache static content, including common image formats, media (video and audio), and web assets (JavaScript and CSS). Requests and responses that are marked as uncacheable, as well as dynamic content (including HTML), will not be cached. + enum CacheMode { + // A value indicating that the enum field is not set. + UNDEFINED_CACHE_MODE = 0; + + // Automatically cache static content, including common image formats, media (video and audio), and web assets (JavaScript and CSS). Requests and responses that are marked as uncacheable, as well as dynamic content (including HTML), will not be cached. + CACHE_ALL_STATIC = 355027945; + + // Cache all content, ignoring any "private", "no-store" or "no-cache" directives in Cache-Control response headers. Warning: this may result in Cloud CDN caching private, per-user (user identifiable) content. + FORCE_CACHE_ALL = 486026928; + + INVALID_CACHE_MODE = 381295560; + + // Requires the origin to set valid caching headers to cache content. Responses without these headers will not be cached at Google's edge, and will require a full trip to the origin on every request, potentially impacting performance and increasing load on the origin server. + USE_ORIGIN_HEADERS = 55380261; + + } + + // Bypass the cache when the specified request headers are matched - e.g. Pragma or Authorization headers. Up to 5 headers can be specified. The cache is bypassed for all cdnPolicy.cacheMode settings. + repeated BackendBucketCdnPolicyBypassCacheOnRequestHeader bypass_cache_on_request_headers = 486203082; + + // The CacheKeyPolicy for this CdnPolicy. + optional BackendBucketCdnPolicyCacheKeyPolicy cache_key_policy = 159263727; + + // Specifies the cache setting for all responses from this backend. The possible values are: USE_ORIGIN_HEADERS Requires the origin to set valid caching headers to cache content. Responses without these headers will not be cached at Google's edge, and will require a full trip to the origin on every request, potentially impacting performance and increasing load on the origin server. FORCE_CACHE_ALL Cache all content, ignoring any "private", "no-store" or "no-cache" directives in Cache-Control response headers. Warning: this may result in Cloud CDN caching private, per-user (user identifiable) content. CACHE_ALL_STATIC Automatically cache static content, including common image formats, media (video and audio), and web assets (JavaScript and CSS). Requests and responses that are marked as uncacheable, as well as dynamic content (including HTML), will not be cached. + // Check the CacheMode enum for the list of possible values. + optional string cache_mode = 28877888; + + // Specifies a separate client (e.g. browser client) maximum TTL. This is used to clamp the max-age (or Expires) value sent to the client. With FORCE_CACHE_ALL, the lesser of client_ttl and default_ttl is used for the response max-age directive, along with a "public" directive. For cacheable content in CACHE_ALL_STATIC mode, client_ttl clamps the max-age from the origin (if specified), or else sets the response max-age directive to the lesser of the client_ttl and default_ttl, and also ensures a "public" cache-control directive is present. If a client TTL is not specified, a default value (1 hour) will be used. The maximum allowed value is 31,622,400s (1 year). + optional int32 client_ttl = 29034360; + + // Specifies the default TTL for cached content served by this origin for responses that do not have an existing valid TTL (max-age or s-max-age). Setting a TTL of "0" means "always revalidate". The value of defaultTTL cannot be set to a value greater than that of maxTTL, but can be equal. When the cacheMode is set to FORCE_CACHE_ALL, the defaultTTL will overwrite the TTL set in all responses. The maximum allowed value is 31,622,400s (1 year), noting that infrequently accessed objects may be evicted from the cache before the defined TTL. + optional int32 default_ttl = 100253422; + + // Specifies the maximum allowed TTL for cached content served by this origin. Cache directives that attempt to set a max-age or s-maxage higher than this, or an Expires header more than maxTTL seconds in the future will be capped at the value of maxTTL, as if it were the value of an s-maxage Cache-Control directive. Headers sent to the client will not be modified. Setting a TTL of "0" means "always revalidate". The maximum allowed value is 31,622,400s (1 year), noting that infrequently accessed objects may be evicted from the cache before the defined TTL. + optional int32 max_ttl = 307578001; + + // Negative caching allows per-status code TTLs to be set, in order to apply fine-grained caching for common errors or redirects. This can reduce the load on your origin and improve end-user experience by reducing response latency. When the cache mode is set to CACHE_ALL_STATIC or USE_ORIGIN_HEADERS, negative caching applies to responses with the specified response code that lack any Cache-Control, Expires, or Pragma: no-cache directives. When the cache mode is set to FORCE_CACHE_ALL, negative caching applies to all responses with the specified response code, and override any caching headers. By default, Cloud CDN will apply the following default TTLs to these status codes: HTTP 300 (Multiple Choice), 301, 308 (Permanent Redirects): 10m HTTP 404 (Not Found), 410 (Gone), 451 (Unavailable For Legal Reasons): 120s HTTP 405 (Method Not Found), 421 (Misdirected Request), 501 (Not Implemented): 60s. These defaults can be overridden in negative_caching_policy. + optional bool negative_caching = 336110005; + + // Sets a cache TTL for the specified HTTP status code. negative_caching must be enabled to configure negative_caching_policy. Omitting the policy and leaving negative_caching enabled will use Cloud CDN's default cache TTLs. Note that when specifying an explicit negative_caching_policy, you should take care to specify a cache TTL for all response codes that you wish to cache. Cloud CDN will not apply any default negative caching when a policy exists. + repeated BackendBucketCdnPolicyNegativeCachingPolicy negative_caching_policy = 155359996; + + // If true then Cloud CDN will combine multiple concurrent cache fill requests into a small number of requests to the origin. + optional bool request_coalescing = 532808276; + + // Serve existing content from the cache (if available) when revalidating content with the origin, or when an error is encountered when refreshing the cache. This setting defines the default "max-stale" duration for any cached responses that do not specify a max-stale directive. Stale responses that exceed the TTL configured here will not be served. The default limit (max-stale) is 86400s (1 day), which will allow stale content to be served up to this limit beyond the max-age (or s-max-age) of a cached response. The maximum allowed value is 604800 (1 week). Set this to zero (0) to disable serve-while-stale. + optional int32 serve_while_stale = 236682203; + + // Maximum number of seconds the response to a signed URL request will be considered fresh. After this time period, the response will be revalidated before being served. Defaults to 1hr (3600s). When serving responses to signed URL requests, Cloud CDN will internally behave as though all responses from this backend had a "Cache-Control: public, max-age=[TTL]" header, regardless of any existing Cache-Control header. The actual headers served in responses will not be altered. + optional int64 signed_url_cache_max_age_sec = 269374534; + + // [Output Only] Names of the keys for signing request URLs. + repeated string signed_url_key_names = 371848885; + +} + +// Bypass the cache when the specified request headers are present, e.g. Pragma or Authorization headers. Values are case insensitive. The presence of such a header overrides the cache_mode setting. +message BackendBucketCdnPolicyBypassCacheOnRequestHeader { + // The header field name to match on when bypassing cache. Values are case-insensitive. + optional string header_name = 110223613; + +} + +// Message containing what to include in the cache key for a request for Cloud CDN. +message BackendBucketCdnPolicyCacheKeyPolicy { + // Allows HTTP request headers (by name) to be used in the cache key. + repeated string include_http_headers = 2489606; + + // Names of query string parameters to include in cache keys. Default parameters are always included. '&' and '=' will be percent encoded and not treated as delimiters. + repeated string query_string_whitelist = 52456496; + +} + +// Specify CDN TTLs for response error codes. +message BackendBucketCdnPolicyNegativeCachingPolicy { + // The HTTP status code to define a TTL against. Only HTTP status codes 300, 301, 302, 307, 308, 404, 405, 410, 421, 451 and 501 are can be specified as values, and you cannot specify a status code more than once. + optional int32 code = 3059181; + + // The TTL (in seconds) for which to cache responses with the corresponding status code. The maximum allowed value is 1800s (30 minutes), noting that infrequently accessed objects may be evicted from the cache before the defined TTL. + optional int32 ttl = 115180; + +} + +// Contains a list of BackendBucket resources. +message BackendBucketList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of BackendBucket resources. + repeated BackendBucket items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Represents a Backend Service resource. A backend service defines how Google Cloud load balancers distribute traffic. The backend service configuration contains a set of values, such as the protocol used to connect to backends, various distribution and session settings, health checks, and timeouts. These settings provide fine-grained control over how your load balancer behaves. Most of the settings have default values that allow for easy configuration if you need to get started quickly. Backend services in Google Compute Engine can be either regionally or globally scoped. * [Global](https://cloud.google.com/compute/docs/reference/rest/v1/backendServices) * [Regional](https://cloud.google.com/compute/docs/reference/rest/v1/regionBackendServices) For more information, see Backend Services. +message BackendService { + // Compress text responses using Brotli or gzip compression, based on the client's Accept-Encoding header. + enum CompressionMode { + // A value indicating that the enum field is not set. + UNDEFINED_COMPRESSION_MODE = 0; + + // Automatically uses the best compression based on the Accept-Encoding header sent by the client. + AUTOMATIC = 165298699; + + // Disables compression. Existing compressed responses cached by Cloud CDN will not be served to clients. + DISABLED = 516696700; + + } + + // Specifies the load balancer type. A backend service created for one type of load balancer cannot be used with another. For more information, refer to Choosing a load balancer. + enum LoadBalancingScheme { + // A value indicating that the enum field is not set. + UNDEFINED_LOAD_BALANCING_SCHEME = 0; + + // Signifies that this will be used for external HTTP(S), SSL Proxy, TCP Proxy, or Network Load Balancing + EXTERNAL = 35607499; + + // Signifies that this will be used for External Managed HTTP(S) Load Balancing. + EXTERNAL_MANAGED = 512006923; + + // Signifies that this will be used for Internal TCP/UDP Load Balancing. + INTERNAL = 279295677; + + // Signifies that this will be used for Internal HTTP(S) Load Balancing. + INTERNAL_MANAGED = 37350397; + + // Signifies that this will be used by Traffic Director. + INTERNAL_SELF_MANAGED = 236211150; + + INVALID_LOAD_BALANCING_SCHEME = 275352060; + + } + + // The load balancing algorithm used within the scope of the locality. The possible values are: - ROUND_ROBIN: This is a simple policy in which each healthy backend is selected in round robin order. This is the default. - LEAST_REQUEST: An O(1) algorithm which selects two random healthy hosts and picks the host which has fewer active requests. - RING_HASH: The ring/modulo hash load balancer implements consistent hashing to backends. The algorithm has the property that the addition/removal of a host from a set of N hosts only affects 1/N of the requests. - RANDOM: The load balancer selects a random healthy host. - ORIGINAL_DESTINATION: Backend host is selected based on the client connection metadata, i.e., connections are opened to the same address as the destination address of the incoming connection before the connection was redirected to the load balancer. - MAGLEV: used as a drop in replacement for the ring hash load balancer. Maglev is not as stable as ring hash but has faster table lookup build times and host selection times. For more information about Maglev, see https://ai.google/research/pubs/pub44824 This field is applicable to either: - A regional backend service with the service_protocol set to HTTP, HTTPS, or HTTP2, and load_balancing_scheme set to INTERNAL_MANAGED. - A global backend service with the load_balancing_scheme set to INTERNAL_SELF_MANAGED. If sessionAffinity is not NONE, and this field is not set to MAGLEV or RING_HASH, session affinity settings will not take effect. Only ROUND_ROBIN and RING_HASH are supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. + enum LocalityLbPolicy { + // A value indicating that the enum field is not set. + UNDEFINED_LOCALITY_LB_POLICY = 0; + + INVALID_LB_POLICY = 323318707; + + // An O(1) algorithm which selects two random healthy hosts and picks the host which has fewer active requests. + LEAST_REQUEST = 46604921; + + // This algorithm implements consistent hashing to backends. Maglev can be used as a drop in replacement for the ring hash load balancer. Maglev is not as stable as ring hash but has faster table lookup build times and host selection times. For more information about Maglev, see https://ai.google/research/pubs/pub44824 + MAGLEV = 119180266; + + // Backend host is selected based on the client connection metadata, i.e., connections are opened to the same address as the destination address of the incoming connection before the connection was redirected to the load balancer. + ORIGINAL_DESTINATION = 166297216; + + // The load balancer selects a random healthy host. + RANDOM = 262527171; + + // The ring/modulo hash load balancer implements consistent hashing to backends. The algorithm has the property that the addition/removal of a host from a set of N hosts only affects 1/N of the requests. + RING_HASH = 432795069; + + // This is a simple policy in which each healthy backend is selected in round robin order. This is the default. + ROUND_ROBIN = 153895801; + + // Per-instance weighted Load Balancing via health check reported weights. If set, the Backend Service must configure a non legacy HTTP-based Health Check, and health check replies are expected to contain non-standard HTTP response header field X-Load-Balancing-Endpoint-Weight to specify the per-instance weights. If set, Load Balancing is weighted based on the per-instance weights reported in the last processed health check replies, as long as every instance either reported a valid weight or had UNAVAILABLE_WEIGHT. Otherwise, Load Balancing remains equal-weight. This option is only supported in Network Load Balancing. + WEIGHTED_MAGLEV = 254930962; + + } + + // The protocol this BackendService uses to communicate with backends. Possible values are HTTP, HTTPS, HTTP2, TCP, SSL, UDP or GRPC. depending on the chosen load balancer or Traffic Director configuration. Refer to the documentation for the load balancers or for Traffic Director for more information. Must be set to GRPC when the backend service is referenced by a URL map that is bound to target gRPC proxy. + enum Protocol { + // A value indicating that the enum field is not set. + UNDEFINED_PROTOCOL = 0; + + // gRPC (available for Traffic Director). + GRPC = 2196510; + + HTTP = 2228360; + + // HTTP/2 with SSL. + HTTP2 = 69079210; + + HTTPS = 69079243; + + // TCP proxying with SSL. + SSL = 82412; + + // TCP proxying or TCP pass-through. + TCP = 82881; + + // UDP. + UDP = 83873; + + // If a Backend Service has UNSPECIFIED as its protocol, it can be used with any L3/L4 Forwarding Rules. + UNSPECIFIED = 526786327; + + } + + // Type of session affinity to use. The default is NONE. Only NONE and HEADER_FIELD are supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. For more details, see: [Session Affinity](https://cloud.google.com/load-balancing/docs/backend-service#session_affinity). + enum SessionAffinity { + // A value indicating that the enum field is not set. + UNDEFINED_SESSION_AFFINITY = 0; + + // 2-tuple hash on packet's source and destination IP addresses. Connections from the same source IP address to the same destination IP address will be served by the same backend VM while that VM remains healthy. + CLIENT_IP = 345665051; + + // 1-tuple hash only on packet's source IP address. Connections from the same source IP address will be served by the same backend VM while that VM remains healthy. This option can only be used for Internal TCP/UDP Load Balancing. + CLIENT_IP_NO_DESTINATION = 106122516; + + // 5-tuple hash on packet's source and destination IP addresses, IP protocol, and source and destination ports. Connections for the same IP protocol from the same source IP address and port to the same destination IP address and port will be served by the same backend VM while that VM remains healthy. This option cannot be used for HTTP(S) load balancing. + CLIENT_IP_PORT_PROTO = 221722926; + + // 3-tuple hash on packet's source and destination IP addresses, and IP protocol. Connections for the same IP protocol from the same source IP address to the same destination IP address will be served by the same backend VM while that VM remains healthy. This option cannot be used for HTTP(S) load balancing. + CLIENT_IP_PROTO = 25322148; + + // Hash based on a cookie generated by the L7 loadbalancer. Only valid for HTTP(S) load balancing. + GENERATED_COOKIE = 370321204; + + // The hash is based on a user specified header field. + HEADER_FIELD = 200737960; + + // The hash is based on a user provided cookie. + HTTP_COOKIE = 494981627; + + // No session affinity. Connections from the same client IP may go to any instance in the pool. + NONE = 2402104; + + } + + // Lifetime of cookies in seconds. This setting is applicable to external and internal HTTP(S) load balancers and Traffic Director and requires GENERATED_COOKIE or HTTP_COOKIE session affinity. If set to 0, the cookie is non-persistent and lasts only until the end of the browser session (or equivalent). The maximum allowed value is two weeks (1,209,600). Not supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. + optional int32 affinity_cookie_ttl_sec = 369996954; + + // The list of backends that serve this BackendService. + repeated Backend backends = 510839903; + + // Cloud CDN configuration for this BackendService. Only available for specified load balancer types. + optional BackendServiceCdnPolicy cdn_policy = 213976452; + + optional CircuitBreakers circuit_breakers = 421340061; + + // Compress text responses using Brotli or gzip compression, based on the client's Accept-Encoding header. + // Check the CompressionMode enum for the list of possible values. + optional string compression_mode = 95520988; + + optional ConnectionDraining connection_draining = 461096747; + + // Connection Tracking configuration for this BackendService. Connection tracking policy settings are only available for Network Load Balancing and Internal TCP/UDP Load Balancing. + optional BackendServiceConnectionTrackingPolicy connection_tracking_policy = 143994969; + + // Consistent Hash-based load balancing can be used to provide soft session affinity based on HTTP headers, cookies or other properties. This load balancing policy is applicable only for HTTP connections. The affinity to a particular destination host will be lost when one or more hosts are added/removed from the destination service. This field specifies parameters that control consistent hashing. This field is only applicable when localityLbPolicy is set to MAGLEV or RING_HASH. This field is applicable to either: - A regional backend service with the service_protocol set to HTTP, HTTPS, or HTTP2, and load_balancing_scheme set to INTERNAL_MANAGED. - A global backend service with the load_balancing_scheme set to INTERNAL_SELF_MANAGED. + optional ConsistentHashLoadBalancerSettings consistent_hash = 905883; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // Headers that the load balancer adds to proxied requests. See [Creating custom headers](https://cloud.google.com/load-balancing/docs/custom-headers). + repeated string custom_request_headers = 27977992; + + // Headers that the load balancer adds to proxied responses. See [Creating custom headers](https://cloud.google.com/load-balancing/docs/custom-headers). + repeated string custom_response_headers = 387539094; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] The resource URL for the edge security policy associated with this backend service. + optional string edge_security_policy = 41036943; + + // If true, enables Cloud CDN for the backend service of an external HTTP(S) load balancer. + optional bool enable_c_d_n = 250733499; + + // Requires at least one backend instance group to be defined as a backup (failover) backend. For load balancers that have configurable failover: [Internal TCP/UDP Load Balancing](https://cloud.google.com/load-balancing/docs/internal/failover-overview) and [external TCP/UDP Load Balancing](https://cloud.google.com/load-balancing/docs/network/networklb-failover-overview). + optional BackendServiceFailoverPolicy failover_policy = 105658655; + + // Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a BackendService. An up-to-date fingerprint must be provided in order to update the BackendService, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve a BackendService. + optional string fingerprint = 234678500; + + // The list of URLs to the healthChecks, httpHealthChecks (legacy), or httpsHealthChecks (legacy) resource for health checking this backend service. Not all backend services support legacy health checks. See Load balancer guide. Currently, at most one health check can be specified for each backend service. Backend services with instance group or zonal NEG backends must have a health check. Backend services with internet or serverless NEG backends must not have a health check. + repeated string health_checks = 448370606; + + // The configurations for Identity-Aware Proxy on this resource. Not available for Internal TCP/UDP Load Balancing and Network Load Balancing. + optional BackendServiceIAP iap = 104024; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of resource. Always compute#backendService for backend services. + optional string kind = 3292052; + + // Specifies the load balancer type. A backend service created for one type of load balancer cannot be used with another. For more information, refer to Choosing a load balancer. + // Check the LoadBalancingScheme enum for the list of possible values. + optional string load_balancing_scheme = 363890244; + + // A list of locality load-balancing policies to be used in order of preference. When you use localityLbPolicies, you must set at least one value for either the localityLbPolicies[].policy or the localityLbPolicies[].customPolicy field. localityLbPolicies overrides any value set in the localityLbPolicy field. For an example of how to use this field, see Define a list of preferred policies. Caution: This field and its children are intended for use in a service mesh that includes gRPC clients only. Envoy proxies can't use backend services that have this configuration. + repeated BackendServiceLocalityLoadBalancingPolicyConfig locality_lb_policies = 140982557; + + // The load balancing algorithm used within the scope of the locality. The possible values are: - ROUND_ROBIN: This is a simple policy in which each healthy backend is selected in round robin order. This is the default. - LEAST_REQUEST: An O(1) algorithm which selects two random healthy hosts and picks the host which has fewer active requests. - RING_HASH: The ring/modulo hash load balancer implements consistent hashing to backends. The algorithm has the property that the addition/removal of a host from a set of N hosts only affects 1/N of the requests. - RANDOM: The load balancer selects a random healthy host. - ORIGINAL_DESTINATION: Backend host is selected based on the client connection metadata, i.e., connections are opened to the same address as the destination address of the incoming connection before the connection was redirected to the load balancer. - MAGLEV: used as a drop in replacement for the ring hash load balancer. Maglev is not as stable as ring hash but has faster table lookup build times and host selection times. For more information about Maglev, see https://ai.google/research/pubs/pub44824 This field is applicable to either: - A regional backend service with the service_protocol set to HTTP, HTTPS, or HTTP2, and load_balancing_scheme set to INTERNAL_MANAGED. - A global backend service with the load_balancing_scheme set to INTERNAL_SELF_MANAGED. If sessionAffinity is not NONE, and this field is not set to MAGLEV or RING_HASH, session affinity settings will not take effect. Only ROUND_ROBIN and RING_HASH are supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. + // Check the LocalityLbPolicy enum for the list of possible values. + optional string locality_lb_policy = 131431487; + + // This field denotes the logging options for the load balancer traffic served by this backend service. If logging is enabled, logs will be exported to Stackdriver. + optional BackendServiceLogConfig log_config = 351299741; + + // Specifies the default maximum duration (timeout) for streams to this service. Duration is computed from the beginning of the stream until the response has been completely processed, including all retries. A stream that does not complete in this duration is closed. If not specified, there will be no timeout limit, i.e. the maximum duration is infinite. This value can be overridden in the PathMatcher configuration of the UrlMap that references this backend service. This field is only allowed when the loadBalancingScheme of the backend service is INTERNAL_SELF_MANAGED. + optional Duration max_stream_duration = 61428376; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // The URL of the network to which this backend service belongs. This field can only be specified when the load balancing scheme is set to INTERNAL. + optional string network = 232872494; + + // Settings controlling the eviction of unhealthy hosts from the load balancing pool for the backend service. If not set, this feature is considered disabled. This field is applicable to either: - A regional backend service with the service_protocol set to HTTP, HTTPS, HTTP2, or GRPC, and load_balancing_scheme set to INTERNAL_MANAGED. - A global backend service with the load_balancing_scheme set to INTERNAL_SELF_MANAGED. + optional OutlierDetection outlier_detection = 354625086; + + // Deprecated in favor of portName. The TCP port to connect on the backend. The default value is 80. For Internal TCP/UDP Load Balancing and Network Load Balancing, omit port. + optional int32 port = 3446913; + + // A named port on a backend instance group representing the port for communication to the backend VMs in that group. The named port must be [defined on each backend instance group](https://cloud.google.com/load-balancing/docs/backend-service#named_ports). This parameter has no meaning if the backends are NEGs. For Internal TCP/UDP Load Balancing and Network Load Balancing, omit port_name. + optional string port_name = 41534345; + + // The protocol this BackendService uses to communicate with backends. Possible values are HTTP, HTTPS, HTTP2, TCP, SSL, UDP or GRPC. depending on the chosen load balancer or Traffic Director configuration. Refer to the documentation for the load balancers or for Traffic Director for more information. Must be set to GRPC when the backend service is referenced by a URL map that is bound to target gRPC proxy. + // Check the Protocol enum for the list of possible values. + optional string protocol = 84577944; + + // [Output Only] URL of the region where the regional backend service resides. This field is not applicable to global backend services. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string region = 138946292; + + // [Output Only] The resource URL for the security policy associated with this backend service. + optional string security_policy = 171082513; + + // This field specifies the security settings that apply to this backend service. This field is applicable to a global backend service with the load_balancing_scheme set to INTERNAL_SELF_MANAGED. + optional SecuritySettings security_settings = 478649922; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // URLs of networkservices.ServiceBinding resources. Can only be set if load balancing scheme is INTERNAL_SELF_MANAGED. If set, lists of backends and health checks must be both empty. + repeated string service_bindings = 133581016; + + // Type of session affinity to use. The default is NONE. Only NONE and HEADER_FIELD are supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. For more details, see: [Session Affinity](https://cloud.google.com/load-balancing/docs/backend-service#session_affinity). + // Check the SessionAffinity enum for the list of possible values. + optional string session_affinity = 463888561; + + optional Subsetting subsetting = 450283536; + + // The backend service timeout has a different meaning depending on the type of load balancer. For more information see, Backend service settings. The default is 30 seconds. The full range of timeout values allowed goes from 1 through 2,147,483,647 seconds. This value can be overridden in the PathMatcher configuration of the UrlMap that references this backend service. Not supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. Instead, use maxStreamDuration. + optional int32 timeout_sec = 79994995; + +} + +// Contains a list of BackendServicesScopedList. +message BackendServiceAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of BackendServicesScopedList resources. + map items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Message containing Cloud CDN configuration for a backend service. +message BackendServiceCdnPolicy { + // Specifies the cache setting for all responses from this backend. The possible values are: USE_ORIGIN_HEADERS Requires the origin to set valid caching headers to cache content. Responses without these headers will not be cached at Google's edge, and will require a full trip to the origin on every request, potentially impacting performance and increasing load on the origin server. FORCE_CACHE_ALL Cache all content, ignoring any "private", "no-store" or "no-cache" directives in Cache-Control response headers. Warning: this may result in Cloud CDN caching private, per-user (user identifiable) content. CACHE_ALL_STATIC Automatically cache static content, including common image formats, media (video and audio), and web assets (JavaScript and CSS). Requests and responses that are marked as uncacheable, as well as dynamic content (including HTML), will not be cached. + enum CacheMode { + // A value indicating that the enum field is not set. + UNDEFINED_CACHE_MODE = 0; + + // Automatically cache static content, including common image formats, media (video and audio), and web assets (JavaScript and CSS). Requests and responses that are marked as uncacheable, as well as dynamic content (including HTML), will not be cached. + CACHE_ALL_STATIC = 355027945; + + // Cache all content, ignoring any "private", "no-store" or "no-cache" directives in Cache-Control response headers. Warning: this may result in Cloud CDN caching private, per-user (user identifiable) content. + FORCE_CACHE_ALL = 486026928; + + INVALID_CACHE_MODE = 381295560; + + // Requires the origin to set valid caching headers to cache content. Responses without these headers will not be cached at Google's edge, and will require a full trip to the origin on every request, potentially impacting performance and increasing load on the origin server. + USE_ORIGIN_HEADERS = 55380261; + + } + + // Bypass the cache when the specified request headers are matched - e.g. Pragma or Authorization headers. Up to 5 headers can be specified. The cache is bypassed for all cdnPolicy.cacheMode settings. + repeated BackendServiceCdnPolicyBypassCacheOnRequestHeader bypass_cache_on_request_headers = 486203082; + + // The CacheKeyPolicy for this CdnPolicy. + optional CacheKeyPolicy cache_key_policy = 159263727; + + // Specifies the cache setting for all responses from this backend. The possible values are: USE_ORIGIN_HEADERS Requires the origin to set valid caching headers to cache content. Responses without these headers will not be cached at Google's edge, and will require a full trip to the origin on every request, potentially impacting performance and increasing load on the origin server. FORCE_CACHE_ALL Cache all content, ignoring any "private", "no-store" or "no-cache" directives in Cache-Control response headers. Warning: this may result in Cloud CDN caching private, per-user (user identifiable) content. CACHE_ALL_STATIC Automatically cache static content, including common image formats, media (video and audio), and web assets (JavaScript and CSS). Requests and responses that are marked as uncacheable, as well as dynamic content (including HTML), will not be cached. + // Check the CacheMode enum for the list of possible values. + optional string cache_mode = 28877888; + + // Specifies a separate client (e.g. browser client) maximum TTL. This is used to clamp the max-age (or Expires) value sent to the client. With FORCE_CACHE_ALL, the lesser of client_ttl and default_ttl is used for the response max-age directive, along with a "public" directive. For cacheable content in CACHE_ALL_STATIC mode, client_ttl clamps the max-age from the origin (if specified), or else sets the response max-age directive to the lesser of the client_ttl and default_ttl, and also ensures a "public" cache-control directive is present. If a client TTL is not specified, a default value (1 hour) will be used. The maximum allowed value is 31,622,400s (1 year). + optional int32 client_ttl = 29034360; + + // Specifies the default TTL for cached content served by this origin for responses that do not have an existing valid TTL (max-age or s-max-age). Setting a TTL of "0" means "always revalidate". The value of defaultTTL cannot be set to a value greater than that of maxTTL, but can be equal. When the cacheMode is set to FORCE_CACHE_ALL, the defaultTTL will overwrite the TTL set in all responses. The maximum allowed value is 31,622,400s (1 year), noting that infrequently accessed objects may be evicted from the cache before the defined TTL. + optional int32 default_ttl = 100253422; + + // Specifies the maximum allowed TTL for cached content served by this origin. Cache directives that attempt to set a max-age or s-maxage higher than this, or an Expires header more than maxTTL seconds in the future will be capped at the value of maxTTL, as if it were the value of an s-maxage Cache-Control directive. Headers sent to the client will not be modified. Setting a TTL of "0" means "always revalidate". The maximum allowed value is 31,622,400s (1 year), noting that infrequently accessed objects may be evicted from the cache before the defined TTL. + optional int32 max_ttl = 307578001; + + // Negative caching allows per-status code TTLs to be set, in order to apply fine-grained caching for common errors or redirects. This can reduce the load on your origin and improve end-user experience by reducing response latency. When the cache mode is set to CACHE_ALL_STATIC or USE_ORIGIN_HEADERS, negative caching applies to responses with the specified response code that lack any Cache-Control, Expires, or Pragma: no-cache directives. When the cache mode is set to FORCE_CACHE_ALL, negative caching applies to all responses with the specified response code, and override any caching headers. By default, Cloud CDN will apply the following default TTLs to these status codes: HTTP 300 (Multiple Choice), 301, 308 (Permanent Redirects): 10m HTTP 404 (Not Found), 410 (Gone), 451 (Unavailable For Legal Reasons): 120s HTTP 405 (Method Not Found), 421 (Misdirected Request), 501 (Not Implemented): 60s. These defaults can be overridden in negative_caching_policy. + optional bool negative_caching = 336110005; + + // Sets a cache TTL for the specified HTTP status code. negative_caching must be enabled to configure negative_caching_policy. Omitting the policy and leaving negative_caching enabled will use Cloud CDN's default cache TTLs. Note that when specifying an explicit negative_caching_policy, you should take care to specify a cache TTL for all response codes that you wish to cache. Cloud CDN will not apply any default negative caching when a policy exists. + repeated BackendServiceCdnPolicyNegativeCachingPolicy negative_caching_policy = 155359996; + + // If true then Cloud CDN will combine multiple concurrent cache fill requests into a small number of requests to the origin. + optional bool request_coalescing = 532808276; + + // Serve existing content from the cache (if available) when revalidating content with the origin, or when an error is encountered when refreshing the cache. This setting defines the default "max-stale" duration for any cached responses that do not specify a max-stale directive. Stale responses that exceed the TTL configured here will not be served. The default limit (max-stale) is 86400s (1 day), which will allow stale content to be served up to this limit beyond the max-age (or s-max-age) of a cached response. The maximum allowed value is 604800 (1 week). Set this to zero (0) to disable serve-while-stale. + optional int32 serve_while_stale = 236682203; + + // Maximum number of seconds the response to a signed URL request will be considered fresh. After this time period, the response will be revalidated before being served. Defaults to 1hr (3600s). When serving responses to signed URL requests, Cloud CDN will internally behave as though all responses from this backend had a "Cache-Control: public, max-age=[TTL]" header, regardless of any existing Cache-Control header. The actual headers served in responses will not be altered. + optional int64 signed_url_cache_max_age_sec = 269374534; + + // [Output Only] Names of the keys for signing request URLs. + repeated string signed_url_key_names = 371848885; + +} + +// Bypass the cache when the specified request headers are present, e.g. Pragma or Authorization headers. Values are case insensitive. The presence of such a header overrides the cache_mode setting. +message BackendServiceCdnPolicyBypassCacheOnRequestHeader { + // The header field name to match on when bypassing cache. Values are case-insensitive. + optional string header_name = 110223613; + +} + +// Specify CDN TTLs for response error codes. +message BackendServiceCdnPolicyNegativeCachingPolicy { + // The HTTP status code to define a TTL against. Only HTTP status codes 300, 301, 302, 307, 308, 404, 405, 410, 421, 451 and 501 are can be specified as values, and you cannot specify a status code more than once. + optional int32 code = 3059181; + + // The TTL (in seconds) for which to cache responses with the corresponding status code. The maximum allowed value is 1800s (30 minutes), noting that infrequently accessed objects may be evicted from the cache before the defined TTL. + optional int32 ttl = 115180; + +} + +// Connection Tracking configuration for this BackendService. +message BackendServiceConnectionTrackingPolicy { + // Specifies connection persistence when backends are unhealthy. The default value is DEFAULT_FOR_PROTOCOL. If set to DEFAULT_FOR_PROTOCOL, the existing connections persist on unhealthy backends only for connection-oriented protocols (TCP and SCTP) and only if the Tracking Mode is PER_CONNECTION (default tracking mode) or the Session Affinity is configured for 5-tuple. They do not persist for UDP. If set to NEVER_PERSIST, after a backend becomes unhealthy, the existing connections on the unhealthy backend are never persisted on the unhealthy backend. They are always diverted to newly selected healthy backends (unless all backends are unhealthy). If set to ALWAYS_PERSIST, existing connections always persist on unhealthy backends regardless of protocol and session affinity. It is generally not recommended to use this mode overriding the default. For more details, see [Connection Persistence for Network Load Balancing](https://cloud.google.com/load-balancing/docs/network/networklb-backend-service#connection-persistence) and [Connection Persistence for Internal TCP/UDP Load Balancing](https://cloud.google.com/load-balancing/docs/internal#connection-persistence). + enum ConnectionPersistenceOnUnhealthyBackends { + // A value indicating that the enum field is not set. + UNDEFINED_CONNECTION_PERSISTENCE_ON_UNHEALTHY_BACKENDS = 0; + + ALWAYS_PERSIST = 38400900; + + DEFAULT_FOR_PROTOCOL = 145265356; + + NEVER_PERSIST = 138646241; + + } + + // Specifies the key used for connection tracking. There are two options: - PER_CONNECTION: This is the default mode. The Connection Tracking is performed as per the Connection Key (default Hash Method) for the specific protocol. - PER_SESSION: The Connection Tracking is performed as per the configured Session Affinity. It matches the configured Session Affinity. For more details, see [Tracking Mode for Network Load Balancing](https://cloud.google.com/load-balancing/docs/network/networklb-backend-service#tracking-mode) and [Tracking Mode for Internal TCP/UDP Load Balancing](https://cloud.google.com/load-balancing/docs/internal#tracking-mode). + enum TrackingMode { + // A value indicating that the enum field is not set. + UNDEFINED_TRACKING_MODE = 0; + + INVALID_TRACKING_MODE = 49234371; + + PER_CONNECTION = 85162848; + + PER_SESSION = 182099252; + + } + + // Specifies connection persistence when backends are unhealthy. The default value is DEFAULT_FOR_PROTOCOL. If set to DEFAULT_FOR_PROTOCOL, the existing connections persist on unhealthy backends only for connection-oriented protocols (TCP and SCTP) and only if the Tracking Mode is PER_CONNECTION (default tracking mode) or the Session Affinity is configured for 5-tuple. They do not persist for UDP. If set to NEVER_PERSIST, after a backend becomes unhealthy, the existing connections on the unhealthy backend are never persisted on the unhealthy backend. They are always diverted to newly selected healthy backends (unless all backends are unhealthy). If set to ALWAYS_PERSIST, existing connections always persist on unhealthy backends regardless of protocol and session affinity. It is generally not recommended to use this mode overriding the default. For more details, see [Connection Persistence for Network Load Balancing](https://cloud.google.com/load-balancing/docs/network/networklb-backend-service#connection-persistence) and [Connection Persistence for Internal TCP/UDP Load Balancing](https://cloud.google.com/load-balancing/docs/internal#connection-persistence). + // Check the ConnectionPersistenceOnUnhealthyBackends enum for the list of possible values. + optional string connection_persistence_on_unhealthy_backends = 152439033; + + // Enable Strong Session Affinity for Network Load Balancing. This option is not available publicly. + optional bool enable_strong_affinity = 24539924; + + // Specifies how long to keep a Connection Tracking entry while there is no matching traffic (in seconds). For Internal TCP/UDP Load Balancing: - The minimum (default) is 10 minutes and the maximum is 16 hours. - It can be set only if Connection Tracking is less than 5-tuple (i.e. Session Affinity is CLIENT_IP_NO_DESTINATION, CLIENT_IP or CLIENT_IP_PROTO, and Tracking Mode is PER_SESSION). For Network Load Balancer the default is 60 seconds. This option is not available publicly. + optional int32 idle_timeout_sec = 24977544; + + // Specifies the key used for connection tracking. There are two options: - PER_CONNECTION: This is the default mode. The Connection Tracking is performed as per the Connection Key (default Hash Method) for the specific protocol. - PER_SESSION: The Connection Tracking is performed as per the configured Session Affinity. It matches the configured Session Affinity. For more details, see [Tracking Mode for Network Load Balancing](https://cloud.google.com/load-balancing/docs/network/networklb-backend-service#tracking-mode) and [Tracking Mode for Internal TCP/UDP Load Balancing](https://cloud.google.com/load-balancing/docs/internal#tracking-mode). + // Check the TrackingMode enum for the list of possible values. + optional string tracking_mode = 127757867; + +} + +// For load balancers that have configurable failover: [Internal TCP/UDP Load Balancing](https://cloud.google.com/load-balancing/docs/internal/failover-overview) and [external TCP/UDP Load Balancing](https://cloud.google.com/load-balancing/docs/network/networklb-failover-overview). On failover or failback, this field indicates whether connection draining will be honored. Google Cloud has a fixed connection draining timeout of 10 minutes. A setting of true terminates existing TCP connections to the active pool during failover and failback, immediately draining traffic. A setting of false allows existing TCP connections to persist, even on VMs no longer in the active pool, for up to the duration of the connection draining timeout (10 minutes). +message BackendServiceFailoverPolicy { + // This can be set to true only if the protocol is TCP. The default is false. + optional bool disable_connection_drain_on_failover = 182150753; + + // If set to true, connections to the load balancer are dropped when all primary and all backup backend VMs are unhealthy.If set to false, connections are distributed among all primary VMs when all primary and all backup backend VMs are unhealthy. For load balancers that have configurable failover: [Internal TCP/UDP Load Balancing](https://cloud.google.com/load-balancing/docs/internal/failover-overview) and [external TCP/UDP Load Balancing](https://cloud.google.com/load-balancing/docs/network/networklb-failover-overview). The default is false. + optional bool drop_traffic_if_unhealthy = 112289428; + + // The value of the field must be in the range [0, 1]. If the value is 0, the load balancer performs a failover when the number of healthy primary VMs equals zero. For all other values, the load balancer performs a failover when the total number of healthy primary VMs is less than this ratio. For load balancers that have configurable failover: [Internal TCP/UDP Load Balancing](https://cloud.google.com/load-balancing/docs/internal/failover-overview) and [external TCP/UDP Load Balancing](https://cloud.google.com/load-balancing/docs/network/networklb-failover-overview). + optional float failover_ratio = 212667006; + +} + +// +message BackendServiceGroupHealth { + // Metadata defined as annotations on the network endpoint group. + map annotations = 112032548; + + // Health state of the backend instances or endpoints in requested instance or network endpoint group, determined based on configured health checks. + repeated HealthStatus health_status = 380545845; + + // [Output Only] Type of resource. Always compute#backendServiceGroupHealth for the health of backend services. + optional string kind = 3292052; + +} + +// Identity-Aware Proxy +message BackendServiceIAP { + // Whether the serving infrastructure will authenticate and authorize all incoming requests. If true, the oauth2ClientId and oauth2ClientSecret fields must be non-empty. + optional bool enabled = 1018689; + + // OAuth2 client ID to use for the authentication flow. + optional string oauth2_client_id = 314017611; + + // OAuth2 client secret to use for the authentication flow. For security reasons, this value cannot be retrieved via the API. Instead, the SHA-256 hash of the value is returned in the oauth2ClientSecretSha256 field. @InputOnly + optional string oauth2_client_secret = 50999520; + + // [Output Only] SHA256 hash value for the field oauth2_client_secret above. + optional string oauth2_client_secret_sha256 = 112903782; + +} + +// Contains a list of BackendService resources. +message BackendServiceList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of BackendService resources. + repeated BackendService items = 100526016; + + // [Output Only] Type of resource. Always compute#backendServiceList for lists of backend services. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Container for either a built-in LB policy supported by gRPC or Envoy or a custom one implemented by the end user. +message BackendServiceLocalityLoadBalancingPolicyConfig { + optional BackendServiceLocalityLoadBalancingPolicyConfigCustomPolicy custom_policy = 4818368; + + optional BackendServiceLocalityLoadBalancingPolicyConfigPolicy policy = 91071794; + +} + +// The configuration for a custom policy implemented by the user and deployed with the client. +message BackendServiceLocalityLoadBalancingPolicyConfigCustomPolicy { + // An optional, arbitrary JSON object with configuration data, understood by a locally installed custom policy implementation. + optional string data = 3076010; + + // Identifies the custom policy. The value should match the name of a custom implementation registered on the gRPC clients. It should follow protocol buffer message naming conventions and include the full path (for example, myorg.CustomLbPolicy). The maximum length is 256 characters. Do not specify the same custom policy more than once for a backend. If you do, the configuration is rejected. For an example of how to use this field, see Use a custom policy. + optional string name = 3373707; + +} + +// The configuration for a built-in load balancing policy. +message BackendServiceLocalityLoadBalancingPolicyConfigPolicy { + // The name of a locality load-balancing policy. Valid values include ROUND_ROBIN and, for Java clients, LEAST_REQUEST. For information about these values, see the description of localityLbPolicy. Do not specify the same policy more than once for a backend. If you do, the configuration is rejected. + enum Name { + // A value indicating that the enum field is not set. + UNDEFINED_NAME = 0; + + INVALID_LB_POLICY = 323318707; + + // An O(1) algorithm which selects two random healthy hosts and picks the host which has fewer active requests. + LEAST_REQUEST = 46604921; + + // This algorithm implements consistent hashing to backends. Maglev can be used as a drop in replacement for the ring hash load balancer. Maglev is not as stable as ring hash but has faster table lookup build times and host selection times. For more information about Maglev, see https://ai.google/research/pubs/pub44824 + MAGLEV = 119180266; + + // Backend host is selected based on the client connection metadata, i.e., connections are opened to the same address as the destination address of the incoming connection before the connection was redirected to the load balancer. + ORIGINAL_DESTINATION = 166297216; + + // The load balancer selects a random healthy host. + RANDOM = 262527171; + + // The ring/modulo hash load balancer implements consistent hashing to backends. The algorithm has the property that the addition/removal of a host from a set of N hosts only affects 1/N of the requests. + RING_HASH = 432795069; + + // This is a simple policy in which each healthy backend is selected in round robin order. This is the default. + ROUND_ROBIN = 153895801; + + // Per-instance weighted Load Balancing via health check reported weights. If set, the Backend Service must configure a non legacy HTTP-based Health Check, and health check replies are expected to contain non-standard HTTP response header field X-Load-Balancing-Endpoint-Weight to specify the per-instance weights. If set, Load Balancing is weighted based on the per-instance weights reported in the last processed health check replies, as long as every instance either reported a valid weight or had UNAVAILABLE_WEIGHT. Otherwise, Load Balancing remains equal-weight. This option is only supported in Network Load Balancing. + WEIGHTED_MAGLEV = 254930962; + + } + + // The name of a locality load-balancing policy. Valid values include ROUND_ROBIN and, for Java clients, LEAST_REQUEST. For information about these values, see the description of localityLbPolicy. Do not specify the same policy more than once for a backend. If you do, the configuration is rejected. + // Check the Name enum for the list of possible values. + optional string name = 3373707; + +} + +// The available logging options for the load balancer traffic served by this backend service. +message BackendServiceLogConfig { + // This field can only be specified if logging is enabled for this backend service. Configures whether all, none or a subset of optional fields should be added to the reported logs. One of [INCLUDE_ALL_OPTIONAL, EXCLUDE_ALL_OPTIONAL, CUSTOM]. Default is EXCLUDE_ALL_OPTIONAL. + enum OptionalMode { + // A value indicating that the enum field is not set. + UNDEFINED_OPTIONAL_MODE = 0; + + // A subset of optional fields. + CUSTOM = 388595569; + + // None optional fields. + EXCLUDE_ALL_OPTIONAL = 168636099; + + // All optional fields. + INCLUDE_ALL_OPTIONAL = 535606965; + + } + + // Denotes whether to enable logging for the load balancer traffic served by this backend service. The default value is false. + optional bool enable = 311764355; + + // This field can only be specified if logging is enabled for this backend service and "logConfig.optionalMode" was set to CUSTOM. Contains a list of optional fields you want to include in the logs. For example: serverInstance, serverGkeDetails.cluster, serverGkeDetails.pod.podNamespace + repeated string optional_fields = 528589944; + + // This field can only be specified if logging is enabled for this backend service. Configures whether all, none or a subset of optional fields should be added to the reported logs. One of [INCLUDE_ALL_OPTIONAL, EXCLUDE_ALL_OPTIONAL, CUSTOM]. Default is EXCLUDE_ALL_OPTIONAL. + // Check the OptionalMode enum for the list of possible values. + optional string optional_mode = 128697122; + + // This field can only be specified if logging is enabled for this backend service. The value of the field must be in [0, 1]. This configures the sampling rate of requests to the load balancer where 1.0 means all logged requests are reported and 0.0 means no logged requests are reported. The default value is 1.0. + optional float sample_rate = 153193045; + +} + +// +message BackendServiceReference { + optional string backend_service = 306946058; + +} + +// +message BackendServicesScopedList { + // A list of BackendServices contained in this scope. + repeated BackendService backend_services = 388522409; + + // Informational warning which replaces the list of backend services when the list is empty. + optional Warning warning = 50704284; + +} + +// +message BfdPacket { + // The diagnostic code specifies the local system's reason for the last change in session state. This allows remote systems to determine the reason that the previous session failed, for example. These diagnostic codes are specified in section 4.1 of RFC5880 + enum Diagnostic { + // A value indicating that the enum field is not set. + UNDEFINED_DIAGNOSTIC = 0; + + ADMINISTRATIVELY_DOWN = 121685798; + + CONCATENATED_PATH_DOWN = 26186892; + + CONTROL_DETECTION_TIME_EXPIRED = 135478383; + + DIAGNOSTIC_UNSPECIFIED = 58720895; + + ECHO_FUNCTION_FAILED = 220687466; + + FORWARDING_PLANE_RESET = 19715882; + + NEIGHBOR_SIGNALED_SESSION_DOWN = 374226742; + + NO_DIAGNOSTIC = 222503141; + + PATH_DOWN = 290605180; + + REVERSE_CONCATENATED_PATH_DOWN = 479337129; + + } + + // The current BFD session state as seen by the transmitting system. These states are specified in section 4.1 of RFC5880 + enum State { + // A value indicating that the enum field is not set. + UNDEFINED_STATE = 0; + + ADMIN_DOWN = 128544690; + + DOWN = 2104482; + + INIT = 2252048; + + STATE_UNSPECIFIED = 470755401; + + UP = 2715; + + } + + // The Authentication Present bit of the BFD packet. This is specified in section 4.1 of RFC5880 + optional bool authentication_present = 105974260; + + // The Control Plane Independent bit of the BFD packet. This is specified in section 4.1 of RFC5880 + optional bool control_plane_independent = 62363573; + + // The demand bit of the BFD packet. This is specified in section 4.1 of RFC5880 + optional bool demand = 275180107; + + // The diagnostic code specifies the local system's reason for the last change in session state. This allows remote systems to determine the reason that the previous session failed, for example. These diagnostic codes are specified in section 4.1 of RFC5880 + // Check the Diagnostic enum for the list of possible values. + optional string diagnostic = 62708647; + + // The Final bit of the BFD packet. This is specified in section 4.1 of RFC5880 + optional bool final = 97436022; + + // The length of the BFD Control packet in bytes. This is specified in section 4.1 of RFC5880 + optional uint32 length = 504249062; + + // The Required Min Echo RX Interval value in the BFD packet. This is specified in section 4.1 of RFC5880 + optional uint32 min_echo_rx_interval_ms = 97286868; + + // The Required Min RX Interval value in the BFD packet. This is specified in section 4.1 of RFC5880 + optional uint32 min_rx_interval_ms = 463399028; + + // The Desired Min TX Interval value in the BFD packet. This is specified in section 4.1 of RFC5880 + optional uint32 min_tx_interval_ms = 526023602; + + // The detection time multiplier of the BFD packet. This is specified in section 4.1 of RFC5880 + optional uint32 multiplier = 191331777; + + // The multipoint bit of the BFD packet. This is specified in section 4.1 of RFC5880 + optional bool multipoint = 191421431; + + // The My Discriminator value in the BFD packet. This is specified in section 4.1 of RFC5880 + optional uint32 my_discriminator = 76663113; + + // The Poll bit of the BFD packet. This is specified in section 4.1 of RFC5880 + optional bool poll = 3446719; + + // The current BFD session state as seen by the transmitting system. These states are specified in section 4.1 of RFC5880 + // Check the State enum for the list of possible values. + optional string state = 109757585; + + // The version number of the BFD protocol, as specified in section 4.1 of RFC5880. + optional uint32 version = 351608024; + + // The Your Discriminator value in the BFD packet. This is specified in section 4.1 of RFC5880 + optional uint32 your_discriminator = 515634064; + +} + +// Next free: 15 +message BfdStatus { + // The BFD session initialization mode for this BGP peer. If set to ACTIVE, the Cloud Router will initiate the BFD session for this BGP peer. If set to PASSIVE, the Cloud Router will wait for the peer router to initiate the BFD session for this BGP peer. If set to DISABLED, BFD is disabled for this BGP peer. + enum BfdSessionInitializationMode { + // A value indicating that the enum field is not set. + UNDEFINED_BFD_SESSION_INITIALIZATION_MODE = 0; + + ACTIVE = 314733318; + + DISABLED = 516696700; + + PASSIVE = 462813959; + + } + + // The diagnostic code specifies the local system's reason for the last change in session state. This allows remote systems to determine the reason that the previous session failed, for example. These diagnostic codes are specified in section 4.1 of RFC5880 + enum LocalDiagnostic { + // A value indicating that the enum field is not set. + UNDEFINED_LOCAL_DIAGNOSTIC = 0; + + ADMINISTRATIVELY_DOWN = 121685798; + + CONCATENATED_PATH_DOWN = 26186892; + + CONTROL_DETECTION_TIME_EXPIRED = 135478383; + + DIAGNOSTIC_UNSPECIFIED = 58720895; + + ECHO_FUNCTION_FAILED = 220687466; + + FORWARDING_PLANE_RESET = 19715882; + + NEIGHBOR_SIGNALED_SESSION_DOWN = 374226742; + + NO_DIAGNOSTIC = 222503141; + + PATH_DOWN = 290605180; + + REVERSE_CONCATENATED_PATH_DOWN = 479337129; + + } + + // The current BFD session state as seen by the transmitting system. These states are specified in section 4.1 of RFC5880 + enum LocalState { + // A value indicating that the enum field is not set. + UNDEFINED_LOCAL_STATE = 0; + + ADMIN_DOWN = 128544690; + + DOWN = 2104482; + + INIT = 2252048; + + STATE_UNSPECIFIED = 470755401; + + UP = 2715; + + } + + // The BFD session initialization mode for this BGP peer. If set to ACTIVE, the Cloud Router will initiate the BFD session for this BGP peer. If set to PASSIVE, the Cloud Router will wait for the peer router to initiate the BFD session for this BGP peer. If set to DISABLED, BFD is disabled for this BGP peer. + // Check the BfdSessionInitializationMode enum for the list of possible values. + optional string bfd_session_initialization_mode = 218156954; + + // Unix timestamp of the most recent config update. + optional int64 config_update_timestamp_micros = 457195569; + + // Control packet counts for the current BFD session. + optional BfdStatusPacketCounts control_packet_counts = 132573561; + + // Inter-packet time interval statistics for control packets. + repeated PacketIntervals control_packet_intervals = 500806649; + + // The diagnostic code specifies the local system's reason for the last change in session state. This allows remote systems to determine the reason that the previous session failed, for example. These diagnostic codes are specified in section 4.1 of RFC5880 + // Check the LocalDiagnostic enum for the list of possible values. + optional string local_diagnostic = 463737083; + + // The current BFD session state as seen by the transmitting system. These states are specified in section 4.1 of RFC5880 + // Check the LocalState enum for the list of possible values. + optional string local_state = 149195453; + + // Negotiated transmit interval for control packets. + optional uint32 negotiated_local_control_tx_interval_ms = 21768340; + + // The most recent Rx control packet for this BFD session. + optional BfdPacket rx_packet = 505069729; + + // The most recent Tx control packet for this BFD session. + optional BfdPacket tx_packet = 111386275; + + // Session uptime in milliseconds. Value will be 0 if session is not up. + optional int64 uptime_ms = 125398365; + +} + +// +message BfdStatusPacketCounts { + // Number of packets received since the beginning of the current BFD session. + optional uint32 num_rx = 39375263; + + // Number of packets received that were rejected because of errors since the beginning of the current BFD session. + optional uint32 num_rx_rejected = 281007902; + + // Number of packets received that were successfully processed since the beginning of the current BFD session. + optional uint32 num_rx_successful = 455361850; + + // Number of packets transmitted since the beginning of the current BFD session. + optional uint32 num_tx = 39375325; + +} + +// Associates `members`, or principals, with a `role`. +message Binding { + // This is deprecated and has no effect. Do not use. + optional string binding_id = 441088277; + + // The condition that is associated with this binding. If the condition evaluates to `true`, then this binding applies to the current request. If the condition evaluates to `false`, then this binding does not apply to the current request. However, a different role binding might grant the same role to one or more of the principals in this binding. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). + optional Expr condition = 212430107; + + // Specifies the principals requesting access for a Google Cloud resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. Does not include identities that come from external identity providers (IdPs) through identity federation. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@example.com` . * `serviceAccount:{emailid}`: An email address that represents a Google service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]`: An identifier for a [Kubernetes service account](https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts). For example, `my-project.svc.id.goog[my-namespace/my-kubernetes-sa]`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: The G Suite domain (primary) that represents all the users of that domain. For example, `google.com` or `example.com`. * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a user that has been recently deleted. For example, `alice@example.com?uid=123456789012345678901`. If the user is recovered, this value reverts to `user:{emailid}` and the recovered user retains the role in the binding. * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a service account that has been recently deleted. For example, `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. If the service account is undeleted, this value reverts to `serviceAccount:{emailid}` and the undeleted service account retains the role in the binding. * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a Google group that has been recently deleted. For example, `admins@example.com?uid=123456789012345678901`. If the group is recovered, this value reverts to `group:{emailid}` and the recovered group retains the role in the binding. + repeated string members = 412010777; + + // Role that is assigned to the list of `members`, or principals. For example, `roles/viewer`, `roles/editor`, or `roles/owner`. + optional string role = 3506294; + +} + +// A request message for Instances.BulkInsert. See the method description for details. +message BulkInsertInstanceRequest { + // The body resource for this request + BulkInsertInstanceResource bulk_insert_instance_resource_resource = 41427278 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A transient resource used in compute.instances.bulkInsert and compute.regionInstances.bulkInsert . This resource is not persisted anywhere, it is used only for processing the requests. +message BulkInsertInstanceResource { + // The maximum number of instances to create. + optional int64 count = 94851343; + + // The instance properties defining the VM instances to be created. Required if sourceInstanceTemplate is not provided. + optional InstanceProperties instance_properties = 215355165; + + // Policy for chosing target zone. For more information, see Create VMs in bulk . + optional LocationPolicy location_policy = 465689852; + + // The minimum number of instances to create. If no min_count is specified then count is used as the default value. If min_count instances cannot be created, then no instances will be created and instances already created will be deleted. + optional int64 min_count = 523228386; + + // The string pattern used for the names of the VMs. Either name_pattern or per_instance_properties must be set. The pattern must contain one continuous sequence of placeholder hash characters (#) with each character corresponding to one digit of the generated instance name. Example: a name_pattern of inst-#### generates instance names such as inst-0001 and inst-0002. If existing instances in the same project and zone have names that match the name pattern then the generated instance numbers start after the biggest existing number. For example, if there exists an instance with name inst-0050, then instance names generated using the pattern inst-#### begin with inst-0051. The name pattern placeholder #...# can contain up to 18 characters. + optional string name_pattern = 413815260; + + // Per-instance properties to be set on individual instances. Keys of this map specify requested instance names. Can be empty if name_pattern is used. + map per_instance_properties = 108502267; + + // Specifies the instance template from which to create instances. You may combine sourceInstanceTemplate with instanceProperties to override specific values from an existing instance template. Bulk API follows the semantics of JSON Merge Patch described by RFC 7396. It can be a full or partial URL. For example, the following are all valid URLs to an instance template: - https://www.googleapis.com/compute/v1/projects/project /global/instanceTemplates/instanceTemplate - projects/project/global/instanceTemplates/instanceTemplate - global/instanceTemplates/instanceTemplate This field is optional. + optional string source_instance_template = 332423616; + +} + +// Per-instance properties to be set on individual instances. To be extended in the future. +message BulkInsertInstanceResourcePerInstanceProperties { + // This field is only temporary. It will be removed. Do not use it. + optional string name = 3373707; + +} + +// A request message for RegionInstances.BulkInsert. See the method description for details. +message BulkInsertRegionInstanceRequest { + // The body resource for this request + BulkInsertInstanceResource bulk_insert_instance_resource_resource = 41427278 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// +message CacheInvalidationRule { + // If set, this invalidation rule will only apply to requests with a Host header matching host. + optional string host = 3208616; + + optional string path = 3433509; + +} + +// Message containing what to include in the cache key for a request for Cloud CDN. +message CacheKeyPolicy { + // If true, requests to different hosts will be cached separately. + optional bool include_host = 486867679; + + // Allows HTTP request headers (by name) to be used in the cache key. + repeated string include_http_headers = 2489606; + + // Allows HTTP cookies (by name) to be used in the cache key. The name=value pair will be used in the cache key Cloud CDN generates. + repeated string include_named_cookies = 87316530; + + // If true, http and https requests will be cached separately. + optional bool include_protocol = 303507535; + + // If true, include query string parameters in the cache key according to query_string_whitelist and query_string_blacklist. If neither is set, the entire query string will be included. If false, the query string will be excluded from the cache key entirely. + optional bool include_query_string = 474036639; + + // Names of query string parameters to exclude in cache keys. All other parameters will be included. Either specify query_string_whitelist or query_string_blacklist, not both. '&' and '=' will be percent encoded and not treated as delimiters. + repeated string query_string_blacklist = 354964742; + + // Names of query string parameters to include in cache keys. All other parameters will be excluded. Either specify query_string_whitelist or query_string_blacklist, not both. '&' and '=' will be percent encoded and not treated as delimiters. + repeated string query_string_whitelist = 52456496; + +} + +// Settings controlling the volume of requests, connections and retries to this backend service. +message CircuitBreakers { + // The maximum number of connections to the backend service. If not specified, there is no limit. Not supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. + optional int32 max_connections = 110652154; + + // The maximum number of pending requests allowed to the backend service. If not specified, there is no limit. Not supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. + optional int32 max_pending_requests = 375558887; + + // The maximum number of parallel requests that allowed to the backend service. If not specified, there is no limit. + optional int32 max_requests = 28097599; + + // Maximum requests for a single connection to the backend service. This parameter is respected by both the HTTP/1.1 and HTTP/2 implementations. If not specified, there is no limit. Setting this parameter to 1 will effectively disable keep alive. Not supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. + optional int32 max_requests_per_connection = 361630528; + + // The maximum number of parallel retries allowed to the backend cluster. If not specified, the default is 1. Not supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. + optional int32 max_retries = 55546219; + +} + +// A request message for FirewallPolicies.CloneRules. See the method description for details. +message CloneRulesFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The firewall policy from which to copy rules. + optional string source_firewall_policy = 25013549; + +} + +// A request message for NetworkFirewallPolicies.CloneRules. See the method description for details. +message CloneRulesNetworkFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The firewall policy from which to copy rules. + optional string source_firewall_policy = 25013549; + +} + +// A request message for RegionNetworkFirewallPolicies.CloneRules. See the method description for details. +message CloneRulesRegionNetworkFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The firewall policy from which to copy rules. + optional string source_firewall_policy = 25013549; + +} + +// Represents a regional Commitment resource. Creating a commitment resource means that you are purchasing a committed use contract with an explicit start and end time. You can create commitments based on vCPUs and memory usage and receive discounted rates. For full details, read Signing Up for Committed Use Discounts. +message Commitment { + // The category of the commitment. Category MACHINE specifies commitments composed of machine resources such as VCPU or MEMORY, listed in resources. Category LICENSE specifies commitments composed of software licenses, listed in licenseResources. Note that only MACHINE commitments should have a Type specified. + enum Category { + // A value indicating that the enum field is not set. + UNDEFINED_CATEGORY = 0; + + CATEGORY_UNSPECIFIED = 509189462; + + LICENSE = 347869217; + + MACHINE = 469553191; + + } + + // The plan for this commitment, which determines duration and discount rate. The currently supported plans are TWELVE_MONTH (1 year), and THIRTY_SIX_MONTH (3 years). + enum Plan { + // A value indicating that the enum field is not set. + UNDEFINED_PLAN = 0; + + INVALID = 530283991; + + THIRTY_SIX_MONTH = 266295942; + + TWELVE_MONTH = 173083962; + + } + + // [Output Only] Status of the commitment with regards to eventual expiration (each commitment has an end date defined). One of the following values: NOT_YET_ACTIVE, ACTIVE, EXPIRED. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + ACTIVE = 314733318; + + // Deprecate CANCELED status. Will use separate status to differentiate cancel by mergeCud or manual cancellation. + CANCELLED = 41957681; + + CREATING = 455564985; + + EXPIRED = 482489093; + + NOT_YET_ACTIVE = 20607337; + + } + + // The type of commitment, which affects the discount rate and the eligible resources. Type MEMORY_OPTIMIZED specifies a commitment that will only apply to memory optimized machines. Type ACCELERATOR_OPTIMIZED specifies a commitment that will only apply to accelerator optimized machines. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + ACCELERATOR_OPTIMIZED = 280848403; + + COMPUTE_OPTIMIZED = 158349023; + + COMPUTE_OPTIMIZED_C2D = 383246453; + + COMPUTE_OPTIMIZED_C3 = 428004784; + + GENERAL_PURPOSE = 299793543; + + GENERAL_PURPOSE_E2 = 301911877; + + GENERAL_PURPOSE_N2 = 301912156; + + GENERAL_PURPOSE_N2D = 232471400; + + GENERAL_PURPOSE_T2D = 232477166; + + MEMORY_OPTIMIZED = 281753417; + + MEMORY_OPTIMIZED_M3 = 276301372; + + TYPE_UNSPECIFIED = 437714322; + + } + + // Specifies whether to enable automatic renewal for the commitment. The default value is false if not specified. The field can be updated until the day of the commitment expiration at 12:00am PST. If the field is set to true, the commitment will be automatically renewed for either one or three years according to the terms of the existing commitment. + optional bool auto_renew = 495520765; + + // The category of the commitment. Category MACHINE specifies commitments composed of machine resources such as VCPU or MEMORY, listed in resources. Category LICENSE specifies commitments composed of software licenses, listed in licenseResources. Note that only MACHINE commitments should have a Type specified. + // Check the Category enum for the list of possible values. + optional string category = 50511102; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] Commitment end time in RFC3339 text format. + optional string end_timestamp = 468096690; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#commitment for commitments. + optional string kind = 3292052; + + // The license specification required as part of a license commitment. + optional LicenseResourceCommitment license_resource = 437955148; + + // List of source commitments to be merged into a new commitment. + repeated string merge_source_commitments = 188093761; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // The plan for this commitment, which determines duration and discount rate. The currently supported plans are TWELVE_MONTH (1 year), and THIRTY_SIX_MONTH (3 years). + // Check the Plan enum for the list of possible values. + optional string plan = 3443497; + + // [Output Only] URL of the region where this commitment may be used. + optional string region = 138946292; + + // List of reservations in this commitment. + repeated Reservation reservations = 399717927; + + // A list of commitment amounts for particular resources. Note that VCPU and MEMORY resource commitments must occur together. + repeated ResourceCommitment resources = 164412965; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // Source commitment to be splitted into a new commitment. + optional string split_source_commitment = 402611156; + + // [Output Only] Commitment start time in RFC3339 text format. + optional string start_timestamp = 83645817; + + // [Output Only] Status of the commitment with regards to eventual expiration (each commitment has an end date defined). One of the following values: NOT_YET_ACTIVE, ACTIVE, EXPIRED. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // [Output Only] An optional, human-readable explanation of the status. + optional string status_message = 297428154; + + // The type of commitment, which affects the discount rate and the eligible resources. Type MEMORY_OPTIMIZED specifies a commitment that will only apply to memory optimized machines. Type ACCELERATOR_OPTIMIZED specifies a commitment that will only apply to accelerator optimized machines. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// +message CommitmentAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of CommitmentsScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#commitmentAggregatedList for aggregated lists of commitments. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of Commitment resources. +message CommitmentList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Commitment resources. + repeated Commitment items = 100526016; + + // [Output Only] Type of resource. Always compute#commitmentList for lists of commitments. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message CommitmentsScopedList { + // [Output Only] A list of commitments contained in this scope. + repeated Commitment commitments = 450664446; + + // [Output Only] Informational warning which replaces the list of commitments when the list is empty. + optional Warning warning = 50704284; + +} + +// This is deprecated and has no effect. Do not use. +message Condition { + // This is deprecated and has no effect. Do not use. + // Additional supported values which may be not listed in the enum directly due to technical reasons: + // NO_ATTR + enum Iam { + // A value indicating that the enum field is not set. + UNDEFINED_IAM = 0; + + // This is deprecated and has no effect. Do not use. + APPROVER = 357258949; + + // This is deprecated and has no effect. Do not use. + ATTRIBUTION = 232465503; + + // This is deprecated and has no effect. Do not use. + AUTHORITY = 504108835; + + // This is deprecated and has no effect. Do not use. + CREDENTIALS_TYPE = 348222141; + + // This is deprecated and has no effect. Do not use. + CREDS_ASSERTION = 332343272; + + // This is deprecated and has no effect. Do not use. + JUSTIFICATION_TYPE = 206147719; + + // This is deprecated and has no effect. Do not use. + SECURITY_REALM = 526269616; + + } + + // This is deprecated and has no effect. Do not use. + enum Op { + // A value indicating that the enum field is not set. + UNDEFINED_OP = 0; + + // This is deprecated and has no effect. Do not use. + DISCHARGED = 266338274; + + // This is deprecated and has no effect. Do not use. + EQUALS = 442201023; + + // This is deprecated and has no effect. Do not use. + IN = 2341; + + // This is deprecated and has no effect. Do not use. + NOT_EQUALS = 19718859; + + // This is deprecated and has no effect. Do not use. + NOT_IN = 161144369; + + // This is deprecated and has no effect. Do not use. + NO_OP = 74481951; + + } + + // This is deprecated and has no effect. Do not use. + // Additional supported values which may be not listed in the enum directly due to technical reasons: + // NO_ATTR + enum Sys { + // A value indicating that the enum field is not set. + UNDEFINED_SYS = 0; + + // This is deprecated and has no effect. Do not use. + IP = 2343; + + // This is deprecated and has no effect. Do not use. + NAME = 2388619; + + // This is deprecated and has no effect. Do not use. + REGION = 266017524; + + // This is deprecated and has no effect. Do not use. + SERVICE = 17781397; + + } + + // This is deprecated and has no effect. Do not use. + // Check the Iam enum for the list of possible values. + optional string iam = 104021; + + // This is deprecated and has no effect. Do not use. + // Check the Op enum for the list of possible values. + optional string op = 3553; + + // This is deprecated and has no effect. Do not use. + optional string svc = 114272; + + // This is deprecated and has no effect. Do not use. + // Check the Sys enum for the list of possible values. + optional string sys = 114381; + + // This is deprecated and has no effect. Do not use. + repeated string values = 249928994; + +} + +// A set of Confidential Instance options. +message ConfidentialInstanceConfig { + // Defines whether the instance should have confidential compute enabled. + optional bool enable_confidential_compute = 102135228; + +} + +// Message containing connection draining configuration. +message ConnectionDraining { + // Configures a duration timeout for existing requests on a removed backend instance. For supported load balancers and protocols, as described in Enabling connection draining. + optional int32 draining_timeout_sec = 225127070; + +} + +// This message defines settings for a consistent hash style load balancer. +message ConsistentHashLoadBalancerSettings { + // Hash is based on HTTP Cookie. This field describes a HTTP cookie that will be used as the hash key for the consistent hash load balancer. If the cookie is not present, it will be generated. This field is applicable if the sessionAffinity is set to HTTP_COOKIE. Not supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. + optional ConsistentHashLoadBalancerSettingsHttpCookie http_cookie = 6673915; + + // The hash based on the value of the specified header field. This field is applicable if the sessionAffinity is set to HEADER_FIELD. + optional string http_header_name = 234798022; + + // The minimum number of virtual nodes to use for the hash ring. Defaults to 1024. Larger ring sizes result in more granular load distributions. If the number of hosts in the load balancing pool is larger than the ring size, each host will be assigned a single virtual node. + optional int64 minimum_ring_size = 234380735; + +} + +// The information about the HTTP Cookie on which the hash function is based for load balancing policies that use a consistent hash. +message ConsistentHashLoadBalancerSettingsHttpCookie { + // Name of the cookie. + optional string name = 3373707; + + // Path to set for the cookie. + optional string path = 3433509; + + // Lifetime of the cookie. + optional Duration ttl = 115180; + +} + +// The specification for allowing client-side cross-origin requests. For more information about the W3C recommendation for cross-origin resource sharing (CORS), see Fetch API Living Standard. +message CorsPolicy { + // In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This field translates to the Access-Control-Allow-Credentials header. Default is false. + optional bool allow_credentials = 481263366; + + // Specifies the content for the Access-Control-Allow-Headers header. + repeated string allow_headers = 45179024; + + // Specifies the content for the Access-Control-Allow-Methods header. + repeated string allow_methods = 205405372; + + // Specifies a regular expression that matches allowed origins. For more information about the regular expression syntax, see Syntax. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED. + repeated string allow_origin_regexes = 215385810; + + // Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. + repeated string allow_origins = 194914071; + + // If true, the setting specifies the CORS policy is disabled. The default value of false, which indicates that the CORS policy is in effect. + optional bool disabled = 270940796; + + // Specifies the content for the Access-Control-Expose-Headers header. + repeated string expose_headers = 247604747; + + // Specifies how long results of a preflight request can be cached in seconds. This field translates to the Access-Control-Max-Age header. + optional int32 max_age = 307559332; + +} + +// A request message for InstanceGroupManagers.CreateInstances. See the method description for details. +message CreateInstancesInstanceGroupManagerRequest { + // The name of the managed instance group. It should conform to RFC1035. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstanceGroupManagersCreateInstancesRequest instance_group_managers_create_instances_request_resource = 24558867 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where the managed instance group is located. It should conform to RFC1035. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for RegionInstanceGroupManagers.CreateInstances. See the method description for details. +message CreateInstancesRegionInstanceGroupManagerRequest { + // The name of the managed instance group. It should conform to RFC1035. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The name of the region where the managed instance group is located. It should conform to RFC1035. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionInstanceGroupManagersCreateInstancesRequest region_instance_group_managers_create_instances_request_resource = 359014280 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Disks.CreateSnapshot. See the method description for details. +message CreateSnapshotDiskRequest { + // Name of the persistent disk to snapshot. + string disk = 3083677 [(google.api.field_behavior) = REQUIRED]; + + // [Input Only] Whether to attempt an application consistent snapshot by informing the OS to prepare for the snapshot process. + optional bool guest_flush = 385550813; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + Snapshot snapshot_resource = 481319977 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for RegionDisks.CreateSnapshot. See the method description for details. +message CreateSnapshotRegionDiskRequest { + // Name of the regional persistent disk to snapshot. + string disk = 3083677 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + Snapshot snapshot_resource = 481319977 [(google.api.field_behavior) = REQUIRED]; + +} + +// +message CustomerEncryptionKey { + // The name of the encryption key that is stored in Google Cloud KMS. For example: "kmsKeyName": "projects/kms_project_id/locations/region/keyRings/ key_region/cryptoKeys/key + optional string kms_key_name = 484373913; + + // The service account being used for the encryption request for the given KMS key. If absent, the Compute Engine default service account is used. For example: "kmsKeyServiceAccount": "name@project_id.iam.gserviceaccount.com/ + optional string kms_key_service_account = 209986261; + + // Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 to either encrypt or decrypt this resource. You can provide either the rawKey or the rsaEncryptedKey. For example: "rawKey": "SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=" + optional string raw_key = 449196488; + + // Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied encryption key to either encrypt or decrypt this resource. You can provide either the rawKey or the rsaEncryptedKey. For example: "rsaEncryptedKey": "ieCx/NcW06PcT7Ep1X6LUTc/hLvUDYyzSZPPVCVPTVEohpeHASqC8uw5TzyO9U+Fka9JFH z0mBibXUInrC/jEk014kCK/NPjYgEMOyssZ4ZINPKxlUh2zn1bV+MCaTICrdmuSBTWlUUiFoD D6PYznLwh8ZNdaheCeZ8ewEXgFQ8V+sDroLaN3Xs3MDTXQEMMoNUXMCZEIpg9Vtp9x2oe==" The key must meet the following requirements before you can provide it to Compute Engine: 1. The key is wrapped using a RSA public key certificate provided by Google. 2. After being wrapped, the key must be encoded in RFC 4648 base64 encoding. Gets the RSA public key certificate provided by Google at: https://cloud-certs.storage.googleapis.com/google-cloud-csek-ingress.pem + optional string rsa_encrypted_key = 335487397; + + // [Output only] The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this resource. + optional string sha256 = 170112551; + +} + +// +message CustomerEncryptionKeyProtectedDisk { + // Decrypts data associated with the disk with a customer-supplied encryption key. + optional CustomerEncryptionKey disk_encryption_key = 271660677; + + // Specifies a valid partial or full URL to an existing Persistent Disk resource. This field is only applicable for persistent disks. For example: "source": "/compute/v1/projects/project_id/zones/zone/disks/ disk_name + optional string source = 177235995; + +} + +// +message Data { + // [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). + optional string key = 106079; + + // [Output Only] A warning data value corresponding to the key. + optional string value = 111972721; + +} + +// A request message for Instances.DeleteAccessConfig. See the method description for details. +message DeleteAccessConfigInstanceRequest { + // The name of the access config to delete. + string access_config = 72856189 [(google.api.field_behavior) = REQUIRED]; + + // The instance name for this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The name of the network interface. + string network_interface = 365387880 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Addresses.Delete. See the method description for details. +message DeleteAddressRequest { + // Name of the address resource to delete. + string address = 462920692 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Autoscalers.Delete. See the method description for details. +message DeleteAutoscalerRequest { + // Name of the autoscaler to delete. + string autoscaler = 517258967 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for BackendBuckets.Delete. See the method description for details. +message DeleteBackendBucketRequest { + // Name of the BackendBucket resource to delete. + string backend_bucket = 91714037 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for BackendServices.Delete. See the method description for details. +message DeleteBackendServiceRequest { + // Name of the BackendService resource to delete. + string backend_service = 306946058 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Disks.Delete. See the method description for details. +message DeleteDiskRequest { + // Name of the persistent disk to delete. + string disk = 3083677 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for ExternalVpnGateways.Delete. See the method description for details. +message DeleteExternalVpnGatewayRequest { + // Name of the externalVpnGateways to delete. + string external_vpn_gateway = 109898629 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for FirewallPolicies.Delete. See the method description for details. +message DeleteFirewallPolicyRequest { + // Name of the firewall policy to delete. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Firewalls.Delete. See the method description for details. +message DeleteFirewallRequest { + // Name of the firewall rule to delete. + string firewall = 511016192 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for ForwardingRules.Delete. See the method description for details. +message DeleteForwardingRuleRequest { + // Name of the ForwardingRule resource to delete. + string forwarding_rule = 269964030 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for GlobalAddresses.Delete. See the method description for details. +message DeleteGlobalAddressRequest { + // Name of the address resource to delete. + string address = 462920692 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for GlobalForwardingRules.Delete. See the method description for details. +message DeleteGlobalForwardingRuleRequest { + // Name of the ForwardingRule resource to delete. + string forwarding_rule = 269964030 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for GlobalNetworkEndpointGroups.Delete. See the method description for details. +message DeleteGlobalNetworkEndpointGroupRequest { + // The name of the network endpoint group to delete. It should comply with RFC1035. + string network_endpoint_group = 433907078 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for GlobalOperations.Delete. See the method description for details. +message DeleteGlobalOperationRequest { + // Name of the Operations resource to delete. + string operation = 52090215 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A response message for GlobalOperations.Delete. See the method description for details. +message DeleteGlobalOperationResponse { +} + +// A request message for GlobalOrganizationOperations.Delete. See the method description for details. +message DeleteGlobalOrganizationOperationRequest { + // Name of the Operations resource to delete. + string operation = 52090215 [(google.api.field_behavior) = REQUIRED]; + + // Parent ID for this request. + optional string parent_id = 459714768; + +} + +// A response message for GlobalOrganizationOperations.Delete. See the method description for details. +message DeleteGlobalOrganizationOperationResponse { +} + +// A request message for GlobalPublicDelegatedPrefixes.Delete. See the method description for details. +message DeleteGlobalPublicDelegatedPrefixeRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the PublicDelegatedPrefix resource to delete. + string public_delegated_prefix = 204238440 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for HealthChecks.Delete. See the method description for details. +message DeleteHealthCheckRequest { + // Name of the HealthCheck resource to delete. + string health_check = 308876645 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Images.Delete. See the method description for details. +message DeleteImageRequest { + // Name of the image resource to delete. + string image = 100313435 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for InstanceGroupManagers.Delete. See the method description for details. +message DeleteInstanceGroupManagerRequest { + // The name of the managed instance group to delete. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where the managed instance group is located. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for InstanceGroups.Delete. See the method description for details. +message DeleteInstanceGroupRequest { + // The name of the instance group to delete. + string instance_group = 81095253 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where the instance group is located. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Instances.Delete. See the method description for details. +message DeleteInstanceRequest { + // Name of the instance resource to delete. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for InstanceTemplates.Delete. See the method description for details. +message DeleteInstanceTemplateRequest { + // The name of the instance template to delete. + string instance_template = 309248228 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for InstanceGroupManagers.DeleteInstances. See the method description for details. +message DeleteInstancesInstanceGroupManagerRequest { + // The name of the managed instance group. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstanceGroupManagersDeleteInstancesRequest instance_group_managers_delete_instances_request_resource = 166421252 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where the managed instance group is located. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for RegionInstanceGroupManagers.DeleteInstances. See the method description for details. +message DeleteInstancesRegionInstanceGroupManagerRequest { + // Name of the managed instance group. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionInstanceGroupManagersDeleteInstancesRequest region_instance_group_managers_delete_instances_request_resource = 500876665 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for InterconnectAttachments.Delete. See the method description for details. +message DeleteInterconnectAttachmentRequest { + // Name of the interconnect attachment to delete. + string interconnect_attachment = 308135284 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Interconnects.Delete. See the method description for details. +message DeleteInterconnectRequest { + // Name of the interconnect to delete. + string interconnect = 224601230 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Licenses.Delete. See the method description for details. +message DeleteLicenseRequest { + // Name of the license resource to delete. + string license = 166757441 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for MachineImages.Delete. See the method description for details. +message DeleteMachineImageRequest { + // The name of the machine image to delete. + string machine_image = 69189475 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for NetworkAttachments.Delete. See the method description for details. +message DeleteNetworkAttachmentRequest { + // Name of the NetworkAttachment resource to delete. + string network_attachment = 224644052 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region of this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). end_interface: MixerMutationRequestBuilder + optional string request_id = 37109963; + +} + +// A request message for NetworkEdgeSecurityServices.Delete. See the method description for details. +message DeleteNetworkEdgeSecurityServiceRequest { + // Name of the network edge security service to delete. + string network_edge_security_service = 157011879 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for NetworkEndpointGroups.Delete. See the method description for details. +message DeleteNetworkEndpointGroupRequest { + // The name of the network endpoint group to delete. It should comply with RFC1035. + string network_endpoint_group = 433907078 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where the network endpoint group is located. It should comply with RFC1035. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for NetworkFirewallPolicies.Delete. See the method description for details. +message DeleteNetworkFirewallPolicyRequest { + // Name of the firewall policy to delete. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Networks.Delete. See the method description for details. +message DeleteNetworkRequest { + // Name of the network to delete. + string network = 232872494 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for NodeGroups.Delete. See the method description for details. +message DeleteNodeGroupRequest { + // Name of the NodeGroup resource to delete. + string node_group = 469958146 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for NodeTemplates.Delete. See the method description for details. +message DeleteNodeTemplateRequest { + // Name of the NodeTemplate resource to delete. + string node_template = 323154455 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for NodeGroups.DeleteNodes. See the method description for details. +message DeleteNodesNodeGroupRequest { + // Name of the NodeGroup resource whose nodes will be deleted. + string node_group = 469958146 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + NodeGroupsDeleteNodesRequest node_groups_delete_nodes_request_resource = 183298962 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for PacketMirrorings.Delete. See the method description for details. +message DeletePacketMirroringRequest { + // Name of the PacketMirroring resource to delete. + string packet_mirroring = 22305996 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for InstanceGroupManagers.DeletePerInstanceConfigs. See the method description for details. +message DeletePerInstanceConfigsInstanceGroupManagerRequest { + // The name of the managed instance group. It should conform to RFC1035. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstanceGroupManagersDeletePerInstanceConfigsReq instance_group_managers_delete_per_instance_configs_req_resource = 362427680 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The name of the zone where the managed instance group is located. It should conform to RFC1035. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for RegionInstanceGroupManagers.DeletePerInstanceConfigs. See the method description for details. +message DeletePerInstanceConfigsRegionInstanceGroupManagerRequest { + // The name of the managed instance group. It should conform to RFC1035. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request, should conform to RFC1035. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionInstanceGroupManagerDeleteInstanceConfigReq region_instance_group_manager_delete_instance_config_req_resource = 740741 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for PublicAdvertisedPrefixes.Delete. See the method description for details. +message DeletePublicAdvertisedPrefixeRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the PublicAdvertisedPrefix resource to delete. + string public_advertised_prefix = 101874590 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for PublicDelegatedPrefixes.Delete. See the method description for details. +message DeletePublicDelegatedPrefixeRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the PublicDelegatedPrefix resource to delete. + string public_delegated_prefix = 204238440 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region of this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionAutoscalers.Delete. See the method description for details. +message DeleteRegionAutoscalerRequest { + // Name of the autoscaler to delete. + string autoscaler = 517258967 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionBackendServices.Delete. See the method description for details. +message DeleteRegionBackendServiceRequest { + // Name of the BackendService resource to delete. + string backend_service = 306946058 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionDisks.Delete. See the method description for details. +message DeleteRegionDiskRequest { + // Name of the regional persistent disk to delete. + string disk = 3083677 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionHealthChecks.Delete. See the method description for details. +message DeleteRegionHealthCheckRequest { + // Name of the HealthCheck resource to delete. + string health_check = 308876645 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionHealthCheckServices.Delete. See the method description for details. +message DeleteRegionHealthCheckServiceRequest { + // Name of the HealthCheckService to delete. The name must be 1-63 characters long, and comply with RFC1035. + string health_check_service = 408374747 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionInstanceGroupManagers.Delete. See the method description for details. +message DeleteRegionInstanceGroupManagerRequest { + // Name of the managed instance group to delete. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionInstanceTemplates.Delete. See the method description for details. +message DeleteRegionInstanceTemplateRequest { + // The name of the instance template to delete. + string instance_template = 309248228 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionNetworkEndpointGroups.Delete. See the method description for details. +message DeleteRegionNetworkEndpointGroupRequest { + // The name of the network endpoint group to delete. It should comply with RFC1035. + string network_endpoint_group = 433907078 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The name of the region where the network endpoint group is located. It should comply with RFC1035. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionNetworkFirewallPolicies.Delete. See the method description for details. +message DeleteRegionNetworkFirewallPolicyRequest { + // Name of the firewall policy to delete. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionNotificationEndpoints.Delete. See the method description for details. +message DeleteRegionNotificationEndpointRequest { + // Name of the NotificationEndpoint resource to delete. + string notification_endpoint = 376807017 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionOperations.Delete. See the method description for details. +message DeleteRegionOperationRequest { + // Name of the Operations resource to delete. + string operation = 52090215 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A response message for RegionOperations.Delete. See the method description for details. +message DeleteRegionOperationResponse { +} + +// A request message for RegionSecurityPolicies.Delete. See the method description for details. +message DeleteRegionSecurityPolicyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the security policy to delete. + string security_policy = 171082513 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionSslCertificates.Delete. See the method description for details. +message DeleteRegionSslCertificateRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the SslCertificate resource to delete. + string ssl_certificate = 46443492 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionSslPolicies.Delete. See the method description for details. +message DeleteRegionSslPolicyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the SSL policy to delete. The name must be 1-63 characters long, and comply with RFC1035. + string ssl_policy = 295190213 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionTargetHttpProxies.Delete. See the method description for details. +message DeleteRegionTargetHttpProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetHttpProxy resource to delete. + string target_http_proxy = 206872421 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionTargetHttpsProxies.Delete. See the method description for details. +message DeleteRegionTargetHttpsProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetHttpsProxy resource to delete. + string target_https_proxy = 52336748 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionTargetTcpProxies.Delete. See the method description for details. +message DeleteRegionTargetTcpProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetTcpProxy resource to delete. + string target_tcp_proxy = 503065442 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionUrlMaps.Delete. See the method description for details. +message DeleteRegionUrlMapRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // begin_interface: MixerMutationRequestBuilder Request ID to support idempotency. + optional string request_id = 37109963; + + // Name of the UrlMap resource to delete. + string url_map = 367020684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Reservations.Delete. See the method description for details. +message DeleteReservationRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the reservation to delete. + string reservation = 47530956 [(google.api.field_behavior) = REQUIRED]; + + // Name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for ResourcePolicies.Delete. See the method description for details. +message DeleteResourcePolicyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the resource policy to delete. + string resource_policy = 159240835 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Routes.Delete. See the method description for details. +message DeleteRouteRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the Route resource to delete. + string route = 108704329 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Routers.Delete. See the method description for details. +message DeleteRouterRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the Router resource to delete. + string router = 148608841 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for SecurityPolicies.Delete. See the method description for details. +message DeleteSecurityPolicyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the security policy to delete. + string security_policy = 171082513 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ServiceAttachments.Delete. See the method description for details. +message DeleteServiceAttachmentRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region of this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the ServiceAttachment resource to delete. + string service_attachment = 338957549 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for BackendBuckets.DeleteSignedUrlKey. See the method description for details. +message DeleteSignedUrlKeyBackendBucketRequest { + // Name of the BackendBucket resource to which the Signed URL Key should be added. The name should conform to RFC1035. + string backend_bucket = 91714037 [(google.api.field_behavior) = REQUIRED]; + + // The name of the Signed URL Key to delete. + string key_name = 500938859 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for BackendServices.DeleteSignedUrlKey. See the method description for details. +message DeleteSignedUrlKeyBackendServiceRequest { + // Name of the BackendService resource to which the Signed URL Key should be added. The name should conform to RFC1035. + string backend_service = 306946058 [(google.api.field_behavior) = REQUIRED]; + + // The name of the Signed URL Key to delete. + string key_name = 500938859 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Snapshots.Delete. See the method description for details. +message DeleteSnapshotRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the Snapshot resource to delete. + string snapshot = 284874180 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for SslCertificates.Delete. See the method description for details. +message DeleteSslCertificateRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the SslCertificate resource to delete. + string ssl_certificate = 46443492 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for SslPolicies.Delete. See the method description for details. +message DeleteSslPolicyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the SSL policy to delete. The name must be 1-63 characters long, and comply with RFC1035. + string ssl_policy = 295190213 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Subnetworks.Delete. See the method description for details. +message DeleteSubnetworkRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the Subnetwork resource to delete. + string subnetwork = 307827694 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetGrpcProxies.Delete. See the method description for details. +message DeleteTargetGrpcProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetGrpcProxy resource to delete. + string target_grpc_proxy = 5020283 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetHttpProxies.Delete. See the method description for details. +message DeleteTargetHttpProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetHttpProxy resource to delete. + string target_http_proxy = 206872421 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetHttpsProxies.Delete. See the method description for details. +message DeleteTargetHttpsProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetHttpsProxy resource to delete. + string target_https_proxy = 52336748 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetInstances.Delete. See the method description for details. +message DeleteTargetInstanceRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetInstance resource to delete. + string target_instance = 289769347 [(google.api.field_behavior) = REQUIRED]; + + // Name of the zone scoping this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for TargetPools.Delete. See the method description for details. +message DeleteTargetPoolRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetPool resource to delete. + string target_pool = 62796298 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetSslProxies.Delete. See the method description for details. +message DeleteTargetSslProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetSslProxy resource to delete. + string target_ssl_proxy = 338795853 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetTcpProxies.Delete. See the method description for details. +message DeleteTargetTcpProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetTcpProxy resource to delete. + string target_tcp_proxy = 503065442 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetVpnGateways.Delete. See the method description for details. +message DeleteTargetVpnGatewayRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the target VPN gateway to delete. + string target_vpn_gateway = 532512843 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for UrlMaps.Delete. See the method description for details. +message DeleteUrlMapRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the UrlMap resource to delete. + string url_map = 367020684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for VpnGateways.Delete. See the method description for details. +message DeleteVpnGatewayRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the VPN gateway to delete. + string vpn_gateway = 406684153 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for VpnTunnels.Delete. See the method description for details. +message DeleteVpnTunnelRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the VpnTunnel resource to delete. + string vpn_tunnel = 143821331 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ZoneOperations.Delete. See the method description for details. +message DeleteZoneOperationRequest { + // Name of the Operations resource to delete. + string operation = 52090215 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A response message for ZoneOperations.Delete. See the method description for details. +message DeleteZoneOperationResponse { +} + +// +message Denied { + // The IP protocol to which this rule applies. The protocol type is required when creating a firewall rule. This value can either be one of the following well known protocol strings (tcp, udp, icmp, esp, ah, ipip, sctp) or the IP protocol number. + optional string I_p_protocol = 488094525; + + // An optional list of ports to which this rule applies. This field is only applicable for the UDP or TCP protocol. Each entry must be either an integer or a range. If not specified, this rule applies to connections through any port. Example inputs include: ["22"], ["80","443"], and ["12345-12349"]. + repeated string ports = 106854418; + +} + +// A request message for Images.Deprecate. See the method description for details. +message DeprecateImageRequest { + // The body resource for this request + DeprecationStatus deprecation_status_resource = 333006064 [(google.api.field_behavior) = REQUIRED]; + + // Image name. + string image = 100313435 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// Deprecation status for a public resource. +message DeprecationStatus { + // The deprecation state of this resource. This can be ACTIVE, DEPRECATED, OBSOLETE, or DELETED. Operations which communicate the end of life date for an image, can use ACTIVE. Operations which create a new resource using a DEPRECATED resource will return successfully, but with a warning indicating the deprecated resource and recommending its replacement. Operations which use OBSOLETE or DELETED resources will be rejected and result in an error. + enum State { + // A value indicating that the enum field is not set. + UNDEFINED_STATE = 0; + + ACTIVE = 314733318; + + DELETED = 120962041; + + DEPRECATED = 463360435; + + OBSOLETE = 66532761; + + } + + // An optional RFC3339 timestamp on or after which the state of this resource is intended to change to DELETED. This is only informational and the status will not change unless the client explicitly changes it. + optional string deleted = 476721177; + + // An optional RFC3339 timestamp on or after which the state of this resource is intended to change to DEPRECATED. This is only informational and the status will not change unless the client explicitly changes it. + optional string deprecated = 515138995; + + // An optional RFC3339 timestamp on or after which the state of this resource is intended to change to OBSOLETE. This is only informational and the status will not change unless the client explicitly changes it. + optional string obsolete = 357647769; + + // The URL of the suggested replacement for a deprecated resource. The suggested replacement resource must be the same kind of resource as the deprecated resource. + optional string replacement = 430919186; + + // The deprecation state of this resource. This can be ACTIVE, DEPRECATED, OBSOLETE, or DELETED. Operations which communicate the end of life date for an image, can use ACTIVE. Operations which create a new resource using a DEPRECATED resource will return successfully, but with a warning indicating the deprecated resource and recommending its replacement. Operations which use OBSOLETE or DELETED resources will be rejected and result in an error. + // Check the State enum for the list of possible values. + optional string state = 109757585; + +} + +// A request message for Instances.DetachDisk. See the method description for details. +message DetachDiskInstanceRequest { + // The device name of the disk to detach. Make a get() request on the instance to view currently attached disks and device names. + string device_name = 67541716 [(google.api.field_behavior) = REQUIRED]; + + // Instance name for this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for GlobalNetworkEndpointGroups.DetachNetworkEndpoints. See the method description for details. +message DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest { + // The body resource for this request + GlobalNetworkEndpointGroupsDetachEndpointsRequest global_network_endpoint_groups_detach_endpoints_request_resource = 8898269 [(google.api.field_behavior) = REQUIRED]; + + // The name of the network endpoint group where you are removing network endpoints. It should comply with RFC1035. + string network_endpoint_group = 433907078 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for NetworkEndpointGroups.DetachNetworkEndpoints. See the method description for details. +message DetachNetworkEndpointsNetworkEndpointGroupRequest { + // The name of the network endpoint group where you are removing network endpoints. It should comply with RFC1035. + string network_endpoint_group = 433907078 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + NetworkEndpointGroupsDetachEndpointsRequest network_endpoint_groups_detach_endpoints_request_resource = 515608697 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where the network endpoint group is located. It should comply with RFC1035. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Projects.DisableXpnHost. See the method description for details. +message DisableXpnHostProjectRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Projects.DisableXpnResource. See the method description for details. +message DisableXpnResourceProjectRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The body resource for this request + ProjectsDisableXpnResourceRequest projects_disable_xpn_resource_request_resource = 209136170 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// Represents a Persistent Disk resource. Google Compute Engine has two Disk resources: * [Zonal](/compute/docs/reference/rest/v1/disks) * [Regional](/compute/docs/reference/rest/v1/regionDisks) Persistent disks are required for running your VM instances. Create both boot and non-boot (data) persistent disks. For more information, read Persistent Disks. For more storage options, read Storage options. The disks resource represents a zonal persistent disk. For more information, read Zonal persistent disks. The regionDisks resource represents a regional persistent disk. For more information, read Regional resources. +message Disk { + // The architecture of the disk. Valid values are ARM64 or X86_64. + enum Architecture { + // A value indicating that the enum field is not set. + UNDEFINED_ARCHITECTURE = 0; + + // Default value indicating Architecture is not set. + ARCHITECTURE_UNSPECIFIED = 394750507; + + // Machines with architecture ARM64 + ARM64 = 62547450; + + // Machines with architecture X86_64 + X86_64 = 425300551; + + } + + // [Output Only] The status of disk creation. - CREATING: Disk is provisioning. - RESTORING: Source data is being copied into the disk. - FAILED: Disk creation failed. - READY: Disk is ready for use. - DELETING: Disk is deleting. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // Disk is provisioning + CREATING = 455564985; + + // Disk is deleting. + DELETING = 528602024; + + // Disk creation failed. + FAILED = 455706685; + + // Disk is ready for use. + READY = 77848963; + + // Source data is being copied into the disk. + RESTORING = 404263851; + + } + + // The architecture of the disk. Valid values are ARM64 or X86_64. + // Check the Architecture enum for the list of possible values. + optional string architecture = 302803283; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Encrypts the disk using a customer-supplied encryption key or a customer-managed encryption key. Encryption keys do not protect access to metadata of the disk. After you encrypt a disk with a customer-supplied key, you must provide the same key if you use the disk later. For example, to create a disk snapshot, to create a disk image, to create a machine image, or to attach the disk to a virtual machine. After you encrypt a disk with a customer-managed key, the diskEncryptionKey.kmsKeyName is set to a key *version* name once the disk is created. The disk is encrypted with this version of the key. In the response, diskEncryptionKey.kmsKeyName appears in the following format: "diskEncryptionKey.kmsKeyName": "projects/kms_project_id/locations/region/keyRings/ key_region/cryptoKeys/key /cryptoKeysVersions/version If you do not provide an encryption key when creating the disk, then the disk is encrypted using an automatically generated key and you don't need to provide a key to use the disk later. + optional CustomerEncryptionKey disk_encryption_key = 271660677; + + // A list of features to enable on the guest operating system. Applicable only for bootable images. Read Enabling guest operating system features to see a list of available options. + repeated GuestOsFeature guest_os_features = 79294545; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#disk for disks. + optional string kind = 3292052; + + // A fingerprint for the labels being applied to this disk, which is essentially a hash of the labels set used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update labels. You must always provide an up-to-date fingerprint hash in order to update or change labels, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve a disk. + optional string label_fingerprint = 178124825; + + // Labels to apply to this disk. These can be later modified by the setLabels method. + map labels = 500195327; + + // [Output Only] Last attach timestamp in RFC3339 text format. + optional string last_attach_timestamp = 42159653; + + // [Output Only] Last detach timestamp in RFC3339 text format. + optional string last_detach_timestamp = 56471027; + + // Integer license codes indicating which licenses are attached to this disk. + repeated int64 license_codes = 45482664; + + // A list of publicly visible licenses. Reserved for Google's use. + repeated string licenses = 337642578; + + // An opaque location hint used to place the disk close to other resources. This field is for use by internal tools that use the public API. + optional string location_hint = 350519505; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // Internal use only. + optional string options = 361137822; + + // Input only. [Input Only] Additional params passed with the request, but not persisted as part of resource payload. + optional DiskParams params = 78313862; + + // Physical block size of the persistent disk, in bytes. If not present in a request, a default value is used. The currently supported size is 4096, other sizes may be added in the future. If an unsupported value is requested, the error message will list the supported values for the caller's project. + optional int64 physical_block_size_bytes = 420007943; + + // Indicates how many IOPS to provision for the disk. This sets the number of I/O operations per second that the disk can handle. Values must be between 10,000 and 120,000. For more details, see the Extreme persistent disk documentation. + optional int64 provisioned_iops = 186769108; + + // [Output Only] URL of the region where the disk resides. Only applicable for regional resources. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string region = 138946292; + + // URLs of the zones where the disk should be replicated to. Only applicable for regional resources. + repeated string replica_zones = 48438272; + + // Resource policies applied to this disk for automatic snapshot creations. + repeated string resource_policies = 22220385; + + // [Output Only] Reserved for future use. + optional bool satisfies_pzs = 480964267; + + // [Output Only] Server-defined fully-qualified URL for this resource. + optional string self_link = 456214797; + + // Size, in GB, of the persistent disk. You can specify this field when creating a persistent disk using the sourceImage, sourceSnapshot, or sourceDisk parameter, or specify it alone to create an empty persistent disk. If you specify this field along with a source, the value of sizeGb must not be less than the size of the source. Acceptable values are 1 to 65536, inclusive. + optional int64 size_gb = 494929369; + + // The source disk used to create this disk. You can provide this as a partial or full URL to the resource. For example, the following are valid values: - https://www.googleapis.com/compute/v1/projects/project/zones/zone /disks/disk - https://www.googleapis.com/compute/v1/projects/project/regions/region /disks/disk - projects/project/zones/zone/disks/disk - projects/project/regions/region/disks/disk - zones/zone/disks/disk - regions/region/disks/disk + optional string source_disk = 451753793; + + // [Output Only] The unique ID of the disk used to create this disk. This value identifies the exact disk that was used to create this persistent disk. For example, if you created the persistent disk from a disk that was later deleted and recreated under the same name, the source disk ID would identify the exact version of the disk that was used. + optional string source_disk_id = 454190809; + + // The source image used to create this disk. If the source image is deleted, this field will not be set. To create a disk with one of the public operating system images, specify the image by its family name. For example, specify family/debian-9 to use the latest Debian 9 image: projects/debian-cloud/global/images/family/debian-9 Alternatively, use a specific version of a public operating system image: projects/debian-cloud/global/images/debian-9-stretch-vYYYYMMDD To create a disk with a custom image that you created, specify the image name in the following format: global/images/my-custom-image You can also specify a custom image by its image family, which returns the latest version of the image in that family. Replace the image name with family/family-name: global/images/family/my-image-family + optional string source_image = 50443319; + + // The customer-supplied encryption key of the source image. Required if the source image is protected by a customer-supplied encryption key. + optional CustomerEncryptionKey source_image_encryption_key = 381503659; + + // [Output Only] The ID value of the image used to create this disk. This value identifies the exact image that was used to create this persistent disk. For example, if you created the persistent disk from an image that was later deleted and recreated under the same name, the source image ID would identify the exact version of the image that was used. + optional string source_image_id = 55328291; + + // The source snapshot used to create this disk. You can provide this as a partial or full URL to the resource. For example, the following are valid values: - https://www.googleapis.com/compute/v1/projects/project /global/snapshots/snapshot - projects/project/global/snapshots/snapshot - global/snapshots/snapshot + optional string source_snapshot = 126061928; + + // The customer-supplied encryption key of the source snapshot. Required if the source snapshot is protected by a customer-supplied encryption key. + optional CustomerEncryptionKey source_snapshot_encryption_key = 303679322; + + // [Output Only] The unique ID of the snapshot used to create this disk. This value identifies the exact snapshot that was used to create this persistent disk. For example, if you created the persistent disk from a snapshot that was later deleted and recreated under the same name, the source snapshot ID would identify the exact version of the snapshot that was used. + optional string source_snapshot_id = 98962258; + + // The full Google Cloud Storage URI where the disk image is stored. This file must be a gzip-compressed tarball whose name ends in .tar.gz or virtual machine disk whose name ends in vmdk. Valid URIs may start with gs:// or https://storage.googleapis.com/. This flag is not optimized for creating multiple disks from a source storage object. To create many disks from a source storage object, use gcloud compute images import instead. + optional string source_storage_object = 233052711; + + // [Output Only] The status of disk creation. - CREATING: Disk is provisioning. - RESTORING: Source data is being copied into the disk. - FAILED: Disk creation failed. - READY: Disk is ready for use. - DELETING: Disk is deleting. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // URL of the disk type resource describing which disk type to use to create the disk. Provide this when creating the disk. For example: projects/project /zones/zone/diskTypes/pd-ssd . See Persistent disk types. + optional string type = 3575610; + + // [Output Only] Links to the users of the disk (attached instances) in form: projects/project/zones/zone/instances/instance + repeated string users = 111578632; + + // [Output Only] URL of the zone where the disk resides. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string zone = 3744684; + +} + +// +message DiskAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of DisksScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#diskAggregatedList for aggregated lists of persistent disks. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// A specification of the desired way to instantiate a disk in the instance template when its created from a source instance. +message DiskInstantiationConfig { + // Specifies whether to include the disk and what image to use. Possible values are: - source-image: to use the same image that was used to create the source instance's corresponding disk. Applicable to the boot disk and additional read-write disks. - source-image-family: to use the same image family that was used to create the source instance's corresponding disk. Applicable to the boot disk and additional read-write disks. - custom-image: to use a user-provided image url for disk creation. Applicable to the boot disk and additional read-write disks. - attach-read-only: to attach a read-only disk. Applicable to read-only disks. - do-not-include: to exclude a disk from the template. Applicable to additional read-write disks, local SSDs, and read-only disks. + enum InstantiateFrom { + // A value indicating that the enum field is not set. + UNDEFINED_INSTANTIATE_FROM = 0; + + // Attach the existing disk in read-only mode. The request will fail if the disk was attached in read-write mode on the source instance. Applicable to: read-only disks. + ATTACH_READ_ONLY = 513775419; + + // Create a blank disk. The disk will be created unformatted. Applicable to: additional read-write disks, local SSDs. + BLANK = 63281460; + + // Use the custom image specified in the custom_image field. Applicable to: boot disk, additional read-write disks. + CUSTOM_IMAGE = 196311789; + + // Use the default instantiation option for the corresponding type of disk. For boot disk and any other R/W disks, new custom images will be created from each disk. For read-only disks, they will be attached in read-only mode. Local SSD disks will be created as blank volumes. + DEFAULT = 115302945; + + // Do not include the disk in the instance template. Applicable to: additional read-write disks, local SSDs, read-only disks. + DO_NOT_INCLUDE = 104218952; + + // Use the same source image used for creation of the source instance's corresponding disk. The request will fail if the source VM's disk was created from a snapshot. Applicable to: boot disk, additional read-write disks. + SOURCE_IMAGE = 62631959; + + // Use the same source image family used for creation of the source instance's corresponding disk. The request will fail if the source image of the source disk does not belong to any image family. Applicable to: boot disk, additional read-write disks. + SOURCE_IMAGE_FAMILY = 76850316; + + } + + // Specifies whether the disk will be auto-deleted when the instance is deleted (but not when the disk is detached from the instance). + optional bool auto_delete = 464761403; + + // The custom source image to be used to restore this disk when instantiating this instance template. + optional string custom_image = 184123149; + + // Specifies the device name of the disk to which the configurations apply to. + optional string device_name = 67541716; + + // Specifies whether to include the disk and what image to use. Possible values are: - source-image: to use the same image that was used to create the source instance's corresponding disk. Applicable to the boot disk and additional read-write disks. - source-image-family: to use the same image family that was used to create the source instance's corresponding disk. Applicable to the boot disk and additional read-write disks. - custom-image: to use a user-provided image url for disk creation. Applicable to the boot disk and additional read-write disks. - attach-read-only: to attach a read-only disk. Applicable to read-only disks. - do-not-include: to exclude a disk from the template. Applicable to additional read-write disks, local SSDs, and read-only disks. + // Check the InstantiateFrom enum for the list of possible values. + optional string instantiate_from = 393383903; + +} + +// A list of Disk resources. +message DiskList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Disk resources. + repeated Disk items = 100526016; + + // [Output Only] Type of resource. Always compute#diskList for lists of disks. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message DiskMoveRequest { + // The URL of the destination zone to move the disk. This can be a full or partial URL. For example, the following are all valid URLs to a zone: - https://www.googleapis.com/compute/v1/projects/project/zones/zone - projects/project/zones/zone - zones/zone + optional string destination_zone = 131854653; + + // The URL of the target disk to move. This can be a full or partial URL. For example, the following are all valid URLs to a disk: - https://www.googleapis.com/compute/v1/projects/project/zones/zone /disks/disk - projects/project/zones/zone/disks/disk - zones/zone/disks/disk + optional string target_disk = 62433163; + +} + +// Additional disk params. +message DiskParams { + // Resource manager tags to be bound to the disk. Tag keys and values have the same definition as resource manager tags. Keys must be in the format `tagKeys/{tag_key_id}`, and values are in the format `tagValues/456`. The field is ignored (both PUT & PATCH) when empty. + map resource_manager_tags = 377671164; + +} + +// Represents a Disk Type resource. Google Compute Engine has two Disk Type resources: * [Regional](/compute/docs/reference/rest/v1/regionDiskTypes) * [Zonal](/compute/docs/reference/rest/v1/diskTypes) You can choose from a variety of disk types based on your needs. For more information, read Storage options. The diskTypes resource represents disk types for a zonal persistent disk. For more information, read Zonal persistent disks. The regionDiskTypes resource represents disk types for a regional persistent disk. For more information, read Regional persistent disks. +message DiskType { + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // [Output Only] Server-defined default disk size in GB. + optional int64 default_disk_size_gb = 270619253; + + // [Output Only] The deprecation status associated with this disk type. + optional DeprecationStatus deprecated = 515138995; + + // [Output Only] An optional description of this resource. + optional string description = 422937596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#diskType for disk types. + optional string kind = 3292052; + + // [Output Only] Name of the resource. + optional string name = 3373707; + + // [Output Only] URL of the region where the disk type resides. Only applicable for regional resources. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] An optional textual description of the valid disk size, such as "10GB-10TB". + optional string valid_disk_size = 493962464; + + // [Output Only] URL of the zone where the disk type resides. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string zone = 3744684; + +} + +// +message DiskTypeAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of DiskTypesScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#diskTypeAggregatedList. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of disk types. +message DiskTypeList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of DiskType resources. + repeated DiskType items = 100526016; + + // [Output Only] Type of resource. Always compute#diskTypeList for disk types. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message DiskTypesScopedList { + // [Output Only] A list of disk types contained in this scope. + repeated DiskType disk_types = 198926167; + + // [Output Only] Informational warning which replaces the list of disk types when the list is empty. + optional Warning warning = 50704284; + +} + +// +message DisksAddResourcePoliciesRequest { + // Full or relative path to the resource policy to be added to this disk. You can only specify one resource policy. + repeated string resource_policies = 22220385; + +} + +// +message DisksRemoveResourcePoliciesRequest { + // Resource policies to be removed from this disk. + repeated string resource_policies = 22220385; + +} + +// +message DisksResizeRequest { + // The new size of the persistent disk, which is specified in GB. + optional int64 size_gb = 494929369; + +} + +// +message DisksScopedList { + // [Output Only] A list of disks contained in this scope. + repeated Disk disks = 95594102; + + // [Output Only] Informational warning which replaces the list of disks when the list is empty. + optional Warning warning = 50704284; + +} + +// A set of Display Device options +message DisplayDevice { + // Defines whether the instance has Display enabled. + optional bool enable_display = 14266886; + +} + +// +message DistributionPolicy { + // The distribution shape to which the group converges either proactively or on resize events (depending on the value set in updatePolicy.instanceRedistributionType). + enum TargetShape { + // A value indicating that the enum field is not set. + UNDEFINED_TARGET_SHAPE = 0; + + // The group picks zones for creating VM instances to fulfill the requested number of VMs within present resource constraints and to maximize utilization of unused zonal reservations. Recommended for batch workloads that do not require high availability. + ANY = 64972; + + // The group prioritizes acquisition of resources, scheduling VMs in zones where resources are available while distributing VMs as evenly as possible across selected zones to minimize the impact of zonal failure. Recommended for highly available serving workloads. + BALANCED = 468409608; + + // The group schedules VM instance creation and deletion to achieve and maintain an even number of managed instances across the selected zones. The distribution is even when the number of managed instances does not differ by more than 1 between any two zones. Recommended for highly available serving workloads. + EVEN = 2140442; + + } + + // The distribution shape to which the group converges either proactively or on resize events (depending on the value set in updatePolicy.instanceRedistributionType). + // Check the TargetShape enum for the list of possible values. + optional string target_shape = 338621299; + + // Zones where the regional managed instance group will create and manage its instances. + repeated DistributionPolicyZoneConfiguration zones = 116085319; + +} + +// +message DistributionPolicyZoneConfiguration { + // The URL of the zone. The zone must exist in the region where the managed instance group is located. + optional string zone = 3744684; + +} + +// A Duration represents a fixed-length span of time represented as a count of seconds and fractions of seconds at nanosecond resolution. It is independent of any calendar and concepts like "day" or "month". Range is approximately 10,000 years. +message Duration { + // Span of time that's a fraction of a second at nanosecond resolution. Durations less than one second are represented with a 0 `seconds` field and a positive `nanos` field. Must be from 0 to 999,999,999 inclusive. + optional int32 nanos = 104586303; + + // Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 inclusive. Note: these bounds are computed from: 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + optional int64 seconds = 359484031; + +} + +// A request message for Projects.EnableXpnHost. See the method description for details. +message EnableXpnHostProjectRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Projects.EnableXpnResource. See the method description for details. +message EnableXpnResourceProjectRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The body resource for this request + ProjectsEnableXpnResourceRequest projects_enable_xpn_resource_request_resource = 421980207 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// [Output Only] If errors are generated during processing of the operation, this field will be populated. +message Error { + // [Output Only] The array of errors encountered while processing this operation. + repeated Errors errors = 315977579; + +} + +// +message ErrorDetails { + optional ErrorInfo error_info = 25251973; + + optional Help help = 3198785; + + optional LocalizedMessage localized_message = 404537155; + + optional QuotaExceededInfo quota_info = 93923861; + +} + +// Describes the cause of the error with structured details. Example of an error when contacting the "pubsub.googleapis.com" API when it is not enabled: { "reason": "API_DISABLED" "domain": "googleapis.com" "metadata": { "resource": "projects/123", "service": "pubsub.googleapis.com" } } This response indicates that the pubsub.googleapis.com API is not enabled. Example of an error that is returned when attempting to create a Spanner instance in a region that is out of stock: { "reason": "STOCKOUT" "domain": "spanner.googleapis.com", "metadata": { "availableRegions": "us-central1,us-east2" } } +message ErrorInfo { + // The logical grouping to which the "reason" belongs. The error domain is typically the registered service name of the tool or product that generates the error. Example: "pubsub.googleapis.com". If the error is generated by some common infrastructure, the error domain must be a globally unique value that identifies the infrastructure. For Google API infrastructure, the error domain is "googleapis.com". + optional string domain = 284415172; + + // Additional structured details about this error. Keys should match /[a-zA-Z0-9-_]/ and be limited to 64 characters in length. When identifying the current value of an exceeded limit, the units should be contained in the key, not the value. For example, rather than {"instanceLimit": "100/request"}, should be returned as, {"instanceLimitPerRequest": "100"}, if the client exceeds the number of instances that can be created in a single (batch) request. + map metadatas = 8514340; + + // The reason of the error. This is a constant value that identifies the proximate cause of the error. Error reasons are unique within a particular domain of errors. This should be at most 63 characters and match a regular expression of `A-Z+[A-Z0-9]`, which represents UPPER_SNAKE_CASE. + optional string reason = 138777156; + +} + +// +message Errors { + // [Output Only] The error type identifier for this error. + optional string code = 3059181; + + // [Output Only] An optional list of messages that contain the error details. There is a set of defined message types to use for providing details.The syntax depends on the error code. For example, QuotaExceededInfo will have details when the error code is QUOTA_EXCEEDED. + repeated ErrorDetails error_details = 274653963; + + // [Output Only] Indicates the field in the request that caused the error. This property is optional. + optional string location = 290430901; + + // [Output Only] An optional, human-readable error message. + optional string message = 418054151; + +} + +// +message ExchangedPeeringRoute { + // The type of the peering route. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + // For routes exported from local network. + DYNAMIC_PEERING_ROUTE = 469794858; + + // The peering route. + STATIC_PEERING_ROUTE = 473407545; + + // The peering route corresponding to subnetwork range. + SUBNET_PEERING_ROUTE = 465782504; + + } + + // The destination range of the route. + optional string dest_range = 381327712; + + // True if the peering route has been imported from a peer. The actual import happens if the field networkPeering.importCustomRoutes is true for this network, and networkPeering.exportCustomRoutes is true for the peer network, and the import does not result in a route conflict. + optional bool imported = 114502404; + + // The region of peering route next hop, only applies to dynamic routes. + optional string next_hop_region = 122577014; + + // The priority of the peering route. + optional uint32 priority = 445151652; + + // The type of the peering route. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// +message ExchangedPeeringRoutesList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of ExchangedPeeringRoute resources. + repeated ExchangedPeeringRoute items = 100526016; + + // [Output Only] Type of resource. Always compute#exchangedPeeringRoutesList for exchanged peering routes lists. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// A request message for Subnetworks.ExpandIpCidrRange. See the method description for details. +message ExpandIpCidrRangeSubnetworkRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the Subnetwork resource to update. + string subnetwork = 307827694 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + SubnetworksExpandIpCidrRangeRequest subnetworks_expand_ip_cidr_range_request_resource = 477014110 [(google.api.field_behavior) = REQUIRED]; + +} + +// Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec. Example (Comparison): title: "Summary size limit" description: "Determines if a summary is less than 100 chars" expression: "document.summary.size() < 100" Example (Equality): title: "Requestor is owner" description: "Determines if requestor is the document owner" expression: "document.owner == request.auth.claims.email" Example (Logic): title: "Public documents" description: "Determine whether the document should be publicly visible" expression: "document.type != 'private' && document.type != 'internal'" Example (Data Manipulation): title: "Notification string" description: "Create a notification string with a timestamp." expression: "'New message received at ' + string(document.create_time)" The exact variables and functions that may be referenced within an expression are determined by the service that evaluates it. See the service documentation for additional information. +message Expr { + // Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI. + optional string description = 422937596; + + // Textual representation of an expression in Common Expression Language syntax. + optional string expression = 352031384; + + // Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file. + optional string location = 290430901; + + // Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression. + optional string title = 110371416; + +} + +// Represents an external VPN gateway. External VPN gateway is the on-premises VPN gateway(s) or another cloud provider's VPN gateway that connects to your Google Cloud VPN gateway. To create a highly available VPN from Google Cloud Platform to your VPN gateway or another cloud provider's VPN gateway, you must create a external VPN gateway resource with information about the other gateway. For more information about using external VPN gateways, see Creating an HA VPN gateway and tunnel pair to a peer VPN. +message ExternalVpnGateway { + // Indicates the user-supplied redundancy type of this external VPN gateway. + enum RedundancyType { + // A value indicating that the enum field is not set. + UNDEFINED_REDUNDANCY_TYPE = 0; + + // The external VPN gateway has four public IP addresses; at the time of writing this API, the AWS virtual private gateway is an example which has four public IP addresses for high availability connections; there should be two VPN connections in the AWS virtual private gateway , each AWS VPN connection has two public IP addresses; please make sure to put two public IP addresses from one AWS VPN connection into interfaces 0 and 1 of this external VPN gateway, and put the other two public IP addresses from another AWS VPN connection into interfaces 2 and 3 of this external VPN gateway. When displaying highly available configuration status for the VPN tunnels connected to FOUR_IPS_REDUNDANCY external VPN gateway, Google will always detect whether interfaces 0 and 1 are connected on one interface of HA Cloud VPN gateway, and detect whether interfaces 2 and 3 are connected to another interface of the HA Cloud VPN gateway. + FOUR_IPS_REDUNDANCY = 520087913; + + // The external VPN gateway has only one public IP address which internally provide redundancy or failover. + SINGLE_IP_INTERNALLY_REDUNDANT = 133914873; + + // The external VPN gateway has two public IP addresses which are redundant with each other, the following two types of setup on your on-premises side would have this type of redundancy: (1) Two separate on-premises gateways, each with one public IP address, the two on-premises gateways are redundant with each other. (2) A single on-premise gateway with two public IP addresses that are redundant with eatch other. + TWO_IPS_REDUNDANCY = 367049635; + + } + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // A list of interfaces for this external VPN gateway. If your peer-side gateway is an on-premises gateway and non-AWS cloud providers' gateway, at most two interfaces can be provided for an external VPN gateway. If your peer side is an AWS virtual private gateway, four interfaces should be provided for an external VPN gateway. + repeated ExternalVpnGatewayInterface interfaces = 12073562; + + // [Output Only] Type of the resource. Always compute#externalVpnGateway for externalVpnGateways. + optional string kind = 3292052; + + // A fingerprint for the labels being applied to this ExternalVpnGateway, which is essentially a hash of the labels set used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update labels. You must always provide an up-to-date fingerprint hash in order to update or change labels, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve an ExternalVpnGateway. + optional string label_fingerprint = 178124825; + + // Labels for this resource. These can only be added or modified by the setLabels method. Each label key/value pair must comply with RFC1035. Label values may be empty. + map labels = 500195327; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // Indicates the user-supplied redundancy type of this external VPN gateway. + // Check the RedundancyType enum for the list of possible values. + optional string redundancy_type = 271443740; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + +} + +// The interface for the external VPN gateway. +message ExternalVpnGatewayInterface { + // The numeric ID of this interface. The allowed input values for this id for different redundancy types of external VPN gateway: - SINGLE_IP_INTERNALLY_REDUNDANT - 0 - TWO_IPS_REDUNDANCY - 0, 1 - FOUR_IPS_REDUNDANCY - 0, 1, 2, 3 + optional uint32 id = 3355; + + // IP address of the interface in the external VPN gateway. Only IPv4 is supported. This IP address can be either from your on-premise gateway or another Cloud provider's VPN gateway, it cannot be an IP address from Google Compute Engine. + optional string ip_address = 406272220; + +} + +// Response to the list request, and contains a list of externalVpnGateways. +message ExternalVpnGatewayList { + optional string etag = 3123477; + + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of ExternalVpnGateway resources. + repeated ExternalVpnGateway items = 100526016; + + // [Output Only] Type of resource. Always compute#externalVpnGatewayList for lists of externalVpnGateways. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message FileContentBuffer { + // The file type of source file. + enum FileType { + // A value indicating that the enum field is not set. + UNDEFINED_FILE_TYPE = 0; + + BIN = 65767; + + UNDEFINED = 137851184; + + X509 = 2674086; + + } + + // The raw content in the secure keys file. + optional string content = 414659705; + + // The file type of source file. + // Check the FileType enum for the list of possible values. + optional string file_type = 294346781; + +} + +// Represents a Firewall Rule resource. Firewall rules allow or deny ingress traffic to, and egress traffic from your instances. For more information, read Firewall rules. +message Firewall { + // Direction of traffic to which this firewall applies, either `INGRESS` or `EGRESS`. The default is `INGRESS`. For `EGRESS` traffic, you cannot specify the sourceTags fields. + enum Direction { + // A value indicating that the enum field is not set. + UNDEFINED_DIRECTION = 0; + + // Indicates that firewall should apply to outgoing traffic. + EGRESS = 432880501; + + // Indicates that firewall should apply to incoming traffic. + INGRESS = 516931221; + + } + + // The list of ALLOW rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a permitted connection. + repeated Allowed allowed = 162398632; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // The list of DENY rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a denied connection. + repeated Denied denied = 275217307; + + // An optional description of this resource. Provide this field when you create the resource. + optional string description = 422937596; + + // If destination ranges are specified, the firewall rule applies only to traffic that has destination IP address in these ranges. These ranges must be expressed in CIDR format. Both IPv4 and IPv6 are supported. + repeated string destination_ranges = 305699879; + + // Direction of traffic to which this firewall applies, either `INGRESS` or `EGRESS`. The default is `INGRESS`. For `EGRESS` traffic, you cannot specify the sourceTags fields. + // Check the Direction enum for the list of possible values. + optional string direction = 111150975; + + // Denotes whether the firewall rule is disabled. When set to true, the firewall rule is not enforced and the network behaves as if it did not exist. If this is unspecified, the firewall rule will be enabled. + optional bool disabled = 270940796; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#firewall for firewall rules. + optional string kind = 3292052; + + // This field denotes the logging options for a particular firewall rule. If logging is enabled, logs will be exported to Cloud Logging. + optional FirewallLogConfig log_config = 351299741; + + // Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`. The first character must be a lowercase letter, and all following characters (except for the last character) must be a dash, lowercase letter, or digit. The last character must be a lowercase letter or digit. + optional string name = 3373707; + + // URL of the network resource for this firewall rule. If not specified when creating a firewall rule, the default network is used: global/networks/default If you choose to specify this field, you can specify the network as a full or partial URL. For example, the following are all valid URLs: - https://www.googleapis.com/compute/v1/projects/myproject/global/networks/my-network - projects/myproject/global/networks/my-network - global/networks/default + optional string network = 232872494; + + // Priority for this rule. This is an integer between `0` and `65535`, both inclusive. The default value is `1000`. Relative priorities determine which rule takes effect if multiple rules apply. Lower values indicate higher priority. For example, a rule with priority `0` has higher precedence than a rule with priority `1`. DENY rules take precedence over ALLOW rules if they have equal priority. Note that VPC networks have implied rules with a priority of `65535`. To avoid conflicts with the implied rules, use a priority number less than `65535`. + optional int32 priority = 445151652; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // If source ranges are specified, the firewall rule applies only to traffic that has a source IP address in these ranges. These ranges must be expressed in CIDR format. One or both of sourceRanges and sourceTags may be set. If both fields are set, the rule applies to traffic that has a source IP address within sourceRanges OR a source IP from a resource with a matching tag listed in the sourceTags field. The connection does not need to match both fields for the rule to apply. Both IPv4 and IPv6 are supported. + repeated string source_ranges = 200097658; + + // If source service accounts are specified, the firewall rules apply only to traffic originating from an instance with a service account in this list. Source service accounts cannot be used to control traffic to an instance's external IP address because service accounts are associated with an instance, not an IP address. sourceRanges can be set at the same time as sourceServiceAccounts. If both are set, the firewall applies to traffic that has a source IP address within the sourceRanges OR a source IP that belongs to an instance with service account listed in sourceServiceAccount. The connection does not need to match both fields for the firewall to apply. sourceServiceAccounts cannot be used at the same time as sourceTags or targetTags. + repeated string source_service_accounts = 105100756; + + // If source tags are specified, the firewall rule applies only to traffic with source IPs that match the primary network interfaces of VM instances that have the tag and are in the same VPC network. Source tags cannot be used to control traffic to an instance's external IP address, it only applies to traffic between instances in the same virtual network. Because tags are associated with instances, not IP addresses. One or both of sourceRanges and sourceTags may be set. If both fields are set, the firewall applies to traffic that has a source IP address within sourceRanges OR a source IP from a resource with a matching tag listed in the sourceTags field. The connection does not need to match both fields for the firewall to apply. + repeated string source_tags = 452222397; + + // A list of service accounts indicating sets of instances located in the network that may make network connections as specified in allowed[]. targetServiceAccounts cannot be used at the same time as targetTags or sourceTags. If neither targetServiceAccounts nor targetTags are specified, the firewall rule applies to all instances on the specified network. + repeated string target_service_accounts = 457639710; + + // A list of tags that controls which instances the firewall rule applies to. If targetTags are specified, then the firewall rule applies only to instances in the VPC network that have one of those tags. If no targetTags are specified, the firewall rule applies to all instances on the specified network. + repeated string target_tags = 62901767; + +} + +// Contains a list of firewalls. +message FirewallList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Firewall resources. + repeated Firewall items = 100526016; + + // [Output Only] Type of resource. Always compute#firewallList for lists of firewalls. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// The available logging options for a firewall rule. +message FirewallLogConfig { + // This field can only be specified for a particular firewall rule if logging is enabled for that rule. This field denotes whether to include or exclude metadata for firewall logs. + enum Metadata { + // A value indicating that the enum field is not set. + UNDEFINED_METADATA = 0; + + EXCLUDE_ALL_METADATA = 334519954; + + INCLUDE_ALL_METADATA = 164619908; + + } + + // This field denotes whether to enable logging for a particular firewall rule. + optional bool enable = 311764355; + + // This field can only be specified for a particular firewall rule if logging is enabled for that rule. This field denotes whether to include or exclude metadata for firewall logs. + // Check the Metadata enum for the list of possible values. + optional string metadata = 86866735; + +} + +// +message FirewallPoliciesListAssociationsResponse { + // A list of associations. + repeated FirewallPolicyAssociation associations = 508736530; + + // [Output Only] Type of firewallPolicy associations. Always compute#FirewallPoliciesListAssociations for lists of firewallPolicy associations. + optional string kind = 3292052; + +} + +// Represents a Firewall Policy resource. +message FirewallPolicy { + // A list of associations that belong to this firewall policy. + repeated FirewallPolicyAssociation associations = 508736530; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Deprecated, please use short name instead. User-provided name of the Organization firewall policy. The name should be unique in the organization in which the firewall policy is created. This field is not applicable to network firewall policies. This name must be set on creation and cannot be changed. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string display_name = 4473832; + + // Specifies a fingerprint for this resource, which is essentially a hash of the metadata's contents and used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update metadata. You must always provide an up-to-date fingerprint hash in order to update or change metadata, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make get() request to the firewall policy. + optional string fingerprint = 234678500; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output only] Type of the resource. Always compute#firewallPolicyfor firewall policies + optional string kind = 3292052; + + // Name of the resource. For Organization Firewall Policies it's a [Output Only] numeric ID allocated by Google Cloud which uniquely identifies the Organization Firewall Policy. + optional string name = 3373707; + + // [Output Only] The parent of the firewall policy. This field is not applicable to network firewall policies. + optional string parent = 78317738; + + // [Output Only] URL of the region where the regional firewall policy resides. This field is not applicable to global firewall policies. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string region = 138946292; + + // [Output Only] Total count of all firewall policy rule tuples. A firewall policy can not exceed a set number of tuples. + optional int32 rule_tuple_count = 388342037; + + // A list of rules that belong to this policy. There must always be a default rule (rule with priority 2147483647 and match "*"). If no rules are provided when creating a firewall policy, a default rule with action "allow" will be added. + repeated FirewallPolicyRule rules = 108873975; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] Server-defined URL for this resource with the resource id. + optional string self_link_with_id = 44520962; + + // User-provided name of the Organization firewall policy. The name should be unique in the organization in which the firewall policy is created. This field is not applicable to network firewall policies. This name must be set on creation and cannot be changed. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string short_name = 492051566; + +} + +// +message FirewallPolicyAssociation { + // The target that the firewall policy is attached to. + optional string attachment_target = 175773741; + + // [Output Only] Deprecated, please use short name instead. The display name of the firewall policy of the association. + optional string display_name = 4473832; + + // [Output Only] The firewall policy ID of the association. + optional string firewall_policy_id = 357211849; + + // The name for an association. + optional string name = 3373707; + + // [Output Only] The short name of the firewall policy of the association. + optional string short_name = 492051566; + +} + +// +message FirewallPolicyList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of FirewallPolicy resources. + repeated FirewallPolicy items = 100526016; + + // [Output Only] Type of resource. Always compute#firewallPolicyList for listsof FirewallPolicies + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Represents a rule that describes one or more match conditions along with the action to be taken when traffic matches this condition (allow or deny). +message FirewallPolicyRule { + // The direction in which this rule applies. + enum Direction { + // A value indicating that the enum field is not set. + UNDEFINED_DIRECTION = 0; + + EGRESS = 432880501; + + INGRESS = 516931221; + + } + + // The Action to perform when the client connection triggers the rule. Valid actions are "allow", "deny" and "goto_next". + optional string action = 187661878; + + // An optional description for this resource. + optional string description = 422937596; + + // The direction in which this rule applies. + // Check the Direction enum for the list of possible values. + optional string direction = 111150975; + + // Denotes whether the firewall policy rule is disabled. When set to true, the firewall policy rule is not enforced and traffic behaves as if it did not exist. If this is unspecified, the firewall policy rule will be enabled. + optional bool disabled = 270940796; + + // Denotes whether to enable logging for a particular rule. If logging is enabled, logs will be exported to the configured export destination in Stackdriver. Logs may be exported to BigQuery or Pub/Sub. Note: you cannot enable logging on "goto_next" rules. + optional bool enable_logging = 295396515; + + // [Output only] Type of the resource. Always compute#firewallPolicyRule for firewall policy rules + optional string kind = 3292052; + + // A match condition that incoming traffic is evaluated against. If it evaluates to true, the corresponding 'action' is enforced. + optional FirewallPolicyRuleMatcher match = 103668165; + + // An integer indicating the priority of a rule in the list. The priority must be a positive value between 0 and 2147483647. Rules are evaluated from highest to lowest priority where 0 is the highest priority and 2147483647 is the lowest prority. + optional int32 priority = 445151652; + + // An optional name for the rule. This field is not a unique identifier and can be updated. + optional string rule_name = 55286254; + + // [Output Only] Calculation of the complexity of a single firewall policy rule. + optional int32 rule_tuple_count = 388342037; + + // A list of network resource URLs to which this rule applies. This field allows you to control which network's VMs get this rule. If this field is left blank, all VMs within the organization will receive the rule. + repeated string target_resources = 528230647; + + // A list of secure tags that controls which instances the firewall rule applies to. If targetSecureTag are specified, then the firewall rule applies only to instances in the VPC network that have one of those EFFECTIVE secure tags, if all the target_secure_tag are in INEFFECTIVE state, then this rule will be ignored. targetSecureTag may not be set at the same time as targetServiceAccounts. If neither targetServiceAccounts nor targetSecureTag are specified, the firewall rule applies to all instances on the specified network. Maximum number of target label tags allowed is 256. + repeated FirewallPolicyRuleSecureTag target_secure_tags = 468132403; + + // A list of service accounts indicating the sets of instances that are applied with this rule. + repeated string target_service_accounts = 457639710; + +} + +// Represents a match condition that incoming traffic is evaluated against. Exactly one field must be specified. +message FirewallPolicyRuleMatcher { + // CIDR IP address range. Maximum number of destination CIDR IP ranges allowed is 5000. + repeated string dest_ip_ranges = 337357713; + + // Pairs of IP protocols and ports that the rule should match. + repeated FirewallPolicyRuleMatcherLayer4Config layer4_configs = 373534261; + + // CIDR IP address range. Maximum number of source CIDR IP ranges allowed is 5000. + repeated string src_ip_ranges = 432128083; + + // List of secure tag values, which should be matched at the source of the traffic. For INGRESS rule, if all the srcSecureTag are INEFFECTIVE, and there is no srcIpRange, this rule will be ignored. Maximum number of source tag values allowed is 256. + repeated FirewallPolicyRuleSecureTag src_secure_tags = 508791302; + +} + +// +message FirewallPolicyRuleMatcherLayer4Config { + // The IP protocol to which this rule applies. The protocol type is required when creating a firewall rule. This value can either be one of the following well known protocol strings (tcp, udp, icmp, esp, ah, ipip, sctp), or the IP protocol number. + optional string ip_protocol = 475958960; + + // An optional list of ports to which this rule applies. This field is only applicable for UDP or TCP protocol. Each entry must be either an integer or a range. If not specified, this rule applies to connections through any port. Example inputs include: ["22"], ["80","443"], and ["12345-12349"]. + repeated string ports = 106854418; + +} + +// +message FirewallPolicyRuleSecureTag { + // [Output Only] State of the secure tag, either `EFFECTIVE` or `INEFFECTIVE`. A secure tag is `INEFFECTIVE` when it is deleted or its network is deleted. + enum State { + // A value indicating that the enum field is not set. + UNDEFINED_STATE = 0; + + EFFECTIVE = 244201863; + + INEFFECTIVE = 304458242; + + } + + // Name of the secure tag, created with TagManager's TagValue API. + optional string name = 3373707; + + // [Output Only] State of the secure tag, either `EFFECTIVE` or `INEFFECTIVE`. A secure tag is `INEFFECTIVE` when it is deleted or its network is deleted. + // Check the State enum for the list of possible values. + optional string state = 109757585; + +} + +// Encapsulates numeric value that can be either absolute or relative. +message FixedOrPercent { + // [Output Only] Absolute value of VM instances calculated based on the specific mode. - If the value is fixed, then the calculated value is equal to the fixed value. - If the value is a percent, then the calculated value is percent/100 * targetSize. For example, the calculated value of a 80% of a managed instance group with 150 instances would be (80/100 * 150) = 120 VM instances. If there is a remainder, the number is rounded. + optional int32 calculated = 472082878; + + // Specifies a fixed number of VM instances. This must be a positive integer. + optional int32 fixed = 97445748; + + // Specifies a percentage of instances between 0 to 100%, inclusive. For example, specify 80 for 80%. + optional int32 percent = 394814533; + +} + +// Represents a Forwarding Rule resource. Forwarding rule resources in Google Cloud can be either regional or global in scope: * [Global](https://cloud.google.com/compute/docs/reference/rest/v1/globalForwardingRules) * [Regional](https://cloud.google.com/compute/docs/reference/rest/v1/forwardingRules) A forwarding rule and its corresponding IP address represent the frontend configuration of a Google Cloud Platform load balancer. Forwarding rules can also reference target instances and Cloud VPN Classic gateways (targetVpnGateway). For more information, read Forwarding rule concepts and Using protocol forwarding. +message ForwardingRule { + // The IP protocol to which this rule applies. For protocol forwarding, valid options are TCP, UDP, ESP, AH, SCTP, ICMP and L3_DEFAULT. The valid IP protocols are different for different load balancing products as described in [Load balancing features](https://cloud.google.com/load-balancing/docs/features#protocols_from_the_load_balancer_to_the_backends). + enum IPProtocolEnum { + // A value indicating that the enum field is not set. + UNDEFINED_I_P_PROTOCOL_ENUM = 0; + + AH = 2087; + + ESP = 68962; + + ICMP = 2241597; + + L3_DEFAULT = 48151369; + + SCTP = 2539724; + + TCP = 82881; + + UDP = 83873; + + } + + // The IP Version that will be used by this forwarding rule. Valid options are IPV4 or IPV6. + enum IpVersion { + // A value indicating that the enum field is not set. + UNDEFINED_IP_VERSION = 0; + + IPV4 = 2254341; + + IPV6 = 2254343; + + UNSPECIFIED_VERSION = 21850000; + + } + + // Specifies the forwarding rule type. For more information about forwarding rules, refer to Forwarding rule concepts. + enum LoadBalancingScheme { + // A value indicating that the enum field is not set. + UNDEFINED_LOAD_BALANCING_SCHEME = 0; + + EXTERNAL = 35607499; + + EXTERNAL_MANAGED = 512006923; + + INTERNAL = 279295677; + + INTERNAL_MANAGED = 37350397; + + INTERNAL_SELF_MANAGED = 236211150; + + INVALID = 530283991; + + } + + // This signifies the networking tier used for configuring this load balancer and can only take the following values: PREMIUM, STANDARD. For regional ForwardingRule, the valid values are PREMIUM and STANDARD. For GlobalForwardingRule, the valid value is PREMIUM. If this field is not specified, it is assumed to be PREMIUM. If IPAddress is specified, this value must be equal to the networkTier of the Address. + enum NetworkTier { + // A value indicating that the enum field is not set. + UNDEFINED_NETWORK_TIER = 0; + + // Public internet quality with fixed bandwidth. + FIXED_STANDARD = 310464328; + + // High quality, Google-grade network tier, support for all networking products. + PREMIUM = 399530551; + + // Public internet quality, only limited support for other networking products. + STANDARD = 484642493; + + // (Output only) Temporary tier for FIXED_STANDARD when fixed standard tier is expired or not configured. + STANDARD_OVERRIDES_FIXED_STANDARD = 465847234; + + } + + // + enum PscConnectionStatus { + // A value indicating that the enum field is not set. + UNDEFINED_PSC_CONNECTION_STATUS = 0; + + // The connection has been accepted by the producer. + ACCEPTED = 246714279; + + // The connection has been closed by the producer and will not serve traffic going forward. + CLOSED = 380163436; + + // The connection has been accepted by the producer, but the producer needs to take further action before the forwarding rule can serve traffic. + NEEDS_ATTENTION = 344491452; + + // The connection is pending acceptance by the producer. + PENDING = 35394935; + + // The connection has been rejected by the producer. + REJECTED = 174130302; + + STATUS_UNSPECIFIED = 42133066; + + } + + // IP address for which this forwarding rule accepts traffic. When a client sends traffic to this IP address, the forwarding rule directs the traffic to the referenced target or backendService. While creating a forwarding rule, specifying an IPAddress is required under the following circumstances: - When the target is set to targetGrpcProxy and validateForProxyless is set to true, the IPAddress should be set to 0.0.0.0. - When the target is a Private Service Connect Google APIs bundle, you must specify an IPAddress. Otherwise, you can optionally specify an IP address that references an existing static (reserved) IP address resource. When omitted, Google Cloud assigns an ephemeral IP address. Use one of the following formats to specify an IP address while creating a forwarding rule: * IP address number, as in `100.1.2.3` * IPv6 address range, as in `2600:1234::/96` * Full resource URL, as in https://www.googleapis.com/compute/v1/projects/ project_id/regions/region/addresses/address-name * Partial URL or by name, as in: - projects/project_id/regions/region/addresses/address-name - regions/region/addresses/address-name - global/addresses/address-name - address-name The forwarding rule's target or backendService, and in most cases, also the loadBalancingScheme, determine the type of IP address that you can use. For detailed information, see [IP address specifications](https://cloud.google.com/load-balancing/docs/forwarding-rule-concepts#ip_address_specifications). When reading an IPAddress, the API always returns the IP address number. + optional string I_p_address = 42976943; + + // The IP protocol to which this rule applies. For protocol forwarding, valid options are TCP, UDP, ESP, AH, SCTP, ICMP and L3_DEFAULT. The valid IP protocols are different for different load balancing products as described in [Load balancing features](https://cloud.google.com/load-balancing/docs/features#protocols_from_the_load_balancer_to_the_backends). + // Check the IPProtocolEnum enum for the list of possible values. + optional string I_p_protocol = 488094525; + + // This field can only be used: - If IPProtocol is one of TCP, UDP, or SCTP. - By internal TCP/UDP load balancers, backend service-based network load balancers, and internal and external protocol forwarding. Set this field to true to allow packets addressed to any port or packets lacking destination port information (for example, UDP fragments after the first fragment) to be forwarded to the backends configured with this forwarding rule. The ports, port_range, and allPorts fields are mutually exclusive. + optional bool all_ports = 445175796; + + // This field is used along with the backend_service field for internal load balancing or with the target field for internal TargetInstance. If the field is set to TRUE, clients can access ILB from all regions. Otherwise only allows access from clients in the same region as the internal load balancer. + optional bool allow_global_access = 499409674; + + // Identifies the backend service to which the forwarding rule sends traffic. Required for Internal TCP/UDP Load Balancing and Network Load Balancing; must be omitted for all other load balancer types. + optional string backend_service = 306946058; + + // [Output Only] The URL for the corresponding base Forwarding Rule. By base Forwarding Rule, we mean the Forwarding Rule that has the same IP address, protocol, and port settings with the current Forwarding Rule, but without sourceIPRanges specified. Always empty if the current Forwarding Rule does not have sourceIPRanges specified. + optional string base_forwarding_rule = 524873104; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a ForwardingRule. Include the fingerprint in patch request to ensure that you do not overwrite changes that were applied from another concurrent request. To see the latest fingerprint, make a get() request to retrieve a ForwardingRule. + optional string fingerprint = 234678500; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // The IP Version that will be used by this forwarding rule. Valid options are IPV4 or IPV6. + // Check the IpVersion enum for the list of possible values. + optional string ip_version = 294959552; + + // Indicates whether or not this load balancer can be used as a collector for packet mirroring. To prevent mirroring loops, instances behind this load balancer will not have their traffic mirrored even if a PacketMirroring rule applies to them. This can only be set to true for load balancers that have their loadBalancingScheme set to INTERNAL. + optional bool is_mirroring_collector = 119255164; + + // [Output Only] Type of the resource. Always compute#forwardingRule for Forwarding Rule resources. + optional string kind = 3292052; + + // A fingerprint for the labels being applied to this resource, which is essentially a hash of the labels set used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update labels. You must always provide an up-to-date fingerprint hash in order to update or change labels, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve a ForwardingRule. + optional string label_fingerprint = 178124825; + + // Labels for this resource. These can only be added or modified by the setLabels method. Each label key/value pair must comply with RFC1035. Label values may be empty. + map labels = 500195327; + + // Specifies the forwarding rule type. For more information about forwarding rules, refer to Forwarding rule concepts. + // Check the LoadBalancingScheme enum for the list of possible values. + optional string load_balancing_scheme = 363890244; + + // Opaque filter criteria used by load balancer to restrict routing configuration to a limited set of xDS compliant clients. In their xDS requests to load balancer, xDS clients present node metadata. When there is a match, the relevant configuration is made available to those proxies. Otherwise, all the resources (e.g. TargetHttpProxy, UrlMap) referenced by the ForwardingRule are not visible to those proxies. For each metadataFilter in this list, if its filterMatchCriteria is set to MATCH_ANY, at least one of the filterLabels must match the corresponding label provided in the metadata. If its filterMatchCriteria is set to MATCH_ALL, then all of its filterLabels must match with corresponding labels provided in the metadata. If multiple metadataFilters are specified, all of them need to be satisfied in order to be considered a match. metadataFilters specified here will be applifed before those specified in the UrlMap that this ForwardingRule references. metadataFilters only applies to Loadbalancers that have their loadBalancingScheme set to INTERNAL_SELF_MANAGED. + repeated MetadataFilter metadata_filters = 464725739; + + // Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. For Private Service Connect forwarding rules that forward traffic to Google APIs, the forwarding rule name must be a 1-20 characters string with lowercase letters and numbers and must start with a letter. + optional string name = 3373707; + + // This field is not used for external load balancing. For Internal TCP/UDP Load Balancing, this field identifies the network that the load balanced IP should belong to for this Forwarding Rule. If this field is not specified, the default network will be used. For Private Service Connect forwarding rules that forward traffic to Google APIs, a network must be provided. + optional string network = 232872494; + + // This signifies the networking tier used for configuring this load balancer and can only take the following values: PREMIUM, STANDARD. For regional ForwardingRule, the valid values are PREMIUM and STANDARD. For GlobalForwardingRule, the valid value is PREMIUM. If this field is not specified, it is assumed to be PREMIUM. If IPAddress is specified, this value must be equal to the networkTier of the Address. + // Check the NetworkTier enum for the list of possible values. + optional string network_tier = 517397843; + + // This is used in PSC consumer ForwardingRule to control whether it should try to auto-generate a DNS zone or not. Non-PSC forwarding rules do not use this field. + optional bool no_automate_dns_zone = 64546991; + + // This field can only be used: - If IPProtocol is one of TCP, UDP, or SCTP. - By backend service-based network load balancers, target pool-based network load balancers, internal proxy load balancers, external proxy load balancers, Traffic Director, external protocol forwarding, and Classic VPN. Some products have restrictions on what ports can be used. See port specifications for details. Only packets addressed to ports in the specified range will be forwarded to the backends configured with this forwarding rule. The ports, port_range, and allPorts fields are mutually exclusive. For external forwarding rules, two or more forwarding rules cannot use the same [IPAddress, IPProtocol] pair, and cannot have overlapping portRanges. For internal forwarding rules within the same VPC network, two or more forwarding rules cannot use the same [IPAddress, IPProtocol] pair, and cannot have overlapping portRanges. @pattern: \\d+(?:-\\d+)? + optional string port_range = 217518079; + + // This field can only be used: - If IPProtocol is one of TCP, UDP, or SCTP. - By internal TCP/UDP load balancers, backend service-based network load balancers, and internal protocol forwarding. You can specify a list of up to five ports by number, separated by commas. The ports can be contiguous or discontiguous. Only packets addressed to these ports will be forwarded to the backends configured with this forwarding rule. For external forwarding rules, two or more forwarding rules cannot use the same [IPAddress, IPProtocol] pair, and cannot share any values defined in ports. For internal forwarding rules within the same VPC network, two or more forwarding rules cannot use the same [IPAddress, IPProtocol] pair, and cannot share any values defined in ports. The ports, port_range, and allPorts fields are mutually exclusive. @pattern: \\d+(?:-\\d+)? + repeated string ports = 106854418; + + // [Output Only] The PSC connection id of the PSC Forwarding Rule. + optional uint64 psc_connection_id = 292082397; + + // + // Check the PscConnectionStatus enum for the list of possible values. + optional string psc_connection_status = 184149172; + + // [Output Only] URL of the region where the regional forwarding rule resides. This field is not applicable to global forwarding rules. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // Service Directory resources to register this forwarding rule with. Currently, only supports a single Service Directory resource. + repeated ForwardingRuleServiceDirectoryRegistration service_directory_registrations = 223549694; + + // An optional prefix to the service name for this Forwarding Rule. If specified, the prefix is the first label of the fully qualified service name. The label must be 1-63 characters long, and comply with RFC1035. Specifically, the label must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. This field is only used for internal load balancing. + optional string service_label = 417008874; + + // [Output Only] The internal fully qualified service name for this Forwarding Rule. This field is only used for internal load balancing. + optional string service_name = 359880149; + + // If not empty, this Forwarding Rule will only forward the traffic when the source IP address matches one of the IP addresses or CIDR ranges set here. Note that a Forwarding Rule can only have up to 64 source IP ranges, and this field can only be used with a regional Forwarding Rule whose scheme is EXTERNAL. Each source_ip_range entry should be either an IP address (for example, 1.2.3.4) or a CIDR range (for example, 1.2.3.0/24). + repeated string source_ip_ranges = 111563210; + + // This field identifies the subnetwork that the load balanced IP should belong to for this Forwarding Rule, used in internal load balancing and network load balancing with IPv6. If the network specified is in auto subnet mode, this field is optional. However, a subnetwork must be specified if the network is in custom subnet mode or when creating external forwarding rule with IPv6. + optional string subnetwork = 307827694; + + // The URL of the target resource to receive the matched traffic. For regional forwarding rules, this target must be in the same region as the forwarding rule. For global forwarding rules, this target must be a global load balancing resource. The forwarded traffic must be of a type appropriate to the target object. - For load balancers, see the "Target" column in [Port specifications](https://cloud.google.com/load-balancing/docs/forwarding-rule-concepts#ip_address_specifications). - For Private Service Connect forwarding rules that forward traffic to Google APIs, provide the name of a supported Google API bundle: - vpc-sc - APIs that support VPC Service Controls. - all-apis - All supported Google APIs. - For Private Service Connect forwarding rules that forward traffic to managed services, the target must be a service attachment. + optional string target = 192835985; + +} + +// +message ForwardingRuleAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of ForwardingRulesScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#forwardingRuleAggregatedList for lists of forwarding rules. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of ForwardingRule resources. +message ForwardingRuleList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of ForwardingRule resources. + repeated ForwardingRule items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message ForwardingRuleReference { + optional string forwarding_rule = 269964030; + +} + +// Describes the auto-registration of the Forwarding Rule to Service Directory. The region and project of the Service Directory resource generated from this registration will be the same as this Forwarding Rule. +message ForwardingRuleServiceDirectoryRegistration { + // Service Directory namespace to register the forwarding rule under. + optional string namespace = 178476379; + + // Service Directory service to register the forwarding rule under. + optional string service = 373540533; + + // [Optional] Service Directory region to register this global forwarding rule under. Default to "us-central1". Only used for PSC for Google APIs. All PSC for Google APIs Forwarding Rules on the same network should use the same Service Directory region. + optional string service_directory_region = 74030416; + +} + +// +message ForwardingRulesScopedList { + // A list of forwarding rules contained in this scope. + repeated ForwardingRule forwarding_rules = 315821365; + + // Informational warning which replaces the list of forwarding rules when the list is empty. + optional Warning warning = 50704284; + +} + +// +message GRPCHealthCheck { + // Specifies how a port is selected for health checking. Can be one of the following values: USE_FIXED_PORT: Specifies a port number explicitly using the port field in the health check. Supported by backend services for pass-through load balancers and backend services for proxy load balancers. Not supported by target pools. The health check supports all backends supported by the backend service provided the backend can be health checked. For example, GCE_VM_IP network endpoint groups, GCE_VM_IP_PORT network endpoint groups, and instance group backends. USE_NAMED_PORT: Not supported. USE_SERVING_PORT: Provides an indirect method of specifying the health check port by referring to the backend service. Only supported by backend services for proxy load balancers. Not supported by target pools. Not supported by backend services for pass-through load balancers. Supports all backends that can be health checked; for example, GCE_VM_IP_PORT network endpoint groups and instance group backends. For GCE_VM_IP_PORT network endpoint group backends, the health check uses the port number specified for each endpoint in the network endpoint group. For instance group backends, the health check uses the port number determined by looking up the backend service's named port in the instance group's list of named ports. + enum PortSpecification { + // A value indicating that the enum field is not set. + UNDEFINED_PORT_SPECIFICATION = 0; + + // The port number in the health check's port is used for health checking. Applies to network endpoint group and instance group backends. + USE_FIXED_PORT = 190235748; + + // Not supported. + USE_NAMED_PORT = 349300671; + + // For network endpoint group backends, the health check uses the port number specified on each endpoint in the network endpoint group. For instance group backends, the health check uses the port number specified for the backend service's named port defined in the instance group's named ports. + USE_SERVING_PORT = 362637516; + + } + + // The gRPC service name for the health check. This field is optional. The value of grpc_service_name has the following meanings by convention: - Empty service_name means the overall status of all services at the backend. - Non-empty service_name means the health of that gRPC service, as defined by the owner of the service. The grpc_service_name can only be ASCII. + optional string grpc_service_name = 136533078; + + // The TCP port number to which the health check prober sends packets. Valid values are 1 through 65535. + optional int32 port = 3446913; + + // Not supported. + optional string port_name = 41534345; + + // Specifies how a port is selected for health checking. Can be one of the following values: USE_FIXED_PORT: Specifies a port number explicitly using the port field in the health check. Supported by backend services for pass-through load balancers and backend services for proxy load balancers. Not supported by target pools. The health check supports all backends supported by the backend service provided the backend can be health checked. For example, GCE_VM_IP network endpoint groups, GCE_VM_IP_PORT network endpoint groups, and instance group backends. USE_NAMED_PORT: Not supported. USE_SERVING_PORT: Provides an indirect method of specifying the health check port by referring to the backend service. Only supported by backend services for proxy load balancers. Not supported by target pools. Not supported by backend services for pass-through load balancers. Supports all backends that can be health checked; for example, GCE_VM_IP_PORT network endpoint groups and instance group backends. For GCE_VM_IP_PORT network endpoint group backends, the health check uses the port number specified for each endpoint in the network endpoint group. For instance group backends, the health check uses the port number determined by looking up the backend service's named port in the instance group's list of named ports. + // Check the PortSpecification enum for the list of possible values. + optional string port_specification = 51590597; + +} + +// A request message for AcceleratorTypes.Get. See the method description for details. +message GetAcceleratorTypeRequest { + // Name of the accelerator type to return. + string accelerator_type = 138031246 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Addresses.Get. See the method description for details. +message GetAddressRequest { + // Name of the address resource to return. + string address = 462920692 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for FirewallPolicies.GetAssociation. See the method description for details. +message GetAssociationFirewallPolicyRequest { + // Name of the firewall policy to which the queried rule belongs. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The name of the association to get from the firewall policy. + optional string name = 3373707; + +} + +// A request message for NetworkFirewallPolicies.GetAssociation. See the method description for details. +message GetAssociationNetworkFirewallPolicyRequest { + // Name of the firewall policy to which the queried association belongs. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The name of the association to get from the firewall policy. + optional string name = 3373707; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionNetworkFirewallPolicies.GetAssociation. See the method description for details. +message GetAssociationRegionNetworkFirewallPolicyRequest { + // Name of the firewall policy to which the queried association belongs. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The name of the association to get from the firewall policy. + optional string name = 3373707; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Autoscalers.Get. See the method description for details. +message GetAutoscalerRequest { + // Name of the autoscaler to return. + string autoscaler = 517258967 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for BackendBuckets.Get. See the method description for details. +message GetBackendBucketRequest { + // Name of the BackendBucket resource to return. + string backend_bucket = 91714037 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for BackendServices.Get. See the method description for details. +message GetBackendServiceRequest { + // Name of the BackendService resource to return. + string backend_service = 306946058 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Interconnects.GetDiagnostics. See the method description for details. +message GetDiagnosticsInterconnectRequest { + // Name of the interconnect resource to query. + string interconnect = 224601230 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Disks.Get. See the method description for details. +message GetDiskRequest { + // Name of the persistent disk to return. + string disk = 3083677 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for DiskTypes.Get. See the method description for details. +message GetDiskTypeRequest { + // Name of the disk type to return. + string disk_type = 93009052 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Instances.GetEffectiveFirewalls. See the method description for details. +message GetEffectiveFirewallsInstanceRequest { + // Name of the instance scoping this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The name of the network interface to get the effective firewalls. + string network_interface = 365387880 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Networks.GetEffectiveFirewalls. See the method description for details. +message GetEffectiveFirewallsNetworkRequest { + // Name of the network for this request. + string network = 232872494 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionNetworkFirewallPolicies.GetEffectiveFirewalls. See the method description for details. +message GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest { + // Network reference + string network = 232872494 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ExternalVpnGateways.Get. See the method description for details. +message GetExternalVpnGatewayRequest { + // Name of the externalVpnGateway to return. + string external_vpn_gateway = 109898629 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for FirewallPolicies.Get. See the method description for details. +message GetFirewallPolicyRequest { + // Name of the firewall policy to get. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Firewalls.Get. See the method description for details. +message GetFirewallRequest { + // Name of the firewall rule to return. + string firewall = 511016192 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ForwardingRules.Get. See the method description for details. +message GetForwardingRuleRequest { + // Name of the ForwardingRule resource to return. + string forwarding_rule = 269964030 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Images.GetFromFamily. See the method description for details. +message GetFromFamilyImageRequest { + // Name of the image family to search for. + string family = 328751972 [(google.api.field_behavior) = REQUIRED]; + + // The image project that the image belongs to. For example, to get a CentOS image, specify centos-cloud as the image project. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for GlobalAddresses.Get. See the method description for details. +message GetGlobalAddressRequest { + // Name of the address resource to return. + string address = 462920692 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for GlobalForwardingRules.Get. See the method description for details. +message GetGlobalForwardingRuleRequest { + // Name of the ForwardingRule resource to return. + string forwarding_rule = 269964030 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for GlobalNetworkEndpointGroups.Get. See the method description for details. +message GetGlobalNetworkEndpointGroupRequest { + // The name of the network endpoint group. It should comply with RFC1035. + string network_endpoint_group = 433907078 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for GlobalOperations.Get. See the method description for details. +message GetGlobalOperationRequest { + // Name of the Operations resource to return. + string operation = 52090215 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_response_field) = "name" + ]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for GlobalOrganizationOperations.Get. See the method description for details. +message GetGlobalOrganizationOperationRequest { + // Name of the Operations resource to return. + string operation = 52090215 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_response_field) = "name" + ]; + + // Parent ID for this request. + optional string parent_id = 459714768; + +} + +// A request message for GlobalPublicDelegatedPrefixes.Get. See the method description for details. +message GetGlobalPublicDelegatedPrefixeRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the PublicDelegatedPrefix resource to return. + string public_delegated_prefix = 204238440 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Instances.GetGuestAttributes. See the method description for details. +message GetGuestAttributesInstanceRequest { + // Name of the instance scoping this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Specifies the guest attributes path to be queried. + optional string query_path = 368591164; + + // Specifies the key for the guest attributes entry. + optional string variable_key = 164364828; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for BackendServices.GetHealth. See the method description for details. +message GetHealthBackendServiceRequest { + // Name of the BackendService resource to which the queried instance belongs. + string backend_service = 306946058 [(google.api.field_behavior) = REQUIRED]; + + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + ResourceGroupReference resource_group_reference_resource = 112951123 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for HealthChecks.Get. See the method description for details. +message GetHealthCheckRequest { + // Name of the HealthCheck resource to return. + string health_check = 308876645 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionBackendServices.GetHealth. See the method description for details. +message GetHealthRegionBackendServiceRequest { + // Name of the BackendService resource for which to get health. + string backend_service = 306946058 [(google.api.field_behavior) = REQUIRED]; + + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + ResourceGroupReference resource_group_reference_resource = 112951123 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetPools.GetHealth. See the method description for details. +message GetHealthTargetPoolRequest { + // The body resource for this request + InstanceReference instance_reference_resource = 292926060 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetPool resource to which the queried instance belongs. + string target_pool = 62796298 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for BackendServices.GetIamPolicy. See the method description for details. +message GetIamPolicyBackendServiceRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Disks.GetIamPolicy. See the method description for details. +message GetIamPolicyDiskRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for FirewallPolicies.GetIamPolicy. See the method description for details. +message GetIamPolicyFirewallPolicyRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Images.GetIamPolicy. See the method description for details. +message GetIamPolicyImageRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Instances.GetIamPolicy. See the method description for details. +message GetIamPolicyInstanceRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InstanceTemplates.GetIamPolicy. See the method description for details. +message GetIamPolicyInstanceTemplateRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Licenses.GetIamPolicy. See the method description for details. +message GetIamPolicyLicenseRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for MachineImages.GetIamPolicy. See the method description for details. +message GetIamPolicyMachineImageRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NetworkAttachments.GetIamPolicy. See the method description for details. +message GetIamPolicyNetworkAttachmentRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NetworkFirewallPolicies.GetIamPolicy. See the method description for details. +message GetIamPolicyNetworkFirewallPolicyRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NodeGroups.GetIamPolicy. See the method description for details. +message GetIamPolicyNodeGroupRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NodeTemplates.GetIamPolicy. See the method description for details. +message GetIamPolicyNodeTemplateRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionBackendServices.GetIamPolicy. See the method description for details. +message GetIamPolicyRegionBackendServiceRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionDisks.GetIamPolicy. See the method description for details. +message GetIamPolicyRegionDiskRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionNetworkFirewallPolicies.GetIamPolicy. See the method description for details. +message GetIamPolicyRegionNetworkFirewallPolicyRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Reservations.GetIamPolicy. See the method description for details. +message GetIamPolicyReservationRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ResourcePolicies.GetIamPolicy. See the method description for details. +message GetIamPolicyResourcePolicyRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ServiceAttachments.GetIamPolicy. See the method description for details. +message GetIamPolicyServiceAttachmentRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Snapshots.GetIamPolicy. See the method description for details. +message GetIamPolicySnapshotRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Subnetworks.GetIamPolicy. See the method description for details. +message GetIamPolicySubnetworkRequest { + // Requested IAM Policy version. + optional int32 options_requested_policy_version = 499220029; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ImageFamilyViews.Get. See the method description for details. +message GetImageFamilyViewRequest { + // Name of the image family to search for. + string family = 328751972 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Images.Get. See the method description for details. +message GetImageRequest { + // Name of the image resource to return. + string image = 100313435 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InstanceGroupManagers.Get. See the method description for details. +message GetInstanceGroupManagerRequest { + // The name of the managed instance group. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone where the managed instance group is located. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InstanceGroups.Get. See the method description for details. +message GetInstanceGroupRequest { + // The name of the instance group. + string instance_group = 81095253 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone where the instance group is located. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Instances.Get. See the method description for details. +message GetInstanceRequest { + // Name of the instance resource to return. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InstanceTemplates.Get. See the method description for details. +message GetInstanceTemplateRequest { + // The name of the instance template. + string instance_template = 309248228 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InterconnectAttachments.Get. See the method description for details. +message GetInterconnectAttachmentRequest { + // Name of the interconnect attachment to return. + string interconnect_attachment = 308135284 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InterconnectLocations.Get. See the method description for details. +message GetInterconnectLocationRequest { + // Name of the interconnect location to return. + string interconnect_location = 492235846 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Interconnects.Get. See the method description for details. +message GetInterconnectRequest { + // Name of the interconnect to return. + string interconnect = 224601230 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for LicenseCodes.Get. See the method description for details. +message GetLicenseCodeRequest { + // Number corresponding to the License code resource to return. + string license_code = 1467179 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Licenses.Get. See the method description for details. +message GetLicenseRequest { + // Name of the License resource to return. + string license = 166757441 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for MachineImages.Get. See the method description for details. +message GetMachineImageRequest { + // The name of the machine image. + string machine_image = 69189475 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for MachineTypes.Get. See the method description for details. +message GetMachineTypeRequest { + // Name of the machine type to return. + string machine_type = 227711026 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Routers.GetNatMappingInfo. See the method description for details. +message GetNatMappingInfoRoutersRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // Name of the Router resource to query for Nat Mapping information of VM endpoints. + string router = 148608841 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NetworkAttachments.Get. See the method description for details. +message GetNetworkAttachmentRequest { + // Name of the NetworkAttachment resource to return. + string network_attachment = 224644052 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region of this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NetworkEdgeSecurityServices.Get. See the method description for details. +message GetNetworkEdgeSecurityServiceRequest { + // Name of the network edge security service to get. + string network_edge_security_service = 157011879 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NetworkEndpointGroups.Get. See the method description for details. +message GetNetworkEndpointGroupRequest { + // The name of the network endpoint group. It should comply with RFC1035. + string network_endpoint_group = 433907078 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone where the network endpoint group is located. It should comply with RFC1035. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NetworkFirewallPolicies.Get. See the method description for details. +message GetNetworkFirewallPolicyRequest { + // Name of the firewall policy to get. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Networks.Get. See the method description for details. +message GetNetworkRequest { + // Name of the network to return. + string network = 232872494 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NodeGroups.Get. See the method description for details. +message GetNodeGroupRequest { + // Name of the node group to return. + string node_group = 469958146 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NodeTemplates.Get. See the method description for details. +message GetNodeTemplateRequest { + // Name of the node template to return. + string node_template = 323154455 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NodeTypes.Get. See the method description for details. +message GetNodeTypeRequest { + // Name of the node type to return. + string node_type = 465832791 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for PacketMirrorings.Get. See the method description for details. +message GetPacketMirroringRequest { + // Name of the PacketMirroring resource to return. + string packet_mirroring = 22305996 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Projects.Get. See the method description for details. +message GetProjectRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for PublicAdvertisedPrefixes.Get. See the method description for details. +message GetPublicAdvertisedPrefixeRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the PublicAdvertisedPrefix resource to return. + string public_advertised_prefix = 101874590 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for PublicDelegatedPrefixes.Get. See the method description for details. +message GetPublicDelegatedPrefixeRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the PublicDelegatedPrefix resource to return. + string public_delegated_prefix = 204238440 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region of this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionAutoscalers.Get. See the method description for details. +message GetRegionAutoscalerRequest { + // Name of the autoscaler to return. + string autoscaler = 517258967 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionBackendServices.Get. See the method description for details. +message GetRegionBackendServiceRequest { + // Name of the BackendService resource to return. + string backend_service = 306946058 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionCommitments.Get. See the method description for details. +message GetRegionCommitmentRequest { + // Name of the commitment to return. + string commitment = 482134805 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionDisks.Get. See the method description for details. +message GetRegionDiskRequest { + // Name of the regional persistent disk to return. + string disk = 3083677 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionDiskTypes.Get. See the method description for details. +message GetRegionDiskTypeRequest { + // Name of the disk type to return. + string disk_type = 93009052 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionHealthChecks.Get. See the method description for details. +message GetRegionHealthCheckRequest { + // Name of the HealthCheck resource to return. + string health_check = 308876645 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionHealthCheckServices.Get. See the method description for details. +message GetRegionHealthCheckServiceRequest { + // Name of the HealthCheckService to update. The name must be 1-63 characters long, and comply with RFC1035. + string health_check_service = 408374747 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionInstanceGroupManagers.Get. See the method description for details. +message GetRegionInstanceGroupManagerRequest { + // Name of the managed instance group to return. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionInstanceGroups.Get. See the method description for details. +message GetRegionInstanceGroupRequest { + // Name of the instance group resource to return. + string instance_group = 81095253 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionInstanceTemplates.Get. See the method description for details. +message GetRegionInstanceTemplateRequest { + // The name of the instance template. + string instance_template = 309248228 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionNetworkEndpointGroups.Get. See the method description for details. +message GetRegionNetworkEndpointGroupRequest { + // The name of the network endpoint group. It should comply with RFC1035. + string network_endpoint_group = 433907078 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region where the network endpoint group is located. It should comply with RFC1035. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionNetworkFirewallPolicies.Get. See the method description for details. +message GetRegionNetworkFirewallPolicyRequest { + // Name of the firewall policy to get. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionNotificationEndpoints.Get. See the method description for details. +message GetRegionNotificationEndpointRequest { + // Name of the NotificationEndpoint resource to return. + string notification_endpoint = 376807017 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionOperations.Get. See the method description for details. +message GetRegionOperationRequest { + // Name of the Operations resource to return. + string operation = 52090215 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_response_field) = "name" + ]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Regions.Get. See the method description for details. +message GetRegionRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region resource to return. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionSecurityPolicies.Get. See the method description for details. +message GetRegionSecurityPolicyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the security policy to get. + string security_policy = 171082513 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionSslCertificates.Get. See the method description for details. +message GetRegionSslCertificateRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the SslCertificate resource to return. + string ssl_certificate = 46443492 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionSslPolicies.Get. See the method description for details. +message GetRegionSslPolicyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the SSL policy to update. The name must be 1-63 characters long, and comply with RFC1035. + string ssl_policy = 295190213 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionTargetHttpProxies.Get. See the method description for details. +message GetRegionTargetHttpProxyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetHttpProxy resource to return. + string target_http_proxy = 206872421 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionTargetHttpsProxies.Get. See the method description for details. +message GetRegionTargetHttpsProxyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetHttpsProxy resource to return. + string target_https_proxy = 52336748 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionTargetTcpProxies.Get. See the method description for details. +message GetRegionTargetTcpProxyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetTcpProxy resource to return. + string target_tcp_proxy = 503065442 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionUrlMaps.Get. See the method description for details. +message GetRegionUrlMapRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the UrlMap resource to return. + string url_map = 367020684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Reservations.Get. See the method description for details. +message GetReservationRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the reservation to retrieve. + string reservation = 47530956 [(google.api.field_behavior) = REQUIRED]; + + // Name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ResourcePolicies.Get. See the method description for details. +message GetResourcePolicyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the resource policy to retrieve. + string resource_policy = 159240835 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Routes.Get. See the method description for details. +message GetRouteRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the Route resource to return. + string route = 108704329 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Routers.Get. See the method description for details. +message GetRouterRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the Router resource to return. + string router = 148608841 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Routers.GetRouterStatus. See the method description for details. +message GetRouterStatusRouterRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the Router resource to query. + string router = 148608841 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for FirewallPolicies.GetRule. See the method description for details. +message GetRuleFirewallPolicyRequest { + // Name of the firewall policy to which the queried rule belongs. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The priority of the rule to get from the firewall policy. + optional int32 priority = 445151652; + +} + +// A request message for NetworkFirewallPolicies.GetRule. See the method description for details. +message GetRuleNetworkFirewallPolicyRequest { + // Name of the firewall policy to which the queried rule belongs. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The priority of the rule to get from the firewall policy. + optional int32 priority = 445151652; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionNetworkFirewallPolicies.GetRule. See the method description for details. +message GetRuleRegionNetworkFirewallPolicyRequest { + // Name of the firewall policy to which the queried rule belongs. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The priority of the rule to get from the firewall policy. + optional int32 priority = 445151652; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for SecurityPolicies.GetRule. See the method description for details. +message GetRuleSecurityPolicyRequest { + // The priority of the rule to get from the security policy. + optional int32 priority = 445151652; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the security policy to which the queried rule belongs. + string security_policy = 171082513 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Instances.GetScreenshot. See the method description for details. +message GetScreenshotInstanceRequest { + // Name of the instance scoping this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for SecurityPolicies.Get. See the method description for details. +message GetSecurityPolicyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the security policy to get. + string security_policy = 171082513 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Instances.GetSerialPortOutput. See the method description for details. +message GetSerialPortOutputInstanceRequest { + // Name of the instance for this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Specifies which COM or serial port to retrieve data from. + optional int32 port = 3446913; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Specifies the starting byte position of the output to return. To start with the first byte of output to the specified port, omit this field or set it to `0`. If the output for that byte position is available, this field matches the `start` parameter sent with the request. If the amount of serial console output exceeds the size of the buffer (1 MB), the oldest output is discarded and is no longer available. If the requested start position refers to discarded output, the start position is adjusted to the oldest output still available, and the adjusted start position is returned as the `start` property value. You can also provide a negative start position, which translates to the most recent number of bytes written to the serial port. For example, -3 is interpreted as the most recent 3 bytes written to the serial console. + optional int64 start = 109757538; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ServiceAttachments.Get. See the method description for details. +message GetServiceAttachmentRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region of this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the ServiceAttachment resource to return. + string service_attachment = 338957549 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Instances.GetShieldedInstanceIdentity. See the method description for details. +message GetShieldedInstanceIdentityInstanceRequest { + // Name or id of the instance scoping this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Snapshots.Get. See the method description for details. +message GetSnapshotRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the Snapshot resource to return. + string snapshot = 284874180 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for SslCertificates.Get. See the method description for details. +message GetSslCertificateRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the SslCertificate resource to return. + string ssl_certificate = 46443492 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for SslPolicies.Get. See the method description for details. +message GetSslPolicyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the SSL policy to update. The name must be 1-63 characters long, and comply with RFC1035. + string ssl_policy = 295190213 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for VpnGateways.GetStatus. See the method description for details. +message GetStatusVpnGatewayRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the VPN gateway to return. + string vpn_gateway = 406684153 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Subnetworks.Get. See the method description for details. +message GetSubnetworkRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the Subnetwork resource to return. + string subnetwork = 307827694 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetGrpcProxies.Get. See the method description for details. +message GetTargetGrpcProxyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetGrpcProxy resource to return. + string target_grpc_proxy = 5020283 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetHttpProxies.Get. See the method description for details. +message GetTargetHttpProxyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetHttpProxy resource to return. + string target_http_proxy = 206872421 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetHttpsProxies.Get. See the method description for details. +message GetTargetHttpsProxyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetHttpsProxy resource to return. + string target_https_proxy = 52336748 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetInstances.Get. See the method description for details. +message GetTargetInstanceRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetInstance resource to return. + string target_instance = 289769347 [(google.api.field_behavior) = REQUIRED]; + + // Name of the zone scoping this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetPools.Get. See the method description for details. +message GetTargetPoolRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetPool resource to return. + string target_pool = 62796298 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetSslProxies.Get. See the method description for details. +message GetTargetSslProxyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetSslProxy resource to return. + string target_ssl_proxy = 338795853 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetTcpProxies.Get. See the method description for details. +message GetTargetTcpProxyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetTcpProxy resource to return. + string target_tcp_proxy = 503065442 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetVpnGateways.Get. See the method description for details. +message GetTargetVpnGatewayRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the target VPN gateway to return. + string target_vpn_gateway = 532512843 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for UrlMaps.Get. See the method description for details. +message GetUrlMapRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the UrlMap resource to return. + string url_map = 367020684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for VpnGateways.Get. See the method description for details. +message GetVpnGatewayRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the VPN gateway to return. + string vpn_gateway = 406684153 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for VpnTunnels.Get. See the method description for details. +message GetVpnTunnelRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the VpnTunnel resource to return. + string vpn_tunnel = 143821331 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Projects.GetXpnHost. See the method description for details. +message GetXpnHostProjectRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Projects.GetXpnResources. See the method description for details. +message GetXpnResourcesProjectsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for ZoneOperations.Get. See the method description for details. +message GetZoneOperationRequest { + // Name of the Operations resource to return. + string operation = 52090215 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_response_field) = "name" + ]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Zones.Get. See the method description for details. +message GetZoneRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the zone resource to return. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// +message GlobalNetworkEndpointGroupsAttachEndpointsRequest { + // The list of network endpoints to be attached. + repeated NetworkEndpoint network_endpoints = 149850285; + +} + +// +message GlobalNetworkEndpointGroupsDetachEndpointsRequest { + // The list of network endpoints to be detached. + repeated NetworkEndpoint network_endpoints = 149850285; + +} + +// +message GlobalOrganizationSetPolicyRequest { + // Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings. + repeated Binding bindings = 403251854; + + // Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify the etag. + optional string etag = 3123477; + + // REQUIRED: The complete policy to be applied to the 'resource'. The size of the policy is limited to a few 10s of KB. An empty policy is in general a valid policy but certain services (like Projects) might reject them. + optional Policy policy = 91071794; + +} + +// +message GlobalSetLabelsRequest { + // The fingerprint of the previous set of labels for this resource, used to detect conflicts. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update labels. You must always provide an up-to-date fingerprint hash when updating or changing labels, otherwise the request will fail with error 412 conditionNotMet. Make a get() request to the resource to get the latest fingerprint. + optional string label_fingerprint = 178124825; + + // A list of labels to apply for this resource. Each label must comply with the requirements for labels. For example, "webserver-frontend": "images". A label value can also be empty (e.g. "my-label": ""). + map labels = 500195327; + +} + +// +message GlobalSetPolicyRequest { + // Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify bindings. + repeated Binding bindings = 403251854; + + // Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify the etag. + optional string etag = 3123477; + + // REQUIRED: The complete policy to be applied to the 'resource'. The size of the policy is limited to a few 10s of KB. An empty policy is in general a valid policy but certain services (like Projects) might reject them. + optional Policy policy = 91071794; + +} + +// A guest attributes entry. +message GuestAttributes { + // [Output Only] Type of the resource. Always compute#guestAttributes for guest attributes entry. + optional string kind = 3292052; + + // The path to be queried. This can be the default namespace ('') or a nested namespace ('\/') or a specified key ('\/\'). + optional string query_path = 368591164; + + // [Output Only] The value of the requested queried path. + optional GuestAttributesValue query_value = 157570874; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // The key to search for. + optional string variable_key = 164364828; + + // [Output Only] The value found for the requested key. + optional string variable_value = 124582382; + +} + +// A guest attributes namespace/key/value entry. +message GuestAttributesEntry { + // Key for the guest attribute entry. + optional string key = 106079; + + // Namespace for the guest attribute entry. + optional string namespace = 178476379; + + // Value for the guest attribute entry. + optional string value = 111972721; + +} + +// Array of guest attribute namespace/key/value tuples. +message GuestAttributesValue { + repeated GuestAttributesEntry items = 100526016; + +} + +// Guest OS features. +message GuestOsFeature { + // The ID of a supported feature. To add multiple values, use commas to separate values. Set to one or more of the following values: - VIRTIO_SCSI_MULTIQUEUE - WINDOWS - MULTI_IP_SUBNET - UEFI_COMPATIBLE - GVNIC - SEV_CAPABLE - SUSPEND_RESUME_COMPATIBLE - SEV_SNP_CAPABLE - TDX_CAPABLE For more information, see Enabling guest operating system features. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + FEATURE_TYPE_UNSPECIFIED = 531767259; + + GVNIC = 68209305; + + MULTI_IP_SUBNET = 151776719; + + SECURE_BOOT = 376811194; + + SEV_CAPABLE = 87083793; + + SEV_LIVE_MIGRATABLE = 392039820; + + SEV_SNP_CAPABLE = 426919; + + UEFI_COMPATIBLE = 195865408; + + VIRTIO_SCSI_MULTIQUEUE = 201597069; + + WINDOWS = 456863331; + + } + + // The ID of a supported feature. To add multiple values, use commas to separate values. Set to one or more of the following values: - VIRTIO_SCSI_MULTIQUEUE - WINDOWS - MULTI_IP_SUBNET - UEFI_COMPATIBLE - GVNIC - SEV_CAPABLE - SUSPEND_RESUME_COMPATIBLE - SEV_SNP_CAPABLE - TDX_CAPABLE For more information, see Enabling guest operating system features. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// +message HTTP2HealthCheck { + // Specifies how a port is selected for health checking. Can be one of the following values: USE_FIXED_PORT: Specifies a port number explicitly using the port field in the health check. Supported by backend services for pass-through load balancers and backend services for proxy load balancers. Not supported by target pools. The health check supports all backends supported by the backend service provided the backend can be health checked. For example, GCE_VM_IP network endpoint groups, GCE_VM_IP_PORT network endpoint groups, and instance group backends. USE_NAMED_PORT: Not supported. USE_SERVING_PORT: Provides an indirect method of specifying the health check port by referring to the backend service. Only supported by backend services for proxy load balancers. Not supported by target pools. Not supported by backend services for pass-through load balancers. Supports all backends that can be health checked; for example, GCE_VM_IP_PORT network endpoint groups and instance group backends. For GCE_VM_IP_PORT network endpoint group backends, the health check uses the port number specified for each endpoint in the network endpoint group. For instance group backends, the health check uses the port number determined by looking up the backend service's named port in the instance group's list of named ports. + enum PortSpecification { + // A value indicating that the enum field is not set. + UNDEFINED_PORT_SPECIFICATION = 0; + + // The port number in the health check's port is used for health checking. Applies to network endpoint group and instance group backends. + USE_FIXED_PORT = 190235748; + + // Not supported. + USE_NAMED_PORT = 349300671; + + // For network endpoint group backends, the health check uses the port number specified on each endpoint in the network endpoint group. For instance group backends, the health check uses the port number specified for the backend service's named port defined in the instance group's named ports. + USE_SERVING_PORT = 362637516; + + } + + // Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. + enum ProxyHeader { + // A value indicating that the enum field is not set. + UNDEFINED_PROXY_HEADER = 0; + + NONE = 2402104; + + PROXY_V1 = 334352940; + + } + + // The value of the host header in the HTTP/2 health check request. If left empty (default value), the host header is set to the destination IP address to which health check packets are sent. The destination IP address depends on the type of load balancer. For details, see: https://cloud.google.com/load-balancing/docs/health-check-concepts#hc-packet-dest + optional string host = 3208616; + + // The TCP port number to which the health check prober sends packets. The default value is 443. Valid values are 1 through 65535. + optional int32 port = 3446913; + + // Not supported. + optional string port_name = 41534345; + + // Specifies how a port is selected for health checking. Can be one of the following values: USE_FIXED_PORT: Specifies a port number explicitly using the port field in the health check. Supported by backend services for pass-through load balancers and backend services for proxy load balancers. Not supported by target pools. The health check supports all backends supported by the backend service provided the backend can be health checked. For example, GCE_VM_IP network endpoint groups, GCE_VM_IP_PORT network endpoint groups, and instance group backends. USE_NAMED_PORT: Not supported. USE_SERVING_PORT: Provides an indirect method of specifying the health check port by referring to the backend service. Only supported by backend services for proxy load balancers. Not supported by target pools. Not supported by backend services for pass-through load balancers. Supports all backends that can be health checked; for example, GCE_VM_IP_PORT network endpoint groups and instance group backends. For GCE_VM_IP_PORT network endpoint group backends, the health check uses the port number specified for each endpoint in the network endpoint group. For instance group backends, the health check uses the port number determined by looking up the backend service's named port in the instance group's list of named ports. + // Check the PortSpecification enum for the list of possible values. + optional string port_specification = 51590597; + + // Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. + // Check the ProxyHeader enum for the list of possible values. + optional string proxy_header = 160374142; + + // The request path of the HTTP/2 health check request. The default value is /. + optional string request_path = 229403605; + + // Creates a content-based HTTP/2 health check. In addition to the required HTTP 200 (OK) status code, you can configure the health check to pass only when the backend sends this specific ASCII response string within the first 1024 bytes of the HTTP response body. For details, see: https://cloud.google.com/load-balancing/docs/health-check-concepts#criteria-protocol-http + optional string response = 196547649; + +} + +// +message HTTPHealthCheck { + // Specifies how a port is selected for health checking. Can be one of the following values: USE_FIXED_PORT: Specifies a port number explicitly using the port field in the health check. Supported by backend services for pass-through load balancers and backend services for proxy load balancers. Also supported in legacy HTTP health checks for target pools. The health check supports all backends supported by the backend service provided the backend can be health checked. For example, GCE_VM_IP network endpoint groups, GCE_VM_IP_PORT network endpoint groups, and instance group backends. USE_NAMED_PORT: Not supported. USE_SERVING_PORT: Provides an indirect method of specifying the health check port by referring to the backend service. Only supported by backend services for proxy load balancers. Not supported by target pools. Not supported by backend services for pass-through load balancers. Supports all backends that can be health checked; for example, GCE_VM_IP_PORT network endpoint groups and instance group backends. For GCE_VM_IP_PORT network endpoint group backends, the health check uses the port number specified for each endpoint in the network endpoint group. For instance group backends, the health check uses the port number determined by looking up the backend service's named port in the instance group's list of named ports. + enum PortSpecification { + // A value indicating that the enum field is not set. + UNDEFINED_PORT_SPECIFICATION = 0; + + // The port number in the health check's port is used for health checking. Applies to network endpoint group and instance group backends. + USE_FIXED_PORT = 190235748; + + // Not supported. + USE_NAMED_PORT = 349300671; + + // For network endpoint group backends, the health check uses the port number specified on each endpoint in the network endpoint group. For instance group backends, the health check uses the port number specified for the backend service's named port defined in the instance group's named ports. + USE_SERVING_PORT = 362637516; + + } + + // Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. + enum ProxyHeader { + // A value indicating that the enum field is not set. + UNDEFINED_PROXY_HEADER = 0; + + NONE = 2402104; + + PROXY_V1 = 334352940; + + } + + // The value of the host header in the HTTP health check request. If left empty (default value), the host header is set to the destination IP address to which health check packets are sent. The destination IP address depends on the type of load balancer. For details, see: https://cloud.google.com/load-balancing/docs/health-check-concepts#hc-packet-dest + optional string host = 3208616; + + // The TCP port number to which the health check prober sends packets. The default value is 80. Valid values are 1 through 65535. + optional int32 port = 3446913; + + // Not supported. + optional string port_name = 41534345; + + // Specifies how a port is selected for health checking. Can be one of the following values: USE_FIXED_PORT: Specifies a port number explicitly using the port field in the health check. Supported by backend services for pass-through load balancers and backend services for proxy load balancers. Also supported in legacy HTTP health checks for target pools. The health check supports all backends supported by the backend service provided the backend can be health checked. For example, GCE_VM_IP network endpoint groups, GCE_VM_IP_PORT network endpoint groups, and instance group backends. USE_NAMED_PORT: Not supported. USE_SERVING_PORT: Provides an indirect method of specifying the health check port by referring to the backend service. Only supported by backend services for proxy load balancers. Not supported by target pools. Not supported by backend services for pass-through load balancers. Supports all backends that can be health checked; for example, GCE_VM_IP_PORT network endpoint groups and instance group backends. For GCE_VM_IP_PORT network endpoint group backends, the health check uses the port number specified for each endpoint in the network endpoint group. For instance group backends, the health check uses the port number determined by looking up the backend service's named port in the instance group's list of named ports. + // Check the PortSpecification enum for the list of possible values. + optional string port_specification = 51590597; + + // Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. + // Check the ProxyHeader enum for the list of possible values. + optional string proxy_header = 160374142; + + // The request path of the HTTP health check request. The default value is /. + optional string request_path = 229403605; + + // Creates a content-based HTTP health check. In addition to the required HTTP 200 (OK) status code, you can configure the health check to pass only when the backend sends this specific ASCII response string within the first 1024 bytes of the HTTP response body. For details, see: https://cloud.google.com/load-balancing/docs/health-check-concepts#criteria-protocol-http + optional string response = 196547649; + +} + +// +message HTTPSHealthCheck { + // Specifies how a port is selected for health checking. Can be one of the following values: USE_FIXED_PORT: Specifies a port number explicitly using the port field in the health check. Supported by backend services for pass-through load balancers and backend services for proxy load balancers. Not supported by target pools. The health check supports all backends supported by the backend service provided the backend can be health checked. For example, GCE_VM_IP network endpoint groups, GCE_VM_IP_PORT network endpoint groups, and instance group backends. USE_NAMED_PORT: Not supported. USE_SERVING_PORT: Provides an indirect method of specifying the health check port by referring to the backend service. Only supported by backend services for proxy load balancers. Not supported by target pools. Not supported by backend services for pass-through load balancers. Supports all backends that can be health checked; for example, GCE_VM_IP_PORT network endpoint groups and instance group backends. For GCE_VM_IP_PORT network endpoint group backends, the health check uses the port number specified for each endpoint in the network endpoint group. For instance group backends, the health check uses the port number determined by looking up the backend service's named port in the instance group's list of named ports. + enum PortSpecification { + // A value indicating that the enum field is not set. + UNDEFINED_PORT_SPECIFICATION = 0; + + // The port number in the health check's port is used for health checking. Applies to network endpoint group and instance group backends. + USE_FIXED_PORT = 190235748; + + // Not supported. + USE_NAMED_PORT = 349300671; + + // For network endpoint group backends, the health check uses the port number specified on each endpoint in the network endpoint group. For instance group backends, the health check uses the port number specified for the backend service's named port defined in the instance group's named ports. + USE_SERVING_PORT = 362637516; + + } + + // Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. + enum ProxyHeader { + // A value indicating that the enum field is not set. + UNDEFINED_PROXY_HEADER = 0; + + NONE = 2402104; + + PROXY_V1 = 334352940; + + } + + // The value of the host header in the HTTPS health check request. If left empty (default value), the host header is set to the destination IP address to which health check packets are sent. The destination IP address depends on the type of load balancer. For details, see: https://cloud.google.com/load-balancing/docs/health-check-concepts#hc-packet-dest + optional string host = 3208616; + + // The TCP port number to which the health check prober sends packets. The default value is 443. Valid values are 1 through 65535. + optional int32 port = 3446913; + + // Not supported. + optional string port_name = 41534345; + + // Specifies how a port is selected for health checking. Can be one of the following values: USE_FIXED_PORT: Specifies a port number explicitly using the port field in the health check. Supported by backend services for pass-through load balancers and backend services for proxy load balancers. Not supported by target pools. The health check supports all backends supported by the backend service provided the backend can be health checked. For example, GCE_VM_IP network endpoint groups, GCE_VM_IP_PORT network endpoint groups, and instance group backends. USE_NAMED_PORT: Not supported. USE_SERVING_PORT: Provides an indirect method of specifying the health check port by referring to the backend service. Only supported by backend services for proxy load balancers. Not supported by target pools. Not supported by backend services for pass-through load balancers. Supports all backends that can be health checked; for example, GCE_VM_IP_PORT network endpoint groups and instance group backends. For GCE_VM_IP_PORT network endpoint group backends, the health check uses the port number specified for each endpoint in the network endpoint group. For instance group backends, the health check uses the port number determined by looking up the backend service's named port in the instance group's list of named ports. + // Check the PortSpecification enum for the list of possible values. + optional string port_specification = 51590597; + + // Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. + // Check the ProxyHeader enum for the list of possible values. + optional string proxy_header = 160374142; + + // The request path of the HTTPS health check request. The default value is /. + optional string request_path = 229403605; + + // Creates a content-based HTTPS health check. In addition to the required HTTP 200 (OK) status code, you can configure the health check to pass only when the backend sends this specific ASCII response string within the first 1024 bytes of the HTTP response body. For details, see: https://cloud.google.com/load-balancing/docs/health-check-concepts#criteria-protocol-http + optional string response = 196547649; + +} + +// Represents a Health Check resource. Google Compute Engine has two Health Check resources: * [Global](/compute/docs/reference/rest/v1/healthChecks) * [Regional](/compute/docs/reference/rest/v1/regionHealthChecks) Internal HTTP(S) load balancers must use regional health checks (`compute.v1.regionHealthChecks`). Traffic Director must use global health checks (`compute.v1.HealthChecks`). Internal TCP/UDP load balancers can use either regional or global health checks (`compute.v1.regionHealthChecks` or `compute.v1.HealthChecks`). External HTTP(S), TCP proxy, and SSL proxy load balancers as well as managed instance group auto-healing must use global health checks (`compute.v1.HealthChecks`). Backend service-based network load balancers must use regional health checks (`compute.v1.regionHealthChecks`). Target pool-based network load balancers must use legacy HTTP health checks (`compute.v1.httpHealthChecks`). For more information, see Health checks overview. +message HealthCheck { + // Specifies the type of the healthCheck, either TCP, SSL, HTTP, HTTPS, HTTP2 or GRPC. Exactly one of the protocol-specific health check fields must be specified, which must match type field. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + GRPC = 2196510; + + HTTP = 2228360; + + HTTP2 = 69079210; + + HTTPS = 69079243; + + INVALID = 530283991; + + SSL = 82412; + + TCP = 82881; + + } + + // How often (in seconds) to send a health check. The default value is 5 seconds. + optional int32 check_interval_sec = 345561006; + + // [Output Only] Creation timestamp in 3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + optional GRPCHealthCheck grpc_health_check = 85529574; + + // A so-far unhealthy instance will be marked healthy after this many consecutive successes. The default value is 2. + optional int32 healthy_threshold = 403212361; + + optional HTTP2HealthCheck http2_health_check = 11360986; + + optional HTTPHealthCheck http_health_check = 412586940; + + optional HTTPSHealthCheck https_health_check = 436046905; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // Type of the resource. + optional string kind = 3292052; + + // Configure logging on this health check. + optional HealthCheckLogConfig log_config = 351299741; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. For example, a name that is 1-63 characters long, matches the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`, and otherwise complies with RFC1035. This regular expression describes a name where the first character is a lowercase letter, and all following characters are a dash, lowercase letter, or digit, except the last character, which isn't a dash. + optional string name = 3373707; + + // [Output Only] Region where the health check resides. Not applicable to global health checks. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + optional SSLHealthCheck ssl_health_check = 280032440; + + optional TCPHealthCheck tcp_health_check = 469980419; + + // How long (in seconds) to wait before claiming failure. The default value is 5 seconds. It is invalid for timeoutSec to have greater value than checkIntervalSec. + optional int32 timeout_sec = 79994995; + + // Specifies the type of the healthCheck, either TCP, SSL, HTTP, HTTPS, HTTP2 or GRPC. Exactly one of the protocol-specific health check fields must be specified, which must match type field. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + + // A so-far healthy instance will be marked unhealthy after this many consecutive failures. The default value is 2. + optional int32 unhealthy_threshold = 227958480; + +} + +// Contains a list of HealthCheck resources. +message HealthCheckList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of HealthCheck resources. + repeated HealthCheck items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Configuration of logging on a health check. If logging is enabled, logs will be exported to Stackdriver. +message HealthCheckLogConfig { + // Indicates whether or not to export logs. This is false by default, which means no health check logging will be done. + optional bool enable = 311764355; + +} + +// A full or valid partial URL to a health check. For example, the following are valid URLs: - https://www.googleapis.com/compute/beta/projects/project-id/global/httpHealthChecks/health-check - projects/project-id/global/httpHealthChecks/health-check - global/httpHealthChecks/health-check +message HealthCheckReference { + optional string health_check = 308876645; + +} + +// Represents a Health-Check as a Service resource. +message HealthCheckService { + // Optional. Policy for how the results from multiple health checks for the same endpoint are aggregated. Defaults to NO_AGGREGATION if unspecified. - NO_AGGREGATION. An EndpointHealth message is returned for each pair in the health check service. - AND. If any health check of an endpoint reports UNHEALTHY, then UNHEALTHY is the HealthState of the endpoint. If all health checks report HEALTHY, the HealthState of the endpoint is HEALTHY. . This is only allowed with regional HealthCheckService. + enum HealthStatusAggregationPolicy { + // A value indicating that the enum field is not set. + UNDEFINED_HEALTH_STATUS_AGGREGATION_POLICY = 0; + + // If any backend's health check reports UNHEALTHY, then UNHEALTHY is the HealthState of the entire health check service. If all backend's are healthy, the HealthState of the health check service is HEALTHY. + AND = 64951; + + // An EndpointHealth message is returned for each backend in the health check service. + NO_AGGREGATION = 426445124; + + } + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a HealthCheckService. An up-to-date fingerprint must be provided in order to patch/update the HealthCheckService; Otherwise, the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve the HealthCheckService. + optional string fingerprint = 234678500; + + // A list of URLs to the HealthCheck resources. Must have at least one HealthCheck, and not more than 10 for regional HealthCheckService, and not more than 1 for global HealthCheckService. HealthCheck resources must have portSpecification=USE_SERVING_PORT or portSpecification=USE_FIXED_PORT. For regional HealthCheckService, the HealthCheck must be regional and in the same region. For global HealthCheckService, HealthCheck must be global. Mix of regional and global HealthChecks is not supported. Multiple regional HealthChecks must belong to the same region. Regional HealthChecks must belong to the same region as zones of NetworkEndpointGroups. For global HealthCheckService using global INTERNET_IP_PORT NetworkEndpointGroups, the global HealthChecks must specify sourceRegions, and HealthChecks that specify sourceRegions can only be used with global INTERNET_IP_PORT NetworkEndpointGroups. + repeated string health_checks = 448370606; + + // Optional. Policy for how the results from multiple health checks for the same endpoint are aggregated. Defaults to NO_AGGREGATION if unspecified. - NO_AGGREGATION. An EndpointHealth message is returned for each pair in the health check service. - AND. If any health check of an endpoint reports UNHEALTHY, then UNHEALTHY is the HealthState of the endpoint. If all health checks report HEALTHY, the HealthState of the endpoint is HEALTHY. . This is only allowed with regional HealthCheckService. + // Check the HealthStatusAggregationPolicy enum for the list of possible values. + optional string health_status_aggregation_policy = 253163129; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output only] Type of the resource. Always compute#healthCheckServicefor health check services. + optional string kind = 3292052; + + // Name of the resource. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // A list of URLs to the NetworkEndpointGroup resources. Must not have more than 100. For regional HealthCheckService, NEGs must be in zones in the region of the HealthCheckService. For global HealthCheckServices, the NetworkEndpointGroups must be global INTERNET_IP_PORT. + repeated string network_endpoint_groups = 29346733; + + // A list of URLs to the NotificationEndpoint resources. Must not have more than 10. A list of endpoints for receiving notifications of change in health status. For regional HealthCheckService, NotificationEndpoint must be regional and in the same region. For global HealthCheckService, NotificationEndpoint must be global. + repeated string notification_endpoints = 406728490; + + // [Output Only] URL of the region where the health check service resides. This field is not applicable to global health check services. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + +} + +// A full or valid partial URL to a health check service. For example, the following are valid URLs: - https://www.googleapis.com/compute/beta/projects/project-id/regions/us-west1/healthCheckServices/health-check-service - projects/project-id/regions/us-west1/healthCheckServices/health-check-service - regions/us-west1/healthCheckServices/health-check-service +message HealthCheckServiceReference { + optional string health_check_service = 408374747; + +} + +// +message HealthCheckServicesList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of HealthCheckService resources. + repeated HealthCheckService items = 100526016; + + // [Output Only] Type of the resource. Always compute#healthCheckServicesList for lists of HealthCheckServices. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message HealthChecksAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of HealthChecksScopedList resources. + map items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message HealthChecksScopedList { + // A list of HealthChecks contained in this scope. + repeated HealthCheck health_checks = 448370606; + + // Informational warning which replaces the list of backend services when the list is empty. + optional Warning warning = 50704284; + +} + +// +message HealthStatus { + // Health state of the instance. + enum HealthState { + // A value indicating that the enum field is not set. + UNDEFINED_HEALTH_STATE = 0; + + HEALTHY = 439801213; + + UNHEALTHY = 462118084; + + } + + // + enum WeightError { + // A value indicating that the enum field is not set. + UNDEFINED_WEIGHT_ERROR = 0; + + // The response to a Health Check probe had the HTTP response header field X-Load-Balancing-Endpoint-Weight, but its content was invalid (i.e., not a non-negative single-precision floating-point number in decimal string representation). + INVALID_WEIGHT = 383698400; + + // The response to a Health Check probe did not have the HTTP response header field X-Load-Balancing-Endpoint-Weight. + MISSING_WEIGHT = 384027537; + + // This is the value when the accompanied health status is either TIMEOUT (i.e.,the Health Check probe was not able to get a response in time) or UNKNOWN. For the latter, it should be typically because there has not been sufficient time to parse and report the weight for a new backend (which is with 0.0.0.0 ip address). However, it can be also due to an outage case for which the health status is explicitly reset to UNKNOWN. + UNAVAILABLE_WEIGHT = 439464295; + + // This is the default value when WeightReportMode is DISABLE, and is also the initial value when WeightReportMode has just updated to ENABLE or DRY_RUN and there has not been sufficient time to parse and report the backend weight. + WEIGHT_NONE = 502428831; + + } + + // Metadata defined as annotations for network endpoint. + map annotations = 112032548; + + // URL of the forwarding rule associated with the health status of the instance. + optional string forwarding_rule = 269964030; + + // A forwarding rule IP address assigned to this instance. + optional string forwarding_rule_ip = 172250632; + + // Health state of the instance. + // Check the HealthState enum for the list of possible values. + optional string health_state = 324007150; + + // URL of the instance resource. + optional string instance = 18257045; + + // For target pool based Network Load Balancing, it indicates the forwarding rule's IP address assigned to this instance. For other types of load balancing, the field indicates VM internal ip. + optional string ip_address = 406272220; + + // The named port of the instance group, not necessarily the port that is health-checked. + optional int32 port = 3446913; + + optional string weight = 282149496; + + // + // Check the WeightError enum for the list of possible values. + optional string weight_error = 522501505; + +} + +// +message HealthStatusForNetworkEndpoint { + // Health state of the network endpoint determined based on the health checks configured. + enum HealthState { + // A value indicating that the enum field is not set. + UNDEFINED_HEALTH_STATE = 0; + + // Endpoint is being drained. + DRAINING = 480455402; + + // Endpoint is healthy. + HEALTHY = 439801213; + + // Endpoint is unhealthy. + UNHEALTHY = 462118084; + + // Health status of the endpoint is unknown. + UNKNOWN = 433141802; + + } + + // URL of the backend service associated with the health state of the network endpoint. + optional BackendServiceReference backend_service = 306946058; + + // URL of the forwarding rule associated with the health state of the network endpoint. + optional ForwardingRuleReference forwarding_rule = 269964030; + + // URL of the health check associated with the health state of the network endpoint. + optional HealthCheckReference health_check = 308876645; + + // URL of the health check service associated with the health state of the network endpoint. + optional HealthCheckServiceReference health_check_service = 408374747; + + // Health state of the network endpoint determined based on the health checks configured. + // Check the HealthState enum for the list of possible values. + optional string health_state = 324007150; + +} + +// Provides links to documentation or for performing an out of band action. For example, if a quota check failed with an error indicating the calling project hasn't enabled the accessed service, this can contain a URL pointing directly to the right place in the developer console to flip the bit. +message Help { + // URL(s) pointing to additional information on handling the current error. + repeated HelpLink links = 102977465; + +} + +// Describes a URL link. +message HelpLink { + // Describes what the link offers. + optional string description = 422937596; + + // The URL of the link. + optional string url = 116079; + +} + +// UrlMaps A host-matching rule for a URL. If matched, will use the named PathMatcher to select the BackendService. +message HostRule { + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // The list of host patterns to match. They must be valid hostnames with optional port numbers in the format host:port. * matches any string of ([a-z0-9-.]*). In that case, * must be the first character, and if followed by anything, the immediate following character must be either - or .. * based matching is not supported when the URL map is bound to a target gRPC proxy that has the validateForProxyless field set to true. + repeated string hosts = 99467211; + + // The name of the PathMatcher to use to match the path portion of the URL if the hostRule matches the URL's host portion. + optional string path_matcher = 337813272; + +} + +// Specification for how requests are aborted as part of fault injection. +message HttpFaultAbort { + // The HTTP status code used to abort the request. The value must be from 200 to 599 inclusive. For gRPC protocol, the gRPC status code is mapped to HTTP status code according to this mapping table. HTTP status 200 is mapped to gRPC status UNKNOWN. Injecting an OK status is currently not supported by Traffic Director. + optional uint32 http_status = 468949897; + + // The percentage of traffic for connections, operations, or requests that is aborted as part of fault injection. The value must be from 0.0 to 100.0 inclusive. + optional double percentage = 151909018; + +} + +// Specifies the delay introduced by the load balancer before forwarding the request to the backend service as part of fault injection. +message HttpFaultDelay { + // Specifies the value of the fixed delay interval. + optional Duration fixed_delay = 317037816; + + // The percentage of traffic for connections, operations, or requests for which a delay is introduced as part of fault injection. The value must be from 0.0 to 100.0 inclusive. + optional double percentage = 151909018; + +} + +// The specification for fault injection introduced into traffic to test the resiliency of clients to backend service failure. As part of fault injection, when clients send requests to a backend service, delays can be introduced by the load balancer on a percentage of requests before sending those request to the backend service. Similarly requests from clients can be aborted by the load balancer for a percentage of requests. +message HttpFaultInjection { + // The specification for how client requests are aborted as part of fault injection. + optional HttpFaultAbort abort = 92611376; + + // The specification for how client requests are delayed as part of fault injection, before being sent to a backend service. + optional HttpFaultDelay delay = 95467907; + +} + +// The request and response header transformations that take effect before the request is passed along to the selected backendService. +message HttpHeaderAction { + // Headers to add to a matching request before forwarding the request to the backendService. + repeated HttpHeaderOption request_headers_to_add = 72111974; + + // A list of header names for headers that need to be removed from the request before forwarding the request to the backendService. + repeated string request_headers_to_remove = 218425247; + + // Headers to add the response before sending the response back to the client. + repeated HttpHeaderOption response_headers_to_add = 32136052; + + // A list of header names for headers that need to be removed from the response before sending the response back to the client. + repeated string response_headers_to_remove = 75415761; + +} + +// matchRule criteria for request header matches. +message HttpHeaderMatch { + // The value should exactly match contents of exactMatch. Only one of exactMatch, prefixMatch, suffixMatch, regexMatch, presentMatch or rangeMatch must be set. + optional string exact_match = 457641093; + + // The name of the HTTP header to match. For matching against the HTTP request's authority, use a headerMatch with the header name ":authority". For matching a request's method, use the headerName ":method". When the URL map is bound to a target gRPC proxy that has the validateForProxyless field set to true, only non-binary user-specified custom metadata and the `content-type` header are supported. The following transport-level headers cannot be used in header matching rules: `:authority`, `:method`, `:path`, `:scheme`, `user-agent`, `accept-encoding`, `content-encoding`, `grpc-accept-encoding`, `grpc-encoding`, `grpc-previous-rpc-attempts`, `grpc-tags-bin`, `grpc-timeout` and `grpc-trace-bin`. + optional string header_name = 110223613; + + // If set to false, the headerMatch is considered a match if the preceding match criteria are met. If set to true, the headerMatch is considered a match if the preceding match criteria are NOT met. The default setting is false. + optional bool invert_match = 501130268; + + // The value of the header must start with the contents of prefixMatch. Only one of exactMatch, prefixMatch, suffixMatch, regexMatch, presentMatch or rangeMatch must be set. + optional string prefix_match = 257898968; + + // A header with the contents of headerName must exist. The match takes place whether or not the request's header has a value. Only one of exactMatch, prefixMatch, suffixMatch, regexMatch, presentMatch or rangeMatch must be set. + optional bool present_match = 67435841; + + // The header value must be an integer and its value must be in the range specified in rangeMatch. If the header does not contain an integer, number or is empty, the match fails. For example for a range [-5, 0] - -3 will match. - 0 will not match. - 0.25 will not match. - -3someString will not match. Only one of exactMatch, prefixMatch, suffixMatch, regexMatch, presentMatch or rangeMatch must be set. rangeMatch is not supported for load balancers that have loadBalancingScheme set to EXTERNAL. + optional Int64RangeMatch range_match = 97244227; + + // The value of the header must match the regular expression specified in regexMatch. For more information about regular expression syntax, see Syntax. For matching against a port specified in the HTTP request, use a headerMatch with headerName set to PORT and a regular expression that satisfies the RFC2616 Host header's port specifier. Only one of exactMatch, prefixMatch, suffixMatch, regexMatch, presentMatch or rangeMatch must be set. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED. + optional string regex_match = 107387853; + + // The value of the header must end with the contents of suffixMatch. Only one of exactMatch, prefixMatch, suffixMatch, regexMatch, presentMatch or rangeMatch must be set. + optional string suffix_match = 426488663; + +} + +// Specification determining how headers are added to requests or responses. +message HttpHeaderOption { + // The name of the header. + optional string header_name = 110223613; + + // The value of the header to add. + optional string header_value = 203094335; + + // If false, headerValue is appended to any values that already exist for the header. If true, headerValue is set for the header, discarding any values that were set for that header. The default value is false. + optional bool replace = 20755124; + +} + +// HttpRouteRuleMatch criteria for a request's query parameter. +message HttpQueryParameterMatch { + // The queryParameterMatch matches if the value of the parameter exactly matches the contents of exactMatch. Only one of presentMatch, exactMatch, or regexMatch must be set. + optional string exact_match = 457641093; + + // The name of the query parameter to match. The query parameter must exist in the request, in the absence of which the request match fails. + optional string name = 3373707; + + // Specifies that the queryParameterMatch matches if the request contains the query parameter, irrespective of whether the parameter has a value or not. Only one of presentMatch, exactMatch, or regexMatch must be set. + optional bool present_match = 67435841; + + // The queryParameterMatch matches if the value of the parameter matches the regular expression specified by regexMatch. For more information about regular expression syntax, see Syntax. Only one of presentMatch, exactMatch, or regexMatch must be set. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED. + optional string regex_match = 107387853; + +} + +// Specifies settings for an HTTP redirect. +message HttpRedirectAction { + // The HTTP Status code to use for this RedirectAction. Supported values are: - MOVED_PERMANENTLY_DEFAULT, which is the default value and corresponds to 301. - FOUND, which corresponds to 302. - SEE_OTHER which corresponds to 303. - TEMPORARY_REDIRECT, which corresponds to 307. In this case, the request method is retained. - PERMANENT_REDIRECT, which corresponds to 308. In this case, the request method is retained. + enum RedirectResponseCode { + // A value indicating that the enum field is not set. + UNDEFINED_REDIRECT_RESPONSE_CODE = 0; + + // Http Status Code 302 - Found. + FOUND = 67084130; + + // Http Status Code 301 - Moved Permanently. + MOVED_PERMANENTLY_DEFAULT = 386698449; + + // Http Status Code 308 - Permanent Redirect maintaining HTTP method. + PERMANENT_REDIRECT = 382006381; + + // Http Status Code 303 - See Other. + SEE_OTHER = 445380580; + + // Http Status Code 307 - Temporary Redirect maintaining HTTP method. + TEMPORARY_REDIRECT = 489550378; + + } + + // The host that is used in the redirect response instead of the one that was supplied in the request. The value must be from 1 to 255 characters. + optional string host_redirect = 107417747; + + // If set to true, the URL scheme in the redirected request is set to HTTPS. If set to false, the URL scheme of the redirected request remains the same as that of the request. This must only be set for URL maps used in TargetHttpProxys. Setting this true for TargetHttpsProxy is not permitted. The default is set to false. + optional bool https_redirect = 170260656; + + // The path that is used in the redirect response instead of the one that was supplied in the request. pathRedirect cannot be supplied together with prefixRedirect. Supply one alone or neither. If neither is supplied, the path of the original request is used for the redirect. The value must be from 1 to 1024 characters. + optional string path_redirect = 272342710; + + // The prefix that replaces the prefixMatch specified in the HttpRouteRuleMatch, retaining the remaining portion of the URL before redirecting the request. prefixRedirect cannot be supplied together with pathRedirect. Supply one alone or neither. If neither is supplied, the path of the original request is used for the redirect. The value must be from 1 to 1024 characters. + optional string prefix_redirect = 446184169; + + // The HTTP Status code to use for this RedirectAction. Supported values are: - MOVED_PERMANENTLY_DEFAULT, which is the default value and corresponds to 301. - FOUND, which corresponds to 302. - SEE_OTHER which corresponds to 303. - TEMPORARY_REDIRECT, which corresponds to 307. In this case, the request method is retained. - PERMANENT_REDIRECT, which corresponds to 308. In this case, the request method is retained. + // Check the RedirectResponseCode enum for the list of possible values. + optional string redirect_response_code = 436710408; + + // If set to true, any accompanying query portion of the original URL is removed before redirecting the request. If set to false, the query portion of the original URL is retained. The default is set to false. + optional bool strip_query = 52284641; + +} + +// The retry policy associates with HttpRouteRule +message HttpRetryPolicy { + // Specifies the allowed number retries. This number must be > 0. If not specified, defaults to 1. + optional uint32 num_retries = 251680141; + + // Specifies a non-zero timeout per retry attempt. If not specified, will use the timeout set in the HttpRouteAction field. If timeout in the HttpRouteAction field is not set, this field uses the largest timeout among all backend services associated with the route. Not supported when the URL map is bound to a target gRPC proxy that has the validateForProxyless field set to true. + optional Duration per_try_timeout = 280041147; + + // Specifies one or more conditions when this retry policy applies. Valid values are: - 5xx: retry is attempted if the instance or endpoint responds with any 5xx response code, or if the instance or endpoint does not respond at all. For example, disconnects, reset, read timeout, connection failure, and refused streams. - gateway-error: Similar to 5xx, but only applies to response codes 502, 503 or 504. - connect-failure: a retry is attempted on failures connecting to the instance or endpoint. For example, connection timeouts. - retriable-4xx: a retry is attempted if the instance or endpoint responds with a 4xx response code. The only error that you can retry is error code 409. - refused-stream: a retry is attempted if the instance or endpoint resets the stream with a REFUSED_STREAM error code. This reset type indicates that it is safe to retry. - cancelled: a retry is attempted if the gRPC status code in the response header is set to cancelled. - deadline-exceeded: a retry is attempted if the gRPC status code in the response header is set to deadline-exceeded. - internal: a retry is attempted if the gRPC status code in the response header is set to internal. - resource-exhausted: a retry is attempted if the gRPC status code in the response header is set to resource-exhausted. - unavailable: a retry is attempted if the gRPC status code in the response header is set to unavailable. Only the following codes are supported when the URL map is bound to target gRPC proxy that has validateForProxyless field set to true. - cancelled - deadline-exceeded - internal - resource-exhausted - unavailable + repeated string retry_conditions = 28815535; + +} + +// +message HttpRouteAction { + // The specification for allowing client-side cross-origin requests. For more information about the W3C recommendation for cross-origin resource sharing (CORS), see Fetch API Living Standard. Not supported when the URL map is bound to a target gRPC proxy. + optional CorsPolicy cors_policy = 398943748; + + // The specification for fault injection introduced into traffic to test the resiliency of clients to backend service failure. As part of fault injection, when clients send requests to a backend service, delays can be introduced by a load balancer on a percentage of requests before sending those requests to the backend service. Similarly requests from clients can be aborted by the load balancer for a percentage of requests. timeout and retry_policy is ignored by clients that are configured with a fault_injection_policy if: 1. The traffic is generated by fault injection AND 2. The fault injection is not a delay fault injection. Fault injection is not supported with the global external HTTP(S) load balancer (classic). To see which load balancers support fault injection, see Load balancing: Routing and traffic management features. + optional HttpFaultInjection fault_injection_policy = 412781079; + + // Specifies the maximum duration (timeout) for streams on the selected route. Unlike the timeout field where the timeout duration starts from the time the request has been fully processed (known as *end-of-stream*), the duration in this field is computed from the beginning of the stream until the response has been processed, including all retries. A stream that does not complete in this duration is closed. If not specified, this field uses the maximum maxStreamDuration value among all backend services associated with the route. This field is only allowed if the Url map is used with backend services with loadBalancingScheme set to INTERNAL_SELF_MANAGED. + optional Duration max_stream_duration = 61428376; + + // Specifies the policy on how requests intended for the route's backends are shadowed to a separate mirrored backend service. The load balancer does not wait for responses from the shadow service. Before sending traffic to the shadow service, the host / authority header is suffixed with -shadow. Not supported when the URL map is bound to a target gRPC proxy that has the validateForProxyless field set to true. + optional RequestMirrorPolicy request_mirror_policy = 220196866; + + // Specifies the retry policy associated with this route. + optional HttpRetryPolicy retry_policy = 56799913; + + // Specifies the timeout for the selected route. Timeout is computed from the time the request has been fully processed (known as *end-of-stream*) up until the response has been processed. Timeout includes all retries. If not specified, this field uses the largest timeout among all backend services associated with the route. Not supported when the URL map is bound to a target gRPC proxy that has validateForProxyless field set to true. + optional Duration timeout = 296701281; + + // The spec to modify the URL of the request, before forwarding the request to the matched service. urlRewrite is the only action supported in UrlMaps for external HTTP(S) load balancers. Not supported when the URL map is bound to a target gRPC proxy that has the validateForProxyless field set to true. + optional UrlRewrite url_rewrite = 273333948; + + // A list of weighted backend services to send traffic to when a route match occurs. The weights determine the fraction of traffic that flows to their corresponding backend service. If all traffic needs to go to a single backend service, there must be one weightedBackendService with weight set to a non-zero number. After a backend service is identified and before forwarding the request to the backend service, advanced routing actions such as URL rewrites and header transformations are applied depending on additional settings specified in this HttpRouteAction. + repeated WeightedBackendService weighted_backend_services = 337028049; + +} + +// The HttpRouteRule setting specifies how to match an HTTP request and the corresponding routing action that load balancing proxies perform. +message HttpRouteRule { + // The short description conveying the intent of this routeRule. The description can have a maximum length of 1024 characters. + optional string description = 422937596; + + // Specifies changes to request and response headers that need to take effect for the selected backendService. The headerAction value specified here is applied before the matching pathMatchers[].headerAction and after pathMatchers[].routeRules[].routeAction.weightedBackendService.backendServiceWeightAction[].headerAction HeaderAction is not supported for load balancers that have their loadBalancingScheme set to EXTERNAL. Not supported when the URL map is bound to a target gRPC proxy that has validateForProxyless field set to true. + optional HttpHeaderAction header_action = 328077352; + + // The list of criteria for matching attributes of a request to this routeRule. This list has OR semantics: the request matches this routeRule when any of the matchRules are satisfied. However predicates within a given matchRule have AND semantics. All predicates within a matchRule must match for the request to match the rule. + repeated HttpRouteRuleMatch match_rules = 376200701; + + // For routeRules within a given pathMatcher, priority determines the order in which a load balancer interprets routeRules. RouteRules are evaluated in order of priority, from the lowest to highest number. The priority of a rule decreases as its number increases (1, 2, 3, N+1). The first rule that matches the request is applied. You cannot configure two or more routeRules with the same priority. Priority for each rule must be set to a number from 0 to 2147483647 inclusive. Priority numbers can have gaps, which enable you to add or remove rules in the future without affecting the rest of the rules. For example, 1, 2, 3, 4, 5, 9, 12, 16 is a valid series of priority numbers to which you could add rules numbered from 6 to 8, 10 to 11, and 13 to 15 in the future without any impact on existing rules. + optional int32 priority = 445151652; + + // In response to a matching matchRule, the load balancer performs advanced routing actions, such as URL rewrites and header transformations, before forwarding the request to the selected backend. If routeAction specifies any weightedBackendServices, service must not be set. Conversely if service is set, routeAction cannot contain any weightedBackendServices. Only one of urlRedirect, service or routeAction.weightedBackendService must be set. URL maps for Classic external HTTP(S) load balancers only support the urlRewrite action within a route rule's routeAction. + optional HttpRouteAction route_action = 424563948; + + // The full or partial URL of the backend service resource to which traffic is directed if this rule is matched. If routeAction is also specified, advanced routing actions, such as URL rewrites, take effect before sending the request to the backend. However, if service is specified, routeAction cannot contain any weightedBackendServices. Conversely, if routeAction specifies any weightedBackendServices, service must not be specified. Only one of urlRedirect, service or routeAction.weightedBackendService must be set. + optional string service = 373540533; + + // When this rule is matched, the request is redirected to a URL specified by urlRedirect. If urlRedirect is specified, service or routeAction must not be set. Not supported when the URL map is bound to a target gRPC proxy. + optional HttpRedirectAction url_redirect = 405147820; + +} + +// HttpRouteRuleMatch specifies a set of criteria for matching requests to an HttpRouteRule. All specified criteria must be satisfied for a match to occur. +message HttpRouteRuleMatch { + // For satisfying the matchRule condition, the path of the request must exactly match the value specified in fullPathMatch after removing any query parameters and anchor that may be part of the original URL. fullPathMatch must be from 1 to 1024 characters. Only one of prefixMatch, fullPathMatch or regexMatch must be specified. + optional string full_path_match = 214598875; + + // Specifies a list of header match criteria, all of which must match corresponding headers in the request. + repeated HttpHeaderMatch header_matches = 361903489; + + // Specifies that prefixMatch and fullPathMatch matches are case sensitive. The default value is false. ignoreCase must not be used with regexMatch. Not supported when the URL map is bound to a target gRPC proxy. + optional bool ignore_case = 464324989; + + // Opaque filter criteria used by the load balancer to restrict routing configuration to a limited set of xDS compliant clients. In their xDS requests to the load balancer, xDS clients present node metadata. When there is a match, the relevant routing configuration is made available to those proxies. For each metadataFilter in this list, if its filterMatchCriteria is set to MATCH_ANY, at least one of the filterLabels must match the corresponding label provided in the metadata. If its filterMatchCriteria is set to MATCH_ALL, then all of its filterLabels must match with corresponding labels provided in the metadata. If multiple metadata filters are specified, all of them need to be satisfied in order to be considered a match. metadataFilters specified here is applied after those specified in ForwardingRule that refers to the UrlMap this HttpRouteRuleMatch belongs to. metadataFilters only applies to load balancers that have loadBalancingScheme set to INTERNAL_SELF_MANAGED. Not supported when the URL map is bound to a target gRPC proxy that has validateForProxyless field set to true. + repeated MetadataFilter metadata_filters = 464725739; + + // For satisfying the matchRule condition, the request's path must begin with the specified prefixMatch. prefixMatch must begin with a /. The value must be from 1 to 1024 characters. Only one of prefixMatch, fullPathMatch or regexMatch must be specified. + optional string prefix_match = 257898968; + + // Specifies a list of query parameter match criteria, all of which must match corresponding query parameters in the request. Not supported when the URL map is bound to a target gRPC proxy. + repeated HttpQueryParameterMatch query_parameter_matches = 286231270; + + // For satisfying the matchRule condition, the path of the request must satisfy the regular expression specified in regexMatch after removing any query parameters and anchor supplied with the original URL. For more information about regular expression syntax, see Syntax. Only one of prefixMatch, fullPathMatch or regexMatch must be specified. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED. + optional string regex_match = 107387853; + +} + +// Represents an Image resource. You can use images to create boot disks for your VM instances. For more information, read Images. +message Image { + // The architecture of the image. Valid values are ARM64 or X86_64. + enum Architecture { + // A value indicating that the enum field is not set. + UNDEFINED_ARCHITECTURE = 0; + + // Default value indicating Architecture is not set. + ARCHITECTURE_UNSPECIFIED = 394750507; + + // Machines with architecture ARM64 + ARM64 = 62547450; + + // Machines with architecture X86_64 + X86_64 = 425300551; + + } + + // The type of the image used to create this disk. The default and only valid value is RAW. + enum SourceType { + // A value indicating that the enum field is not set. + UNDEFINED_SOURCE_TYPE = 0; + + RAW = 80904; + + } + + // [Output Only] The status of the image. An image can be used to create other resources, such as instances, only after the image has been successfully created and the status is set to READY. Possible values are FAILED, PENDING, or READY. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // Image is deleting. + DELETING = 528602024; + + // Image creation failed due to an error. + FAILED = 455706685; + + // Image hasn't been created as yet. + PENDING = 35394935; + + // Image has been successfully created. + READY = 77848963; + + } + + // The architecture of the image. Valid values are ARM64 or X86_64. + // Check the Architecture enum for the list of possible values. + optional string architecture = 302803283; + + // Size of the image tar.gz archive stored in Google Cloud Storage (in bytes). + optional int64 archive_size_bytes = 381093450; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // The deprecation status associated with this image. + optional DeprecationStatus deprecated = 515138995; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Size of the image when restored onto a persistent disk (in GB). + optional int64 disk_size_gb = 316263735; + + // The name of the image family to which this image belongs. The image family name can be from a publicly managed image family provided by Compute Engine, or from a custom image family you create. For example, centos-stream-9 is a publicly available image family. For more information, see Image family best practices. When creating disks, you can specify an image family instead of a specific image name. The image family always returns its latest image that is not deprecated. The name of the image family must comply with RFC1035. + optional string family = 328751972; + + // A list of features to enable on the guest operating system. Applicable only for bootable images. To see a list of available options, see the guestOSfeatures[].type parameter. + repeated GuestOsFeature guest_os_features = 79294545; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // Encrypts the image using a customer-supplied encryption key. After you encrypt an image with a customer-supplied key, you must provide the same key if you use the image later (e.g. to create a disk from the image). Customer-supplied encryption keys do not protect access to metadata of the disk. If you do not provide an encryption key when creating the image, then the disk will be encrypted using an automatically generated key and you do not need to provide a key to use the image later. + optional CustomerEncryptionKey image_encryption_key = 379512583; + + // [Output Only] Type of the resource. Always compute#image for images. + optional string kind = 3292052; + + // A fingerprint for the labels being applied to this image, which is essentially a hash of the labels used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update labels. You must always provide an up-to-date fingerprint hash in order to update or change labels, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve an image. + optional string label_fingerprint = 178124825; + + // Labels to apply to this image. These can be later modified by the setLabels method. + map labels = 500195327; + + // Integer license codes indicating which licenses are attached to this image. + repeated int64 license_codes = 45482664; + + // Any applicable license URI. + repeated string licenses = 337642578; + + // Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // The parameters of the raw disk image. + optional RawDisk raw_disk = 503113556; + + // [Output Only] Reserved for future use. + optional bool satisfies_pzs = 480964267; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // Set the secure boot keys of shielded instance. + optional InitialStateConfig shielded_instance_initial_state = 192356867; + + // URL of the source disk used to create this image. For example, the following are valid values: - https://www.googleapis.com/compute/v1/projects/project/zones/zone /disks/disk - projects/project/zones/zone/disks/disk - zones/zone/disks/disk In order to create an image, you must provide the full or partial URL of one of the following: - The rawDisk.source URL - The sourceDisk URL - The sourceImage URL - The sourceSnapshot URL + optional string source_disk = 451753793; + + // The customer-supplied encryption key of the source disk. Required if the source disk is protected by a customer-supplied encryption key. + optional CustomerEncryptionKey source_disk_encryption_key = 531501153; + + // [Output Only] The ID value of the disk used to create this image. This value may be used to determine whether the image was taken from the current or a previous instance of a given disk name. + optional string source_disk_id = 454190809; + + // URL of the source image used to create this image. The following are valid formats for the URL: - https://www.googleapis.com/compute/v1/projects/project_id/global/ images/image_name - projects/project_id/global/images/image_name In order to create an image, you must provide the full or partial URL of one of the following: - The rawDisk.source URL - The sourceDisk URL - The sourceImage URL - The sourceSnapshot URL + optional string source_image = 50443319; + + // The customer-supplied encryption key of the source image. Required if the source image is protected by a customer-supplied encryption key. + optional CustomerEncryptionKey source_image_encryption_key = 381503659; + + // [Output Only] The ID value of the image used to create this image. This value may be used to determine whether the image was taken from the current or a previous instance of a given image name. + optional string source_image_id = 55328291; + + // URL of the source snapshot used to create this image. The following are valid formats for the URL: - https://www.googleapis.com/compute/v1/projects/project_id/global/ snapshots/snapshot_name - projects/project_id/global/snapshots/snapshot_name In order to create an image, you must provide the full or partial URL of one of the following: - The rawDisk.source URL - The sourceDisk URL - The sourceImage URL - The sourceSnapshot URL + optional string source_snapshot = 126061928; + + // The customer-supplied encryption key of the source snapshot. Required if the source snapshot is protected by a customer-supplied encryption key. + optional CustomerEncryptionKey source_snapshot_encryption_key = 303679322; + + // [Output Only] The ID value of the snapshot used to create this image. This value may be used to determine whether the snapshot was taken from the current or a previous instance of a given snapshot name. + optional string source_snapshot_id = 98962258; + + // The type of the image used to create this disk. The default and only valid value is RAW. + // Check the SourceType enum for the list of possible values. + optional string source_type = 452245726; + + // [Output Only] The status of the image. An image can be used to create other resources, such as instances, only after the image has been successfully created and the status is set to READY. Possible values are FAILED, PENDING, or READY. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // Cloud Storage bucket storage location of the image (regional or multi-regional). + repeated string storage_locations = 328005274; + +} + +// +message ImageFamilyView { + // The latest image that is part of the specified image family in the requested location, and that is not deprecated. + optional Image image = 100313435; + +} + +// Contains a list of images. +message ImageList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Image resources. + repeated Image items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Initial State for shielded instance, these are public keys which are safe to store in public +message InitialStateConfig { + // The Key Database (db). + repeated FileContentBuffer dbs = 99253; + + // The forbidden key database (dbx). + repeated FileContentBuffer dbxs = 3077113; + + // The Key Exchange Key (KEK). + repeated FileContentBuffer keks = 3288130; + + // The Platform Key (PK). + optional FileContentBuffer pk = 3579; + +} + +// A request message for Addresses.Insert. See the method description for details. +message InsertAddressRequest { + // The body resource for this request + Address address_resource = 483888121 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Autoscalers.Insert. See the method description for details. +message InsertAutoscalerRequest { + // The body resource for this request + Autoscaler autoscaler_resource = 207616118 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for BackendBuckets.Insert. See the method description for details. +message InsertBackendBucketRequest { + // The body resource for this request + BackendBucket backend_bucket_resource = 380757784 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for BackendServices.Insert. See the method description for details. +message InsertBackendServiceRequest { + // The body resource for this request + BackendService backend_service_resource = 347586723 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Disks.Insert. See the method description for details. +message InsertDiskRequest { + // The body resource for this request + Disk disk_resource = 25880688 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Source image to restore onto a disk. This field is optional. + optional string source_image = 50443319; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for ExternalVpnGateways.Insert. See the method description for details. +message InsertExternalVpnGatewayRequest { + // The body resource for this request + ExternalVpnGateway external_vpn_gateway_resource = 486813576 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for FirewallPolicies.Insert. See the method description for details. +message InsertFirewallPolicyRequest { + // The body resource for this request + FirewallPolicy firewall_policy_resource = 495049532 [(google.api.field_behavior) = REQUIRED]; + + // Parent ID for this request. The ID can be either be "folders/[FOLDER_ID]" if the parent is a folder or "organizations/[ORGANIZATION_ID]" if the parent is an organization. + string parent_id = 459714768 [ + (google.cloud.operation_request_field) = "parent_id", + (google.api.field_behavior) = REQUIRED + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Firewalls.Insert. See the method description for details. +message InsertFirewallRequest { + // The body resource for this request + Firewall firewall_resource = 41425005 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for ForwardingRules.Insert. See the method description for details. +message InsertForwardingRuleRequest { + // The body resource for this request + ForwardingRule forwarding_rule_resource = 301211695 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for GlobalAddresses.Insert. See the method description for details. +message InsertGlobalAddressRequest { + // The body resource for this request + Address address_resource = 483888121 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for GlobalForwardingRules.Insert. See the method description for details. +message InsertGlobalForwardingRuleRequest { + // The body resource for this request + ForwardingRule forwarding_rule_resource = 301211695 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for GlobalNetworkEndpointGroups.Insert. See the method description for details. +message InsertGlobalNetworkEndpointGroupRequest { + // The body resource for this request + NetworkEndpointGroup network_endpoint_group_resource = 525788839 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for GlobalPublicDelegatedPrefixes.Insert. See the method description for details. +message InsertGlobalPublicDelegatedPrefixeRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The body resource for this request + PublicDelegatedPrefix public_delegated_prefix_resource = 47594501 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for HealthChecks.Insert. See the method description for details. +message InsertHealthCheckRequest { + // The body resource for this request + HealthCheck health_check_resource = 201925032 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Images.Insert. See the method description for details. +message InsertImageRequest { + // Force image creation if true. + optional bool force_create = 197723344; + + // The body resource for this request + Image image_resource = 371171954 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for InstanceGroupManagers.Insert. See the method description for details. +message InsertInstanceGroupManagerRequest { + // The body resource for this request + InstanceGroupManager instance_group_manager_resource = 261063946 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where you want to create the managed instance group. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for InstanceGroups.Insert. See the method description for details. +message InsertInstanceGroupRequest { + // The body resource for this request + InstanceGroup instance_group_resource = 286612152 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where you want to create the instance group. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Instances.Insert. See the method description for details. +message InsertInstanceRequest { + // The body resource for this request + Instance instance_resource = 215988344 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Specifies instance template to create the instance. This field is optional. It can be a full or partial URL. For example, the following are all valid URLs to an instance template: - https://www.googleapis.com/compute/v1/projects/project /global/instanceTemplates/instanceTemplate - projects/project/global/instanceTemplates/instanceTemplate - global/instanceTemplates/instanceTemplate + optional string source_instance_template = 332423616; + + // Specifies the machine image to use to create the instance. This field is optional. It can be a full or partial URL. For example, the following are all valid URLs to a machine image: - https://www.googleapis.com/compute/v1/projects/project/global/global /machineImages/machineImage - projects/project/global/global/machineImages/machineImage - global/machineImages/machineImage + optional string source_machine_image = 21769791; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for InstanceTemplates.Insert. See the method description for details. +message InsertInstanceTemplateRequest { + // The body resource for this request + InstanceTemplate instance_template_resource = 10679561 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for InterconnectAttachments.Insert. See the method description for details. +message InsertInterconnectAttachmentRequest { + // The body resource for this request + InterconnectAttachment interconnect_attachment_resource = 212341369 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // If true, the request will not be committed. + optional bool validate_only = 242744629; + +} + +// A request message for Interconnects.Insert. See the method description for details. +message InsertInterconnectRequest { + // The body resource for this request + Interconnect interconnect_resource = 397611167 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Licenses.Insert. See the method description for details. +message InsertLicenseRequest { + // The body resource for this request + License license_resource = 437955148 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for MachineImages.Insert. See the method description for details. +message InsertMachineImageRequest { + // The body resource for this request + MachineImage machine_image_resource = 60740970 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Required. Source instance that is used to create the machine image from. + optional string source_instance = 396315705; + +} + +// A request message for NetworkAttachments.Insert. See the method description for details. +message InsertNetworkAttachmentRequest { + // The body resource for this request + NetworkAttachment network_attachment_resource = 210974745 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region of this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). end_interface: MixerMutationRequestBuilder + optional string request_id = 37109963; + +} + +// A request message for NetworkEdgeSecurityServices.Insert. See the method description for details. +message InsertNetworkEdgeSecurityServiceRequest { + // The body resource for this request + NetworkEdgeSecurityService network_edge_security_service_resource = 477548966 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // If true, the request will not be committed. + optional bool validate_only = 242744629; + +} + +// A request message for NetworkEndpointGroups.Insert. See the method description for details. +message InsertNetworkEndpointGroupRequest { + // The body resource for this request + NetworkEndpointGroup network_endpoint_group_resource = 525788839 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where you want to create the network endpoint group. It should comply with RFC1035. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for NetworkFirewallPolicies.Insert. See the method description for details. +message InsertNetworkFirewallPolicyRequest { + // The body resource for this request + FirewallPolicy firewall_policy_resource = 495049532 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Networks.Insert. See the method description for details. +message InsertNetworkRequest { + // The body resource for this request + Network network_resource = 122105599 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for NodeGroups.Insert. See the method description for details. +message InsertNodeGroupRequest { + // Initial count of nodes in the node group. + int32 initial_node_count = 71951469 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + NodeGroup node_group_resource = 505321899 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for NodeTemplates.Insert. See the method description for details. +message InsertNodeTemplateRequest { + // The body resource for this request + NodeTemplate node_template_resource = 127364406 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for PacketMirrorings.Insert. See the method description for details. +message InsertPacketMirroringRequest { + // The body resource for this request + PacketMirroring packet_mirroring_resource = 493501985 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for PublicAdvertisedPrefixes.Insert. See the method description for details. +message InsertPublicAdvertisedPrefixeRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The body resource for this request + PublicAdvertisedPrefix public_advertised_prefix_resource = 233614223 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for PublicDelegatedPrefixes.Insert. See the method description for details. +message InsertPublicDelegatedPrefixeRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The body resource for this request + PublicDelegatedPrefix public_delegated_prefix_resource = 47594501 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region of this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionAutoscalers.Insert. See the method description for details. +message InsertRegionAutoscalerRequest { + // The body resource for this request + Autoscaler autoscaler_resource = 207616118 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionBackendServices.Insert. See the method description for details. +message InsertRegionBackendServiceRequest { + // The body resource for this request + BackendService backend_service_resource = 347586723 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionCommitments.Insert. See the method description for details. +message InsertRegionCommitmentRequest { + // The body resource for this request + Commitment commitment_resource = 244240888 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionDisks.Insert. See the method description for details. +message InsertRegionDiskRequest { + // The body resource for this request + Disk disk_resource = 25880688 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Source image to restore onto a disk. This field is optional. + optional string source_image = 50443319; + +} + +// A request message for RegionHealthChecks.Insert. See the method description for details. +message InsertRegionHealthCheckRequest { + // The body resource for this request + HealthCheck health_check_resource = 201925032 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionHealthCheckServices.Insert. See the method description for details. +message InsertRegionHealthCheckServiceRequest { + // The body resource for this request + HealthCheckService health_check_service_resource = 477367794 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionInstanceGroupManagers.Insert. See the method description for details. +message InsertRegionInstanceGroupManagerRequest { + // The body resource for this request + InstanceGroupManager instance_group_manager_resource = 261063946 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionInstanceTemplates.Insert. See the method description for details. +message InsertRegionInstanceTemplateRequest { + // The body resource for this request + InstanceTemplate instance_template_resource = 10679561 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionNetworkEndpointGroups.Insert. See the method description for details. +message InsertRegionNetworkEndpointGroupRequest { + // The body resource for this request + NetworkEndpointGroup network_endpoint_group_resource = 525788839 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The name of the region where you want to create the network endpoint group. It should comply with RFC1035. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionNetworkFirewallPolicies.Insert. See the method description for details. +message InsertRegionNetworkFirewallPolicyRequest { + // The body resource for this request + FirewallPolicy firewall_policy_resource = 495049532 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionNotificationEndpoints.Insert. See the method description for details. +message InsertRegionNotificationEndpointRequest { + // The body resource for this request + NotificationEndpoint notification_endpoint_resource = 338459940 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionSecurityPolicies.Insert. See the method description for details. +message InsertRegionSecurityPolicyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + SecurityPolicy security_policy_resource = 216159612 [(google.api.field_behavior) = REQUIRED]; + + // If true, the request will not be committed. + optional bool validate_only = 242744629; + +} + +// A request message for RegionSslCertificates.Insert. See the method description for details. +message InsertRegionSslCertificateRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + SslCertificate ssl_certificate_resource = 180709897 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionSslPolicies.Insert. See the method description for details. +message InsertRegionSslPolicyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + SslPolicy ssl_policy_resource = 274891848 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionTargetHttpProxies.Insert. See the method description for details. +message InsertRegionTargetHttpProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetHttpProxy target_http_proxy_resource = 24696744 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionTargetHttpsProxies.Insert. See the method description for details. +message InsertRegionTargetHttpsProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetHttpsProxy target_https_proxy_resource = 433657473 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionTargetTcpProxies.Insert. See the method description for details. +message InsertRegionTargetTcpProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetTcpProxy target_tcp_proxy_resource = 145913931 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionUrlMaps.Insert. See the method description for details. +message InsertRegionUrlMapRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // begin_interface: MixerMutationRequestBuilder Request ID to support idempotency. + optional string request_id = 37109963; + + // The body resource for this request + UrlMap url_map_resource = 168675425 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Reservations.Insert. See the method description for details. +message InsertReservationRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + Reservation reservation_resource = 285030177 [(google.api.field_behavior) = REQUIRED]; + + // Name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for ResourcePolicies.Insert. See the method description for details. +message InsertResourcePolicyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + ResourcePolicy resource_policy_resource = 76826186 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Routes.Insert. See the method description for details. +message InsertRouteRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + Route route_resource = 225428804 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Routers.Insert. See the method description for details. +message InsertRouterRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + Router router_resource = 155222084 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for SecurityPolicies.Insert. See the method description for details. +message InsertSecurityPolicyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + SecurityPolicy security_policy_resource = 216159612 [(google.api.field_behavior) = REQUIRED]; + + // If true, the request will not be committed. + optional bool validate_only = 242744629; + +} + +// A request message for ServiceAttachments.Insert. See the method description for details. +message InsertServiceAttachmentRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region of this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + ServiceAttachment service_attachment_resource = 472980256 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Snapshots.Insert. See the method description for details. +message InsertSnapshotRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + Snapshot snapshot_resource = 481319977 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for SslCertificates.Insert. See the method description for details. +message InsertSslCertificateRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + SslCertificate ssl_certificate_resource = 180709897 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for SslPolicies.Insert. See the method description for details. +message InsertSslPolicyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + SslPolicy ssl_policy_resource = 274891848 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Subnetworks.Insert. See the method description for details. +message InsertSubnetworkRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + Subnetwork subnetwork_resource = 42233151 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetGrpcProxies.Insert. See the method description for details. +message InsertTargetGrpcProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetGrpcProxy target_grpc_proxy_resource = 328922450 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetHttpProxies.Insert. See the method description for details. +message InsertTargetHttpProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetHttpProxy target_http_proxy_resource = 24696744 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetHttpsProxies.Insert. See the method description for details. +message InsertTargetHttpsProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetHttpsProxy target_https_proxy_resource = 433657473 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetInstances.Insert. See the method description for details. +message InsertTargetInstanceRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetInstance target_instance_resource = 430453066 [(google.api.field_behavior) = REQUIRED]; + + // Name of the zone scoping this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for TargetPools.Insert. See the method description for details. +message InsertTargetPoolRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetPool target_pool_resource = 101281443 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetSslProxies.Insert. See the method description for details. +message InsertTargetSslProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetSslProxy target_ssl_proxy_resource = 142016192 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetTcpProxies.Insert. See the method description for details. +message InsertTargetTcpProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetTcpProxy target_tcp_proxy_resource = 145913931 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetVpnGateways.Insert. See the method description for details. +message InsertTargetVpnGatewayRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetVpnGateway target_vpn_gateway_resource = 498050 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for UrlMaps.Insert. See the method description for details. +message InsertUrlMapRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + UrlMap url_map_resource = 168675425 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for VpnGateways.Insert. See the method description for details. +message InsertVpnGatewayRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + VpnGateway vpn_gateway_resource = 182688660 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for VpnTunnels.Insert. See the method description for details. +message InsertVpnTunnelRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + VpnTunnel vpn_tunnel_resource = 86839482 [(google.api.field_behavior) = REQUIRED]; + +} + +// Represents an Instance resource. An instance is a virtual machine that is hosted on Google Cloud Platform. For more information, read Virtual Machine Instances. +message Instance { + // KeyRevocationActionType of the instance. Supported options are "STOP" and "NONE". The default value is "NONE" if it is not specified. + enum KeyRevocationActionType { + // A value indicating that the enum field is not set. + UNDEFINED_KEY_REVOCATION_ACTION_TYPE = 0; + + // Default value. This value is unused. + KEY_REVOCATION_ACTION_TYPE_UNSPECIFIED = 467110106; + + // Indicates user chose no operation. + NONE = 2402104; + + // Indicates user chose to opt for VM shutdown on key revocation. + STOP = 2555906; + + } + + // The private IPv6 google access type for the VM. If not specified, use INHERIT_FROM_SUBNETWORK as default. + enum PrivateIpv6GoogleAccess { + // A value indicating that the enum field is not set. + UNDEFINED_PRIVATE_IPV6_GOOGLE_ACCESS = 0; + + // Bidirectional private IPv6 access to/from Google services. If specified, the subnetwork who is attached to the instance's default network interface will be assigned an internal IPv6 prefix if it doesn't have before. + ENABLE_BIDIRECTIONAL_ACCESS_TO_GOOGLE = 427975994; + + // Outbound private IPv6 access from VMs in this subnet to Google services. If specified, the subnetwork who is attached to the instance's default network interface will be assigned an internal IPv6 prefix if it doesn't have before. + ENABLE_OUTBOUND_VM_ACCESS_TO_GOOGLE = 288210263; + + // Each network interface inherits PrivateIpv6GoogleAccess from its subnetwork. + INHERIT_FROM_SUBNETWORK = 530256959; + + } + + // [Output Only] The status of the instance. One of the following values: PROVISIONING, STAGING, RUNNING, STOPPING, SUSPENDING, SUSPENDED, REPAIRING, and TERMINATED. For more information about the status of the instance, see Instance life cycle. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // The Nanny is halted and we are performing tear down tasks like network deprogramming, releasing quota, IP, tearing down disks etc. + DEPROVISIONING = 428935662; + + // Resources are being allocated for the instance. + PROVISIONING = 290896621; + + // The instance is in repair. + REPAIRING = 413483285; + + // The instance is running. + RUNNING = 121282975; + + // All required resources have been allocated and the instance is being started. + STAGING = 431072283; + + // The instance has stopped successfully. + STOPPED = 444276141; + + // The instance is currently stopping (either being deleted or killed). + STOPPING = 350791796; + + // The instance has suspended. + SUSPENDED = 51223995; + + // The instance is suspending. + SUSPENDING = 514206246; + + // The instance has stopped (either by explicit action or underlying failure). + TERMINATED = 250018339; + + } + + // Controls for advanced machine-related behavior features. + optional AdvancedMachineFeatures advanced_machine_features = 409646002; + + // Allows this instance to send and receive packets with non-matching destination or source IPs. This is required if you plan to use this instance to forward routes. For more information, see Enabling IP Forwarding . + optional bool can_ip_forward = 467731324; + + optional ConfidentialInstanceConfig confidential_instance_config = 490637685; + + // [Output Only] The CPU platform used by this instance. + optional string cpu_platform = 410285354; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // Whether the resource should be protected against deletion. + optional bool deletion_protection = 458014698; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Array of disks associated with this instance. Persistent disks must be created before you can assign them. + repeated AttachedDisk disks = 95594102; + + // Enables display device for the instance. + optional DisplayDevice display_device = 258933875; + + // Specifies a fingerprint for this resource, which is essentially a hash of the instance's contents and used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update the instance. You must always provide an up-to-date fingerprint hash in order to update the instance. To see the latest fingerprint, make get() request to the instance. + optional string fingerprint = 234678500; + + // A list of the type and count of accelerator cards attached to the instance. + repeated AcceleratorConfig guest_accelerators = 463595119; + + // Specifies the hostname of the instance. The specified hostname must be RFC1035 compliant. If hostname is not specified, the default hostname is [INSTANCE_NAME].c.[PROJECT_ID].internal when using the global DNS, and [INSTANCE_NAME].[ZONE].c.[PROJECT_ID].internal when using zonal DNS. + optional string hostname = 237067315; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // KeyRevocationActionType of the instance. Supported options are "STOP" and "NONE". The default value is "NONE" if it is not specified. + // Check the KeyRevocationActionType enum for the list of possible values. + optional string key_revocation_action_type = 235941474; + + // [Output Only] Type of the resource. Always compute#instance for instances. + optional string kind = 3292052; + + // A fingerprint for this request, which is essentially a hash of the label's contents and used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update labels. You must always provide an up-to-date fingerprint hash in order to update or change labels. To see the latest fingerprint, make get() request to the instance. + optional string label_fingerprint = 178124825; + + // Labels to apply to this instance. These can be later modified by the setLabels method. + map labels = 500195327; + + // [Output Only] Last start timestamp in RFC3339 text format. + optional string last_start_timestamp = 443830736; + + // [Output Only] Last stop timestamp in RFC3339 text format. + optional string last_stop_timestamp = 412823010; + + // [Output Only] Last suspended timestamp in RFC3339 text format. + optional string last_suspended_timestamp = 356275337; + + // Full or partial URL of the machine type resource to use for this instance, in the format: zones/zone/machineTypes/machine-type. This is provided by the client when the instance is created. For example, the following is a valid partial url to a predefined machine type: zones/us-central1-f/machineTypes/n1-standard-1 To create a custom machine type, provide a URL to a machine type in the following format, where CPUS is 1 or an even number up to 32 (2, 4, 6, ... 24, etc), and MEMORY is the total memory for this instance. Memory must be a multiple of 256 MB and must be supplied in MB (e.g. 5 GB of memory is 5120 MB): zones/zone/machineTypes/custom-CPUS-MEMORY For example: zones/us-central1-f/machineTypes/custom-4-5120 For a full list of restrictions, read the Specifications for custom machine types. + optional string machine_type = 227711026; + + // The metadata key/value pairs assigned to this instance. This includes custom metadata and predefined keys. + optional Metadata metadata = 86866735; + + // Specifies a minimum CPU platform for the VM instance. Applicable values are the friendly names of CPU platforms, such as minCpuPlatform: "Intel Haswell" or minCpuPlatform: "Intel Sandy Bridge". + optional string min_cpu_platform = 242912759; + + // The name of the resource, provided by the client when initially creating the resource. The resource name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // An array of network configurations for this instance. These specify how interfaces are configured to interact with other network services, such as connecting to the internet. Multiple interfaces are supported per instance. + repeated NetworkInterface network_interfaces = 52735243; + + optional NetworkPerformanceConfig network_performance_config = 398330850; + + // Input only. [Input Only] Additional params passed with the request, but not persisted as part of resource payload. + optional InstanceParams params = 78313862; + + // The private IPv6 google access type for the VM. If not specified, use INHERIT_FROM_SUBNETWORK as default. + // Check the PrivateIpv6GoogleAccess enum for the list of possible values. + optional string private_ipv6_google_access = 48277006; + + // Specifies the reservations that this instance can consume from. + optional ReservationAffinity reservation_affinity = 157850683; + + // Resource policies applied to this instance. + repeated string resource_policies = 22220385; + + // [Output Only] Specifies values set for instance attributes as compared to the values requested by user in the corresponding input only field. + optional ResourceStatus resource_status = 249429315; + + // [Output Only] Reserved for future use. + optional bool satisfies_pzs = 480964267; + + // Sets the scheduling options for this instance. + optional Scheduling scheduling = 386688404; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // A list of service accounts, with their specified scopes, authorized for this instance. Only one service account per VM instance is supported. Service accounts generate access tokens that can be accessed through the metadata server and used to authenticate applications on the instance. See Service Accounts for more information. + repeated ServiceAccount service_accounts = 277537328; + + optional ShieldedInstanceConfig shielded_instance_config = 12862901; + + optional ShieldedInstanceIntegrityPolicy shielded_instance_integrity_policy = 163696919; + + // Source machine image + optional string source_machine_image = 21769791; + + // Source machine image encryption key when creating an instance from a machine image. + optional CustomerEncryptionKey source_machine_image_encryption_key = 192839075; + + // [Output Only] Whether a VM has been restricted for start because Compute Engine has detected suspicious activity. + optional bool start_restricted = 123693144; + + // [Output Only] The status of the instance. One of the following values: PROVISIONING, STAGING, RUNNING, STOPPING, SUSPENDING, SUSPENDED, REPAIRING, and TERMINATED. For more information about the status of the instance, see Instance life cycle. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // [Output Only] An optional, human-readable explanation of the status. + optional string status_message = 297428154; + + // Tags to apply to this instance. Tags are used to identify valid sources or targets for network firewalls and are specified by the client during instance creation. The tags can be later modified by the setTags method. Each tag within the list must comply with RFC1035. Multiple tags can be specified via the 'tags.items' field. + optional Tags tags = 3552281; + + // [Output Only] URL of the zone where the instance resides. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string zone = 3744684; + +} + +// +message InstanceAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // An object that contains a list of instances scoped by zone. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#instanceAggregatedList for aggregated lists of Instance resources. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message InstanceConsumptionData { + // Resources consumed by the instance. + optional InstanceConsumptionInfo consumption_info = 146354898; + + // Server-defined URL for the instance. + optional string instance = 18257045; + +} + +// +message InstanceConsumptionInfo { + // The number of virtual CPUs that are available to the instance. + optional int32 guest_cpus = 393356754; + + // The amount of local SSD storage available to the instance, defined in GiB. + optional int32 local_ssd_gb = 329237578; + + // The amount of physical memory available to the instance, defined in MiB. + optional int32 memory_mb = 116001171; + + // The minimal guaranteed number of virtual CPUs that are reserved. + optional int32 min_node_cpus = 317231675; + +} + +// Represents an Instance Group resource. Instance Groups can be used to configure a target for load balancing. Instance groups can either be managed or unmanaged. To create managed instance groups, use the instanceGroupManager or regionInstanceGroupManager resource instead. Use zonal unmanaged instance groups if you need to apply load balancing to groups of heterogeneous instances or if you need to manage the instances yourself. You cannot create regional unmanaged instance groups. For more information, read Instance groups. +message InstanceGroup { + // [Output Only] The creation timestamp for this instance group in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] The fingerprint of the named ports. The system uses this fingerprint to detect conflicts when multiple users change the named ports concurrently. + optional string fingerprint = 234678500; + + // [Output Only] A unique identifier for this instance group, generated by the server. + optional uint64 id = 3355; + + // [Output Only] The resource type, which is always compute#instanceGroup for instance groups. + optional string kind = 3292052; + + // The name of the instance group. The name must be 1-63 characters long, and comply with RFC1035. + optional string name = 3373707; + + // Assigns a name to a port number. For example: {name: "http", port: 80} This allows the system to reference ports by the assigned name instead of a port number. Named ports can also contain multiple ports. For example: [{name: "app1", port: 8080}, {name: "app1", port: 8081}, {name: "app2", port: 8082}] Named ports apply to all instances in this instance group. + repeated NamedPort named_ports = 427598732; + + // [Output Only] The URL of the network to which all instances in the instance group belong. If your instance has multiple network interfaces, then the network and subnetwork fields only refer to the network and subnet used by your primary interface (nic0). + optional string network = 232872494; + + // [Output Only] The URL of the region where the instance group is located (for regional resources). + optional string region = 138946292; + + // [Output Only] The URL for this instance group. The server generates this URL. + optional string self_link = 456214797; + + // [Output Only] The total number of instances in the instance group. + optional int32 size = 3530753; + + // [Output Only] The URL of the subnetwork to which all instances in the instance group belong. If your instance has multiple network interfaces, then the network and subnetwork fields only refer to the network and subnet used by your primary interface (nic0). + optional string subnetwork = 307827694; + + // [Output Only] The URL of the zone where the instance group is located (for zonal resources). + optional string zone = 3744684; + +} + +// +message InstanceGroupAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of InstanceGroupsScopedList resources. + map items = 100526016; + + // [Output Only] The resource type, which is always compute#instanceGroupAggregatedList for aggregated lists of instance groups. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// A list of InstanceGroup resources. +message InstanceGroupList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of InstanceGroup resources. + repeated InstanceGroup items = 100526016; + + // [Output Only] The resource type, which is always compute#instanceGroupList for instance group lists. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Represents a Managed Instance Group resource. An instance group is a collection of VM instances that you can manage as a single entity. For more information, read Instance groups. For zonal Managed Instance Group, use the instanceGroupManagers resource. For regional Managed Instance Group, use the regionInstanceGroupManagers resource. +message InstanceGroupManager { + // Pagination behavior of the listManagedInstances API method for this managed instance group. + enum ListManagedInstancesResults { + // A value indicating that the enum field is not set. + UNDEFINED_LIST_MANAGED_INSTANCES_RESULTS = 0; + + // (Default) Pagination is disabled for the group's listManagedInstances API method. maxResults and pageToken query parameters are ignored and all instances are returned in a single response. + PAGELESS = 32183464; + + // Pagination is enabled for the group's listManagedInstances API method. maxResults and pageToken query parameters are respected. + PAGINATED = 40190637; + + } + + // The autohealing policy for this managed instance group. You can specify only one value. + repeated InstanceGroupManagerAutoHealingPolicy auto_healing_policies = 456799109; + + // The base instance name to use for instances in this group. The value must be 1-58 characters long. Instances are named by appending a hyphen and a random four-character string to the base instance name. The base instance name must comply with RFC1035. + optional string base_instance_name = 389106439; + + // [Output Only] The creation timestamp for this managed instance group in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // [Output Only] The list of instance actions and the number of instances in this managed instance group that are scheduled for each of those actions. + optional InstanceGroupManagerActionsSummary current_actions = 164045879; + + // An optional description of this resource. + optional string description = 422937596; + + // Policy specifying the intended distribution of managed instances across zones in a regional managed instance group. + optional DistributionPolicy distribution_policy = 534558541; + + // Fingerprint of this resource. This field may be used in optimistic locking. It will be ignored when inserting an InstanceGroupManager. An up-to-date fingerprint must be provided in order to update the InstanceGroupManager, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve an InstanceGroupManager. + optional string fingerprint = 234678500; + + // [Output Only] A unique identifier for this resource type. The server generates this identifier. + optional uint64 id = 3355; + + // [Output Only] The URL of the Instance Group resource. + optional string instance_group = 81095253; + + // The URL of the instance template that is specified for this managed instance group. The group uses this template to create all new instances in the managed instance group. The templates for existing instances in the group do not change unless you run recreateInstances, run applyUpdatesToInstances, or set the group's updatePolicy.type to PROACTIVE. + optional string instance_template = 309248228; + + // [Output Only] The resource type, which is always compute#instanceGroupManager for managed instance groups. + optional string kind = 3292052; + + // Pagination behavior of the listManagedInstances API method for this managed instance group. + // Check the ListManagedInstancesResults enum for the list of possible values. + optional string list_managed_instances_results = 296047156; + + // The name of the managed instance group. The name must be 1-63 characters long, and comply with RFC1035. + optional string name = 3373707; + + // Named ports configured for the Instance Groups complementary to this Instance Group Manager. + repeated NamedPort named_ports = 427598732; + + // [Output Only] The URL of the region where the managed instance group resides (for regional resources). + optional string region = 138946292; + + // [Output Only] The URL for this managed instance group. The server defines this URL. + optional string self_link = 456214797; + + // Stateful configuration for this Instanced Group Manager + optional StatefulPolicy stateful_policy = 47538565; + + // [Output Only] The status of this managed instance group. + optional InstanceGroupManagerStatus status = 181260274; + + // The URLs for all TargetPool resources to which instances in the instanceGroup field are added. The target pools automatically apply to all of the instances in the managed instance group. + repeated string target_pools = 336072617; + + // The target number of running instances for this managed instance group. You can reduce this number by using the instanceGroupManager deleteInstances or abandonInstances methods. Resizing the group also changes this number. + optional int32 target_size = 62880239; + + // The update policy for this managed instance group. + optional InstanceGroupManagerUpdatePolicy update_policy = 175809896; + + // Specifies the instance templates used by this managed instance group to create instances. Each version is defined by an instanceTemplate and a name. Every version can appear at most once per instance group. This field overrides the top-level instanceTemplate field. Read more about the relationships between these fields. Exactly one version must leave the targetSize field unset. That version will be applied to all remaining instances. For more information, read about canary updates. + repeated InstanceGroupManagerVersion versions = 162430619; + + // [Output Only] The URL of a zone where the managed instance group is located (for zonal resources). + optional string zone = 3744684; + +} + +// +message InstanceGroupManagerActionsSummary { + // [Output Only] The total number of instances in the managed instance group that are scheduled to be abandoned. Abandoning an instance removes it from the managed instance group without deleting it. + optional int32 abandoning = 440023373; + + // [Output Only] The number of instances in the managed instance group that are scheduled to be created or are currently being created. If the group fails to create any of these instances, it tries again until it creates the instance successfully. If you have disabled creation retries, this field will not be populated; instead, the creatingWithoutRetries field will be populated. + optional int32 creating = 209809081; + + // [Output Only] The number of instances that the managed instance group will attempt to create. The group attempts to create each instance only once. If the group fails to create any of these instances, it decreases the group's targetSize value accordingly. + optional int32 creating_without_retries = 369916745; + + // [Output Only] The number of instances in the managed instance group that are scheduled to be deleted or are currently being deleted. + optional int32 deleting = 282846120; + + // [Output Only] The number of instances in the managed instance group that are running and have no scheduled actions. + optional int32 none = 3387192; + + // [Output Only] The number of instances in the managed instance group that are scheduled to be recreated or are currently being being recreated. Recreating an instance deletes the existing root persistent disk and creates a new disk from the image that is defined in the instance template. + optional int32 recreating = 339057132; + + // [Output Only] The number of instances in the managed instance group that are being reconfigured with properties that do not require a restart or a recreate action. For example, setting or removing target pools for the instance. + optional int32 refreshing = 215044903; + + // [Output Only] The number of instances in the managed instance group that are scheduled to be restarted or are currently being restarted. + optional int32 restarting = 372312947; + + // [Output Only] The number of instances in the managed instance group that are scheduled to be resumed or are currently being resumed. + optional int32 resuming = 201100714; + + // [Output Only] The number of instances in the managed instance group that are scheduled to be started or are currently being started. + optional int32 starting = 243064896; + + // [Output Only] The number of instances in the managed instance group that are scheduled to be stopped or are currently being stopped. + optional int32 stopping = 105035892; + + // [Output Only] The number of instances in the managed instance group that are scheduled to be suspended or are currently being suspended. + optional int32 suspending = 29113894; + + // [Output Only] The number of instances in the managed instance group that are being verified. See the managedInstances[].currentAction property in the listManagedInstances method documentation. + optional int32 verifying = 451612873; + +} + +// +message InstanceGroupManagerAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of InstanceGroupManagersScopedList resources. + map items = 100526016; + + // [Output Only] The resource type, which is always compute#instanceGroupManagerAggregatedList for an aggregated list of managed instance groups. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message InstanceGroupManagerAutoHealingPolicy { + // The URL for the health check that signals autohealing. + optional string health_check = 308876645; + + // The number of seconds that the managed instance group waits before it applies autohealing policies to new instances or recently recreated instances. This initial delay allows instances to initialize and run their startup scripts before the instance group determines that they are UNHEALTHY. This prevents the managed instance group from recreating its instances prematurely. This value must be from range [0, 3600]. + optional int32 initial_delay_sec = 263207002; + +} + +// [Output Only] A list of managed instance groups. +message InstanceGroupManagerList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of InstanceGroupManager resources. + repeated InstanceGroupManager items = 100526016; + + // [Output Only] The resource type, which is always compute#instanceGroupManagerList for a list of managed instance groups. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message InstanceGroupManagerStatus { + // [Output Only] The URL of the Autoscaler that targets this instance group manager. + optional string autoscaler = 517258967; + + // [Output Only] A bit indicating whether the managed instance group is in a stable state. A stable state means that: none of the instances in the managed instance group is currently undergoing any type of change (for example, creation, restart, or deletion); no future changes are scheduled for instances in the managed instance group; and the managed instance group itself is not being modified. + optional bool is_stable = 108410864; + + // [Output Only] Stateful status of the given Instance Group Manager. + optional InstanceGroupManagerStatusStateful stateful = 244462412; + + // [Output Only] A status of consistency of Instances' versions with their target version specified by version field on Instance Group Manager. + optional InstanceGroupManagerStatusVersionTarget version_target = 289386200; + +} + +// +message InstanceGroupManagerStatusStateful { + // [Output Only] A bit indicating whether the managed instance group has stateful configuration, that is, if you have configured any items in a stateful policy or in per-instance configs. The group might report that it has no stateful configuration even when there is still some preserved state on a managed instance, for example, if you have deleted all PICs but not yet applied those deletions. + optional bool has_stateful_config = 110474224; + + // [Output Only] Status of per-instance configurations on the instance. + optional InstanceGroupManagerStatusStatefulPerInstanceConfigs per_instance_configs = 526265001; + +} + +// +message InstanceGroupManagerStatusStatefulPerInstanceConfigs { + // A bit indicating if all of the group's per-instance configurations (listed in the output of a listPerInstanceConfigs API call) have status EFFECTIVE or there are no per-instance-configs. + optional bool all_effective = 516540553; + +} + +// +message InstanceGroupManagerStatusVersionTarget { + // [Output Only] A bit indicating whether version target has been reached in this managed instance group, i.e. all instances are in their target version. Instances' target version are specified by version field on Instance Group Manager. + optional bool is_reached = 433209149; + +} + +// +message InstanceGroupManagerUpdatePolicy { + // The instance redistribution policy for regional managed instance groups. Valid values are: - PROACTIVE (default): The group attempts to maintain an even distribution of VM instances across zones in the region. - NONE: For non-autoscaled groups, proactive redistribution is disabled. + // Additional supported values which may be not listed in the enum directly due to technical reasons: + // NONE + // PROACTIVE + enum InstanceRedistributionType { + // A value indicating that the enum field is not set. + UNDEFINED_INSTANCE_REDISTRIBUTION_TYPE = 0; + + } + + // Minimal action to be taken on an instance. Use this option to minimize disruption as much as possible or to apply a more disruptive action than is necessary. - To limit disruption as much as possible, set the minimal action to REFRESH. If your update requires a more disruptive action, Compute Engine performs the necessary action to execute the update. - To apply a more disruptive action than is strictly necessary, set the minimal action to RESTART or REPLACE. For example, Compute Engine does not need to restart a VM to change its metadata. But if your application reads instance metadata only when a VM is restarted, you can set the minimal action to RESTART in order to pick up metadata changes. + // Additional supported values which may be not listed in the enum directly due to technical reasons: + // NONE + // REFRESH + // REPLACE + // RESTART + enum MinimalAction { + // A value indicating that the enum field is not set. + UNDEFINED_MINIMAL_ACTION = 0; + + } + + // Most disruptive action that is allowed to be taken on an instance. You can specify either NONE to forbid any actions, REFRESH to allow actions that do not need instance restart, RESTART to allow actions that can be applied without instance replacing or REPLACE to allow all possible actions. If the Updater determines that the minimal update action needed is more disruptive than most disruptive allowed action you specify it will not perform the update at all. + // Additional supported values which may be not listed in the enum directly due to technical reasons: + // NONE + // REFRESH + // REPLACE + // RESTART + enum MostDisruptiveAllowedAction { + // A value indicating that the enum field is not set. + UNDEFINED_MOST_DISRUPTIVE_ALLOWED_ACTION = 0; + + } + + // What action should be used to replace instances. See minimal_action.REPLACE + enum ReplacementMethod { + // A value indicating that the enum field is not set. + UNDEFINED_REPLACEMENT_METHOD = 0; + + // Instances will be recreated (with the same name) + RECREATE = 522644719; + + // Default option: instances will be deleted and created (with a new name) + SUBSTITUTE = 280924314; + + } + + // The type of update process. You can specify either PROACTIVE so that the instance group manager proactively executes actions in order to bring instances to their target versions or OPPORTUNISTIC so that no action is proactively executed but the update will be performed as part of other actions (for example, resizes or recreateInstances calls). + // Additional supported values which may be not listed in the enum directly due to technical reasons: + // PROACTIVE + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + // No action is being proactively performed in order to bring this IGM to its target version distribution (regardless of whether this distribution is expressed using instanceTemplate or versions field). + OPPORTUNISTIC = 429530089; + + } + + // The instance redistribution policy for regional managed instance groups. Valid values are: - PROACTIVE (default): The group attempts to maintain an even distribution of VM instances across zones in the region. - NONE: For non-autoscaled groups, proactive redistribution is disabled. + // Check the InstanceRedistributionType enum for the list of possible values. + optional string instance_redistribution_type = 292630424; + + // The maximum number of instances that can be created above the specified targetSize during the update process. This value can be either a fixed number or, if the group has 10 or more instances, a percentage. If you set a percentage, the number of instances is rounded if necessary. The default value for maxSurge is a fixed value equal to the number of zones in which the managed instance group operates. At least one of either maxSurge or maxUnavailable must be greater than 0. Learn more about maxSurge. + optional FixedOrPercent max_surge = 302572691; + + // The maximum number of instances that can be unavailable during the update process. An instance is considered available if all of the following conditions are satisfied: - The instance's status is RUNNING. - If there is a health check on the instance group, the instance's health check status must be HEALTHY at least once. If there is no health check on the group, then the instance only needs to have a status of RUNNING to be considered available. This value can be either a fixed number or, if the group has 10 or more instances, a percentage. If you set a percentage, the number of instances is rounded if necessary. The default value for maxUnavailable is a fixed value equal to the number of zones in which the managed instance group operates. At least one of either maxSurge or maxUnavailable must be greater than 0. Learn more about maxUnavailable. + optional FixedOrPercent max_unavailable = 404940277; + + // Minimal action to be taken on an instance. Use this option to minimize disruption as much as possible or to apply a more disruptive action than is necessary. - To limit disruption as much as possible, set the minimal action to REFRESH. If your update requires a more disruptive action, Compute Engine performs the necessary action to execute the update. - To apply a more disruptive action than is strictly necessary, set the minimal action to RESTART or REPLACE. For example, Compute Engine does not need to restart a VM to change its metadata. But if your application reads instance metadata only when a VM is restarted, you can set the minimal action to RESTART in order to pick up metadata changes. + // Check the MinimalAction enum for the list of possible values. + optional string minimal_action = 270567060; + + // Most disruptive action that is allowed to be taken on an instance. You can specify either NONE to forbid any actions, REFRESH to allow actions that do not need instance restart, RESTART to allow actions that can be applied without instance replacing or REPLACE to allow all possible actions. If the Updater determines that the minimal update action needed is more disruptive than most disruptive allowed action you specify it will not perform the update at all. + // Check the MostDisruptiveAllowedAction enum for the list of possible values. + optional string most_disruptive_allowed_action = 66103053; + + // What action should be used to replace instances. See minimal_action.REPLACE + // Check the ReplacementMethod enum for the list of possible values. + optional string replacement_method = 505931694; + + // The type of update process. You can specify either PROACTIVE so that the instance group manager proactively executes actions in order to bring instances to their target versions or OPPORTUNISTIC so that no action is proactively executed but the update will be performed as part of other actions (for example, resizes or recreateInstances calls). + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// +message InstanceGroupManagerVersion { + // The URL of the instance template that is specified for this managed instance group. The group uses this template to create new instances in the managed instance group until the `targetSize` for this version is reached. The templates for existing instances in the group do not change unless you run recreateInstances, run applyUpdatesToInstances, or set the group's updatePolicy.type to PROACTIVE; in those cases, existing instances are updated until the `targetSize` for this version is reached. + optional string instance_template = 309248228; + + // Name of the version. Unique among all versions in the scope of this managed instance group. + optional string name = 3373707; + + // Specifies the intended number of instances to be created from the instanceTemplate. The final number of instances created from the template will be equal to: - If expressed as a fixed number, the minimum of either targetSize.fixed or instanceGroupManager.targetSize is used. - if expressed as a percent, the targetSize would be (targetSize.percent/100 * InstanceGroupManager.targetSize) If there is a remainder, the number is rounded. If unset, this version will update any remaining instances not updated by another version. Read Starting a canary update for more information. + optional FixedOrPercent target_size = 62880239; + +} + +// +message InstanceGroupManagersAbandonInstancesRequest { + // The URLs of one or more instances to abandon. This can be a full URL or a partial URL, such as zones/[ZONE]/instances/[INSTANCE_NAME]. + repeated string instances = 29097598; + +} + +// InstanceGroupManagers.applyUpdatesToInstances +message InstanceGroupManagersApplyUpdatesRequest { + // The minimal action that you want to perform on each instance during the update: - REPLACE: At minimum, delete the instance and create it again. - RESTART: Stop the instance and start it again. - REFRESH: Do not stop the instance. - NONE: Do not disrupt the instance at all. By default, the minimum action is NONE. If your update requires a more disruptive action than you set with this flag, the necessary action is performed to execute the update. + // Additional supported values which may be not listed in the enum directly due to technical reasons: + // NONE + // REFRESH + // REPLACE + // RESTART + enum MinimalAction { + // A value indicating that the enum field is not set. + UNDEFINED_MINIMAL_ACTION = 0; + + } + + // The most disruptive action that you want to perform on each instance during the update: - REPLACE: Delete the instance and create it again. - RESTART: Stop the instance and start it again. - REFRESH: Do not stop the instance. - NONE: Do not disrupt the instance at all. By default, the most disruptive allowed action is REPLACE. If your update requires a more disruptive action than you set with this flag, the update request will fail. + // Additional supported values which may be not listed in the enum directly due to technical reasons: + // NONE + // REFRESH + // REPLACE + // RESTART + enum MostDisruptiveAllowedAction { + // A value indicating that the enum field is not set. + UNDEFINED_MOST_DISRUPTIVE_ALLOWED_ACTION = 0; + + } + + // Flag to update all instances instead of specified list of “instances”. If the flag is set to true then the instances may not be specified in the request. + optional bool all_instances = 403676512; + + // The list of URLs of one or more instances for which you want to apply updates. Each URL can be a full URL or a partial URL, such as zones/[ZONE]/instances/[INSTANCE_NAME]. + repeated string instances = 29097598; + + // The minimal action that you want to perform on each instance during the update: - REPLACE: At minimum, delete the instance and create it again. - RESTART: Stop the instance and start it again. - REFRESH: Do not stop the instance. - NONE: Do not disrupt the instance at all. By default, the minimum action is NONE. If your update requires a more disruptive action than you set with this flag, the necessary action is performed to execute the update. + // Check the MinimalAction enum for the list of possible values. + optional string minimal_action = 270567060; + + // The most disruptive action that you want to perform on each instance during the update: - REPLACE: Delete the instance and create it again. - RESTART: Stop the instance and start it again. - REFRESH: Do not stop the instance. - NONE: Do not disrupt the instance at all. By default, the most disruptive allowed action is REPLACE. If your update requires a more disruptive action than you set with this flag, the update request will fail. + // Check the MostDisruptiveAllowedAction enum for the list of possible values. + optional string most_disruptive_allowed_action = 66103053; + +} + +// InstanceGroupManagers.createInstances +message InstanceGroupManagersCreateInstancesRequest { + // [Required] List of specifications of per-instance configs. + repeated PerInstanceConfig instances = 29097598; + +} + +// +message InstanceGroupManagersDeleteInstancesRequest { + // The URLs of one or more instances to delete. This can be a full URL or a partial URL, such as zones/[ZONE]/instances/[INSTANCE_NAME]. + repeated string instances = 29097598; + + // Specifies whether the request should proceed despite the inclusion of instances that are not members of the group or that are already in the process of being deleted or abandoned. If this field is set to `false` and such an instance is specified in the request, the operation fails. The operation always fails if the request contains a malformed instance URL or a reference to an instance that exists in a zone or region other than the group's zone or region. + optional bool skip_instances_on_validation_error = 40631073; + +} + +// InstanceGroupManagers.deletePerInstanceConfigs +message InstanceGroupManagersDeletePerInstanceConfigsReq { + // The list of instance names for which we want to delete per-instance configs on this managed instance group. + repeated string names = 104585032; + +} + +// +message InstanceGroupManagersListErrorsResponse { + // [Output Only] The list of errors of the managed instance group. + repeated InstanceManagedByIgmError items = 100526016; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + +} + +// +message InstanceGroupManagersListManagedInstancesResponse { + // [Output Only] The list of instances in the managed instance group. + repeated ManagedInstance managed_instances = 336219614; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + +} + +// +message InstanceGroupManagersListPerInstanceConfigsResp { + // [Output Only] The list of PerInstanceConfig. + repeated PerInstanceConfig items = 100526016; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// InstanceGroupManagers.patchPerInstanceConfigs +message InstanceGroupManagersPatchPerInstanceConfigsReq { + // The list of per-instance configurations to insert or patch on this managed instance group. + repeated PerInstanceConfig per_instance_configs = 526265001; + +} + +// +message InstanceGroupManagersRecreateInstancesRequest { + // The URLs of one or more instances to recreate. This can be a full URL or a partial URL, such as zones/[ZONE]/instances/[INSTANCE_NAME]. + repeated string instances = 29097598; + +} + +// +message InstanceGroupManagersScopedList { + // [Output Only] The list of managed instance groups that are contained in the specified project and zone. + repeated InstanceGroupManager instance_group_managers = 214072592; + + // [Output Only] The warning that replaces the list of managed instance groups when the list is empty. + optional Warning warning = 50704284; + +} + +// +message InstanceGroupManagersSetInstanceTemplateRequest { + // The URL of the instance template that is specified for this managed instance group. The group uses this template to create all new instances in the managed instance group. The templates for existing instances in the group do not change unless you run recreateInstances, run applyUpdatesToInstances, or set the group's updatePolicy.type to PROACTIVE. + optional string instance_template = 309248228; + +} + +// +message InstanceGroupManagersSetTargetPoolsRequest { + // The fingerprint of the target pools information. Use this optional property to prevent conflicts when multiple users change the target pools settings concurrently. Obtain the fingerprint with the instanceGroupManagers.get method. Then, include the fingerprint in your request to ensure that you do not overwrite changes that were applied from another concurrent request. + optional string fingerprint = 234678500; + + // The list of target pool URLs that instances in this managed instance group belong to. The managed instance group applies these target pools to all of the instances in the group. Existing instances and new instances in the group all receive these target pool settings. + repeated string target_pools = 336072617; + +} + +// InstanceGroupManagers.updatePerInstanceConfigs +message InstanceGroupManagersUpdatePerInstanceConfigsReq { + // The list of per-instance configurations to insert or patch on this managed instance group. + repeated PerInstanceConfig per_instance_configs = 526265001; + +} + +// +message InstanceGroupsAddInstancesRequest { + // The list of instances to add to the instance group. + repeated InstanceReference instances = 29097598; + +} + +// +message InstanceGroupsListInstances { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of InstanceWithNamedPorts resources. + repeated InstanceWithNamedPorts items = 100526016; + + // [Output Only] The resource type, which is always compute#instanceGroupsListInstances for the list of instances in the specified instance group. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message InstanceGroupsListInstancesRequest { + // A filter for the state of the instances in the instance group. Valid options are ALL or RUNNING. If you do not specify this parameter the list includes all instances regardless of their state. + enum InstanceState { + // A value indicating that the enum field is not set. + UNDEFINED_INSTANCE_STATE = 0; + + // Includes all instances in the generated list regardless of their state. + ALL = 64897; + + // Includes instances in the generated list only if they have a RUNNING state. + RUNNING = 121282975; + + } + + // A filter for the state of the instances in the instance group. Valid options are ALL or RUNNING. If you do not specify this parameter the list includes all instances regardless of their state. + // Check the InstanceState enum for the list of possible values. + optional string instance_state = 92223591; + +} + +// +message InstanceGroupsRemoveInstancesRequest { + // The list of instances to remove from the instance group. + repeated InstanceReference instances = 29097598; + +} + +// +message InstanceGroupsScopedList { + // [Output Only] The list of instance groups that are contained in this scope. + repeated InstanceGroup instance_groups = 366469310; + + // [Output Only] An informational warning that replaces the list of instance groups when the list is empty. + optional Warning warning = 50704284; + +} + +// +message InstanceGroupsSetNamedPortsRequest { + // The fingerprint of the named ports information for this instance group. Use this optional property to prevent conflicts when multiple users change the named ports settings concurrently. Obtain the fingerprint with the instanceGroups.get method. Then, include the fingerprint in your request to ensure that you do not overwrite changes that were applied from another concurrent request. A request with an incorrect fingerprint will fail with error 412 conditionNotMet. + optional string fingerprint = 234678500; + + // The list of named ports to set for this instance group. + repeated NamedPort named_ports = 427598732; + +} + +// Contains a list of instances. +message InstanceList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Instance resources. + repeated Instance items = 100526016; + + // [Output Only] Type of resource. Always compute#instanceList for lists of Instance resources. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of instance referrers. +message InstanceListReferrers { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Reference resources. + repeated Reference items = 100526016; + + // [Output Only] Type of resource. Always compute#instanceListReferrers for lists of Instance referrers. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message InstanceManagedByIgmError { + // [Output Only] Contents of the error. + optional InstanceManagedByIgmErrorManagedInstanceError error = 96784904; + + // [Output Only] Details of the instance action that triggered this error. May be null, if the error was not caused by an action on an instance. This field is optional. + optional InstanceManagedByIgmErrorInstanceActionDetails instance_action_details = 292224547; + + // [Output Only] The time that this error occurred. This value is in RFC3339 text format. + optional string timestamp = 55126294; + +} + +// +message InstanceManagedByIgmErrorInstanceActionDetails { + // [Output Only] Action that managed instance group was executing on the instance when the error occurred. Possible values: + enum Action { + // A value indicating that the enum field is not set. + UNDEFINED_ACTION = 0; + + // The managed instance group is abandoning this instance. The instance will be removed from the instance group and from any target pools that are associated with this group. + ABANDONING = 388244813; + + // The managed instance group is creating this instance. If the group fails to create this instance, it will try again until it is successful. + CREATING = 455564985; + + // The managed instance group is attempting to create this instance only once. If the group fails to create this instance, it does not try again and the group's targetSize value is decreased. + CREATING_WITHOUT_RETRIES = 428843785; + + // The managed instance group is permanently deleting this instance. + DELETING = 528602024; + + // The managed instance group has not scheduled any actions for this instance. + NONE = 2402104; + + // The managed instance group is recreating this instance. + RECREATING = 287278572; + + // The managed instance group is applying configuration changes to the instance without stopping it. For example, the group can update the target pool list for an instance without stopping that instance. + REFRESHING = 163266343; + + // The managed instance group is restarting this instance. + RESTARTING = 320534387; + + // The managed instance group is resuming this instance. + RESUMING = 446856618; + + // The managed instance group is starting this instance. + STARTING = 488820800; + + // The managed instance group is stopping this instance. + STOPPING = 350791796; + + // The managed instance group is suspending this instance. + SUSPENDING = 514206246; + + // The managed instance group is verifying this already created instance. Verification happens every time the instance is (re)created or restarted and consists of: 1. Waiting until health check specified as part of this managed instance group's autohealing policy reports HEALTHY. Note: Applies only if autohealing policy has a health check specified 2. Waiting for addition verification steps performed as post-instance creation (subject to future extensions). + VERIFYING = 16982185; + + } + + // [Output Only] Action that managed instance group was executing on the instance when the error occurred. Possible values: + // Check the Action enum for the list of possible values. + optional string action = 187661878; + + // [Output Only] The URL of the instance. The URL can be set even if the instance has not yet been created. + optional string instance = 18257045; + + // [Output Only] Version this instance was created from, or was being created from, but the creation failed. Corresponds to one of the versions that were set on the Instance Group Manager resource at the time this instance was being created. + optional ManagedInstanceVersion version = 351608024; + +} + +// +message InstanceManagedByIgmErrorManagedInstanceError { + // [Output Only] Error code. + optional string code = 3059181; + + // [Output Only] Error message. + optional string message = 418054151; + +} + +// +message InstanceMoveRequest { + // The URL of the destination zone to move the instance. This can be a full or partial URL. For example, the following are all valid URLs to a zone: - https://www.googleapis.com/compute/v1/projects/project/zones/zone - projects/project/zones/zone - zones/zone + optional string destination_zone = 131854653; + + // The URL of the target instance to move. This can be a full or partial URL. For example, the following are all valid URLs to an instance: - https://www.googleapis.com/compute/v1/projects/project/zones/zone /instances/instance - projects/project/zones/zone/instances/instance - zones/zone/instances/instance + optional string target_instance = 289769347; + +} + +// Additional instance params. +message InstanceParams { + // Resource manager tags to be bound to the instance. Tag keys and values have the same definition as resource manager tags. Keys must be in the format `tagKeys/{tag_key_id}`, and values are in the format `tagValues/456`. The field is ignored (both PUT & PATCH) when empty. + map resource_manager_tags = 377671164; + +} + +// +message InstanceProperties { + // KeyRevocationActionType of the instance. Supported options are "STOP" and "NONE". The default value is "NONE" if it is not specified. + enum KeyRevocationActionType { + // A value indicating that the enum field is not set. + UNDEFINED_KEY_REVOCATION_ACTION_TYPE = 0; + + // Default value. This value is unused. + KEY_REVOCATION_ACTION_TYPE_UNSPECIFIED = 467110106; + + // Indicates user chose no operation. + NONE = 2402104; + + // Indicates user chose to opt for VM shutdown on key revocation. + STOP = 2555906; + + } + + // The private IPv6 google access type for VMs. If not specified, use INHERIT_FROM_SUBNETWORK as default. Note that for MachineImage, this is not supported yet. + enum PrivateIpv6GoogleAccess { + // A value indicating that the enum field is not set. + UNDEFINED_PRIVATE_IPV6_GOOGLE_ACCESS = 0; + + // Bidirectional private IPv6 access to/from Google services. If specified, the subnetwork who is attached to the instance's default network interface will be assigned an internal IPv6 prefix if it doesn't have before. + ENABLE_BIDIRECTIONAL_ACCESS_TO_GOOGLE = 427975994; + + // Outbound private IPv6 access from VMs in this subnet to Google services. If specified, the subnetwork who is attached to the instance's default network interface will be assigned an internal IPv6 prefix if it doesn't have before. + ENABLE_OUTBOUND_VM_ACCESS_TO_GOOGLE = 288210263; + + // Each network interface inherits PrivateIpv6GoogleAccess from its subnetwork. + INHERIT_FROM_SUBNETWORK = 530256959; + + } + + // Controls for advanced machine-related behavior features. Note that for MachineImage, this is not supported yet. + optional AdvancedMachineFeatures advanced_machine_features = 409646002; + + // Enables instances created based on these properties to send packets with source IP addresses other than their own and receive packets with destination IP addresses other than their own. If these instances will be used as an IP gateway or it will be set as the next-hop in a Route resource, specify true. If unsure, leave this set to false. See the Enable IP forwarding documentation for more information. + optional bool can_ip_forward = 467731324; + + // Specifies the Confidential Instance options. Note that for MachineImage, this is not supported yet. + optional ConfidentialInstanceConfig confidential_instance_config = 490637685; + + // An optional text description for the instances that are created from these properties. + optional string description = 422937596; + + // An array of disks that are associated with the instances that are created from these properties. + repeated AttachedDisk disks = 95594102; + + // A list of guest accelerator cards' type and count to use for instances created from these properties. + repeated AcceleratorConfig guest_accelerators = 463595119; + + // KeyRevocationActionType of the instance. Supported options are "STOP" and "NONE". The default value is "NONE" if it is not specified. + // Check the KeyRevocationActionType enum for the list of possible values. + optional string key_revocation_action_type = 235941474; + + // Labels to apply to instances that are created from these properties. + map labels = 500195327; + + // The machine type to use for instances that are created from these properties. + optional string machine_type = 227711026; + + // The metadata key/value pairs to assign to instances that are created from these properties. These pairs can consist of custom metadata or predefined keys. See Project and instance metadata for more information. + optional Metadata metadata = 86866735; + + // Minimum cpu/platform to be used by instances. The instance may be scheduled on the specified or newer cpu/platform. Applicable values are the friendly names of CPU platforms, such as minCpuPlatform: "Intel Haswell" or minCpuPlatform: "Intel Sandy Bridge". For more information, read Specifying a Minimum CPU Platform. + optional string min_cpu_platform = 242912759; + + // An array of network access configurations for this interface. + repeated NetworkInterface network_interfaces = 52735243; + + // Note that for MachineImage, this is not supported yet. + optional NetworkPerformanceConfig network_performance_config = 398330850; + + // The private IPv6 google access type for VMs. If not specified, use INHERIT_FROM_SUBNETWORK as default. Note that for MachineImage, this is not supported yet. + // Check the PrivateIpv6GoogleAccess enum for the list of possible values. + optional string private_ipv6_google_access = 48277006; + + // Specifies the reservations that instances can consume from. Note that for MachineImage, this is not supported yet. + optional ReservationAffinity reservation_affinity = 157850683; + + // Resource manager tags to be bound to the instance. Tag keys and values have the same definition as resource manager tags. Keys must be in the format `tagKeys/{tag_key_id}`, and values are in the format `tagValues/456`. The field is ignored (both PUT & PATCH) when empty. + map resource_manager_tags = 377671164; + + // Resource policies (names, not URLs) applied to instances created from these properties. Note that for MachineImage, this is not supported yet. + repeated string resource_policies = 22220385; + + // Specifies the scheduling options for the instances that are created from these properties. + optional Scheduling scheduling = 386688404; + + // A list of service accounts with specified scopes. Access tokens for these service accounts are available to the instances that are created from these properties. Use metadata queries to obtain the access tokens for these instances. + repeated ServiceAccount service_accounts = 277537328; + + // Note that for MachineImage, this is not supported yet. + optional ShieldedInstanceConfig shielded_instance_config = 12862901; + + // A list of tags to apply to the instances that are created from these properties. The tags identify valid sources or targets for network firewalls. The setTags method can modify this list of tags. Each tag within the list must comply with RFC1035. + optional Tags tags = 3552281; + +} + +// +message InstanceReference { + // The URL for a specific instance. @required compute.instancegroups.addInstances/removeInstances + optional string instance = 18257045; + +} + +// Represents an Instance Template resource. You can use instance templates to create VM instances and managed instance groups. For more information, read Instance Templates. +message InstanceTemplate { + // [Output Only] The creation timestamp for this instance template in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] A unique identifier for this instance template. The server defines this identifier. + optional uint64 id = 3355; + + // [Output Only] The resource type, which is always compute#instanceTemplate for instance templates. + optional string kind = 3292052; + + // Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // The instance properties for this instance template. + optional InstanceProperties properties = 147688755; + + // [Output Only] URL of the region where the instance template resides. Only applicable for regional resources. + optional string region = 138946292; + + // [Output Only] The URL for this instance template. The server defines this URL. + optional string self_link = 456214797; + + // The source instance used to create the template. You can provide this as a partial or full URL to the resource. For example, the following are valid values: - https://www.googleapis.com/compute/v1/projects/project/zones/zone /instances/instance - projects/project/zones/zone/instances/instance + optional string source_instance = 396315705; + + // The source instance params to use to create this instance template. + optional SourceInstanceParams source_instance_params = 135342156; + +} + +// Contains a list of InstanceTemplatesScopedList. +message InstanceTemplateAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of InstanceTemplatesScopedList resources. + map items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// A list of instance templates. +message InstanceTemplateList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of InstanceTemplate resources. + repeated InstanceTemplate items = 100526016; + + // [Output Only] The resource type, which is always compute#instanceTemplatesListResponse for instance template lists. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message InstanceTemplatesScopedList { + // [Output Only] A list of instance templates that are contained within the specified project and zone. + repeated InstanceTemplate instance_templates = 459889679; + + // [Output Only] An informational warning that replaces the list of instance templates when the list is empty. + optional Warning warning = 50704284; + +} + +// +message InstanceWithNamedPorts { + // [Output Only] The status of the instance. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // The Nanny is halted and we are performing tear down tasks like network deprogramming, releasing quota, IP, tearing down disks etc. + DEPROVISIONING = 428935662; + + // Resources are being allocated for the instance. + PROVISIONING = 290896621; + + // The instance is in repair. + REPAIRING = 413483285; + + // The instance is running. + RUNNING = 121282975; + + // All required resources have been allocated and the instance is being started. + STAGING = 431072283; + + // The instance has stopped successfully. + STOPPED = 444276141; + + // The instance is currently stopping (either being deleted or killed). + STOPPING = 350791796; + + // The instance has suspended. + SUSPENDED = 51223995; + + // The instance is suspending. + SUSPENDING = 514206246; + + // The instance has stopped (either by explicit action or underlying failure). + TERMINATED = 250018339; + + } + + // [Output Only] The URL of the instance. + optional string instance = 18257045; + + // [Output Only] The named ports that belong to this instance group. + repeated NamedPort named_ports = 427598732; + + // [Output Only] The status of the instance. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + +} + +// +message InstancesAddResourcePoliciesRequest { + // Resource policies to be added to this instance. + repeated string resource_policies = 22220385; + +} + +// +message InstancesGetEffectiveFirewallsResponse { + // Effective firewalls from firewall policies. + repeated InstancesGetEffectiveFirewallsResponseEffectiveFirewallPolicy firewall_policys = 410985794; + + // Effective firewalls on the instance. + repeated Firewall firewalls = 272245619; + +} + +// +message InstancesGetEffectiveFirewallsResponseEffectiveFirewallPolicy { + // [Output Only] The type of the firewall policy. Can be one of HIERARCHY, NETWORK, NETWORK_REGIONAL. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + HIERARCHY = 69902869; + + NETWORK = 413984270; + + NETWORK_REGIONAL = 190804272; + + UNSPECIFIED = 526786327; + + } + + // [Output Only] Deprecated, please use short name instead. The display name of the firewall policy. + optional string display_name = 4473832; + + // [Output Only] The name of the firewall policy. + optional string name = 3373707; + + // The rules that apply to the network. + repeated FirewallPolicyRule rules = 108873975; + + // [Output Only] The short name of the firewall policy. + optional string short_name = 492051566; + + // [Output Only] The type of the firewall policy. Can be one of HIERARCHY, NETWORK, NETWORK_REGIONAL. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// +message InstancesRemoveResourcePoliciesRequest { + // Resource policies to be removed from this instance. + repeated string resource_policies = 22220385; + +} + +// +message InstancesScopedList { + // [Output Only] A list of instances contained in this scope. + repeated Instance instances = 29097598; + + // [Output Only] Informational warning which replaces the list of instances when the list is empty. + optional Warning warning = 50704284; + +} + +// +message InstancesSetLabelsRequest { + // Fingerprint of the previous set of labels for this resource, used to prevent conflicts. Provide the latest fingerprint value when making a request to add or change labels. + optional string label_fingerprint = 178124825; + + map labels = 500195327; + +} + +// +message InstancesSetMachineResourcesRequest { + // A list of the type and count of accelerator cards attached to the instance. + repeated AcceleratorConfig guest_accelerators = 463595119; + +} + +// +message InstancesSetMachineTypeRequest { + // Full or partial URL of the machine type resource. See Machine Types for a full list of machine types. For example: zones/us-central1-f/machineTypes/n1-standard-1 + optional string machine_type = 227711026; + +} + +// +message InstancesSetMinCpuPlatformRequest { + // Minimum cpu/platform this instance should be started at. + optional string min_cpu_platform = 242912759; + +} + +// +message InstancesSetNameRequest { + // The current name of this resource, used to prevent conflicts. Provide the latest name when making a request to change name. + optional string current_name = 394983825; + + // The name to be applied to the instance. Needs to be RFC 1035 compliant. + optional string name = 3373707; + +} + +// +message InstancesSetServiceAccountRequest { + // Email address of the service account. + optional string email = 96619420; + + // The list of scopes to be made available for this service account. + repeated string scopes = 165973151; + +} + +// +message InstancesStartWithEncryptionKeyRequest { + // Array of disks associated with this instance that are protected with a customer-supplied encryption key. In order to start the instance, the disk url and its corresponding key must be provided. If the disk is not protected with a customer-supplied encryption key it should not be specified. + repeated CustomerEncryptionKeyProtectedDisk disks = 95594102; + +} + +// HttpRouteRuleMatch criteria for field values that must stay within the specified integer range. +message Int64RangeMatch { + // The end of the range (exclusive) in signed long integer format. + optional int64 range_end = 322439897; + + // The start of the range (inclusive) in signed long integer format. + optional int64 range_start = 103333600; + +} + +// Represents an Interconnect resource. An Interconnect resource is a dedicated connection between the GCP network and your on-premises network. For more information, read the Dedicated Interconnect Overview. +message Interconnect { + // Type of interconnect, which can take one of the following values: - PARTNER: A partner-managed interconnection shared between customers though a partner. - DEDICATED: A dedicated physical interconnection with the customer. Note that a value IT_PRIVATE has been deprecated in favor of DEDICATED. + enum InterconnectType { + // A value indicating that the enum field is not set. + UNDEFINED_INTERCONNECT_TYPE = 0; + + // A dedicated physical interconnection with the customer. + DEDICATED = 258411983; + + // [Deprecated] A private, physical interconnection with the customer. + IT_PRIVATE = 335677007; + + // A partner-managed interconnection shared between customers via partner. + PARTNER = 461924520; + + } + + // Type of link requested, which can take one of the following values: - LINK_TYPE_ETHERNET_10G_LR: A 10G Ethernet with LR optics - LINK_TYPE_ETHERNET_100G_LR: A 100G Ethernet with LR optics. Note that this field indicates the speed of each of the links in the bundle, not the speed of the entire bundle. + enum LinkType { + // A value indicating that the enum field is not set. + UNDEFINED_LINK_TYPE = 0; + + // 100G Ethernet, LR Optics. + LINK_TYPE_ETHERNET_100G_LR = 337672551; + + // 10G Ethernet, LR Optics. [(rate_bps) = 10000000000]; + LINK_TYPE_ETHERNET_10G_LR = 236739749; + + } + + // [Output Only] The current status of this Interconnect's functionality, which can take one of the following values: - OS_ACTIVE: A valid Interconnect, which is turned up and is ready to use. Attachments may be provisioned on this Interconnect. - OS_UNPROVISIONED: An Interconnect that has not completed turnup. No attachments may be provisioned on this Interconnect. - OS_UNDER_MAINTENANCE: An Interconnect that is undergoing internal maintenance. No attachments may be provisioned or updated on this Interconnect. + enum OperationalStatus { + // A value indicating that the enum field is not set. + UNDEFINED_OPERATIONAL_STATUS = 0; + + // The interconnect is valid, turned up, and ready to use. Attachments may be provisioned on this interconnect. + OS_ACTIVE = 55721409; + + // The interconnect has not completed turnup. No attachments may be provisioned on this interconnect. + OS_UNPROVISIONED = 239771840; + + } + + // [Output Only] The current state of Interconnect functionality, which can take one of the following values: - ACTIVE: The Interconnect is valid, turned up and ready to use. Attachments may be provisioned on this Interconnect. - UNPROVISIONED: The Interconnect has not completed turnup. No attachments may be provisioned on this Interconnect. - UNDER_MAINTENANCE: The Interconnect is undergoing internal maintenance. No attachments may be provisioned or updated on this Interconnect. + enum State { + // A value indicating that the enum field is not set. + UNDEFINED_STATE = 0; + + // The interconnect is valid, turned up, and ready to use. Attachments may be provisioned on this interconnect. + ACTIVE = 314733318; + + // The interconnect has not completed turnup. No attachments may be provisioned on this interconnect. + UNPROVISIONED = 517333979; + + } + + // Administrative status of the interconnect. When this is set to true, the Interconnect is functional and can carry traffic. When set to false, no packets can be carried over the interconnect and no BGP routes are exchanged over it. By default, the status is set to true. + optional bool admin_enabled = 445675089; + + // [Output Only] A list of CircuitInfo objects, that describe the individual circuits in this LAG. + repeated InterconnectCircuitInfo circuit_infos = 164839855; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // Customer name, to put in the Letter of Authorization as the party authorized to request a crossconnect. + optional string customer_name = 3665484; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] A list of outages expected for this Interconnect. + repeated InterconnectOutageNotification expected_outages = 264484123; + + // [Output Only] IP address configured on the Google side of the Interconnect link. This can be used only for ping tests. + optional string google_ip_address = 443105954; + + // [Output Only] Google reference ID to be used when raising support tickets with Google or otherwise to debug backend connectivity issues. + optional string google_reference_id = 534944469; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] A list of the URLs of all InterconnectAttachments configured to use this Interconnect. + repeated string interconnect_attachments = 425388415; + + // Type of interconnect, which can take one of the following values: - PARTNER: A partner-managed interconnection shared between customers though a partner. - DEDICATED: A dedicated physical interconnection with the customer. Note that a value IT_PRIVATE has been deprecated in favor of DEDICATED. + // Check the InterconnectType enum for the list of possible values. + optional string interconnect_type = 515165259; + + // [Output Only] Type of the resource. Always compute#interconnect for interconnects. + optional string kind = 3292052; + + // Type of link requested, which can take one of the following values: - LINK_TYPE_ETHERNET_10G_LR: A 10G Ethernet with LR optics - LINK_TYPE_ETHERNET_100G_LR: A 100G Ethernet with LR optics. Note that this field indicates the speed of each of the links in the bundle, not the speed of the entire bundle. + // Check the LinkType enum for the list of possible values. + optional string link_type = 523207775; + + // URL of the InterconnectLocation object that represents where this connection is to be provisioned. + optional string location = 290430901; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // Email address to contact the customer NOC for operations and maintenance notifications regarding this Interconnect. If specified, this will be used for notifications in addition to all other forms described, such as Cloud Monitoring logs alerting and Cloud Notifications. This field is required for users who sign up for Cloud Interconnect using workforce identity federation. + optional string noc_contact_email = 14072832; + + // [Output Only] The current status of this Interconnect's functionality, which can take one of the following values: - OS_ACTIVE: A valid Interconnect, which is turned up and is ready to use. Attachments may be provisioned on this Interconnect. - OS_UNPROVISIONED: An Interconnect that has not completed turnup. No attachments may be provisioned on this Interconnect. - OS_UNDER_MAINTENANCE: An Interconnect that is undergoing internal maintenance. No attachments may be provisioned or updated on this Interconnect. + // Check the OperationalStatus enum for the list of possible values. + optional string operational_status = 201070847; + + // [Output Only] IP address configured on the customer side of the Interconnect link. The customer should configure this IP address during turnup when prompted by Google NOC. This can be used only for ping tests. + optional string peer_ip_address = 207735769; + + // [Output Only] Number of links actually provisioned in this interconnect. + optional int32 provisioned_link_count = 410888565; + + // Target number of physical links in the link bundle, as requested by the customer. + optional int32 requested_link_count = 45051387; + + // [Output Only] Reserved for future use. + optional bool satisfies_pzs = 480964267; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] The current state of Interconnect functionality, which can take one of the following values: - ACTIVE: The Interconnect is valid, turned up and ready to use. Attachments may be provisioned on this Interconnect. - UNPROVISIONED: The Interconnect has not completed turnup. No attachments may be provisioned on this Interconnect. - UNDER_MAINTENANCE: The Interconnect is undergoing internal maintenance. No attachments may be provisioned or updated on this Interconnect. + // Check the State enum for the list of possible values. + optional string state = 109757585; + +} + +// Represents an Interconnect Attachment (VLAN) resource. You can use Interconnect attachments (VLANS) to connect your Virtual Private Cloud networks to your on-premises networks through an Interconnect. For more information, read Creating VLAN Attachments. +message InterconnectAttachment { + // Provisioned bandwidth capacity for the interconnect attachment. For attachments of type DEDICATED, the user can set the bandwidth. For attachments of type PARTNER, the Google Partner that is operating the interconnect must set the bandwidth. Output only for PARTNER type, mutable for PARTNER_PROVIDER and DEDICATED, and can take one of the following values: - BPS_50M: 50 Mbit/s - BPS_100M: 100 Mbit/s - BPS_200M: 200 Mbit/s - BPS_300M: 300 Mbit/s - BPS_400M: 400 Mbit/s - BPS_500M: 500 Mbit/s - BPS_1G: 1 Gbit/s - BPS_2G: 2 Gbit/s - BPS_5G: 5 Gbit/s - BPS_10G: 10 Gbit/s - BPS_20G: 20 Gbit/s - BPS_50G: 50 Gbit/s + enum Bandwidth { + // A value indicating that the enum field is not set. + UNDEFINED_BANDWIDTH = 0; + + // 100 Mbit/s + BPS_100M = 49547958; + + // 10 Gbit/s + BPS_10G = 278693006; + + // 1 Gbit/s + BPS_1G = 355358448; + + // 200 Mbit/s + BPS_200M = 49577749; + + // 20 Gbit/s + BPS_20G = 278693967; + + // 2 Gbit/s + BPS_2G = 355358479; + + // 300 Mbit/s + BPS_300M = 49607540; + + // 400 Mbit/s + BPS_400M = 49637331; + + // 500 Mbit/s + BPS_500M = 49667122; + + // 50 Gbit/s + BPS_50G = 278696850; + + // 50 Mbit/s + BPS_50M = 278696856; + + // 5 Gbit/s + BPS_5G = 355358572; + + } + + // Desired availability domain for the attachment. Only available for type PARTNER, at creation time, and can take one of the following values: - AVAILABILITY_DOMAIN_ANY - AVAILABILITY_DOMAIN_1 - AVAILABILITY_DOMAIN_2 For improved reliability, customers should configure a pair of attachments, one per availability domain. The selected availability domain will be provided to the Partner via the pairing key, so that the provisioned circuit will lie in the specified domain. If not specified, the value will default to AVAILABILITY_DOMAIN_ANY. + enum EdgeAvailabilityDomain { + // A value indicating that the enum field is not set. + UNDEFINED_EDGE_AVAILABILITY_DOMAIN = 0; + + AVAILABILITY_DOMAIN_1 = 349552090; + + AVAILABILITY_DOMAIN_2 = 349552091; + + AVAILABILITY_DOMAIN_ANY = 375256373; + + } + + // Indicates the user-supplied encryption option of this VLAN attachment (interconnectAttachment). Can only be specified at attachment creation for PARTNER or DEDICATED attachments. Possible values are: - NONE - This is the default value, which means that the VLAN attachment carries unencrypted traffic. VMs are able to send traffic to, or receive traffic from, such a VLAN attachment. - IPSEC - The VLAN attachment carries only encrypted traffic that is encrypted by an IPsec device, such as an HA VPN gateway or third-party IPsec VPN. VMs cannot directly send traffic to, or receive traffic from, such a VLAN attachment. To use *HA VPN over Cloud Interconnect*, the VLAN attachment must be created with this option. + enum Encryption { + // A value indicating that the enum field is not set. + UNDEFINED_ENCRYPTION = 0; + + // The interconnect attachment will carry only encrypted traffic that is encrypted by an IPsec device such as HA VPN gateway; VMs cannot directly send traffic to or receive traffic from such an interconnect attachment. To use HA VPN over Cloud Interconnect, the interconnect attachment must be created with this option. + IPSEC = 69882282; + + // This is the default value, which means the Interconnect Attachment will carry unencrypted traffic. VMs will be able to send traffic to or receive traffic from such interconnect attachment. + NONE = 2402104; + + } + + // [Output Only] The current status of whether or not this interconnect attachment is functional, which can take one of the following values: - OS_ACTIVE: The attachment has been turned up and is ready to use. - OS_UNPROVISIONED: The attachment is not ready to use yet, because turnup is not complete. + enum OperationalStatus { + // A value indicating that the enum field is not set. + UNDEFINED_OPERATIONAL_STATUS = 0; + + // Indicates that attachment has been turned up and is ready to use. + OS_ACTIVE = 55721409; + + // Indicates that attachment is not ready to use yet, because turnup is not complete. + OS_UNPROVISIONED = 239771840; + + } + + // The stack type for this interconnect attachment to identify whether the IPv6 feature is enabled or not. If not specified, IPV4_ONLY will be used. This field can be both set at interconnect attachments creation and update interconnect attachment operations. + enum StackType { + // A value indicating that the enum field is not set. + UNDEFINED_STACK_TYPE = 0; + + // The interconnect attachment can have both IPv4 and IPv6 addresses. + IPV4_IPV6 = 22197249; + + // The interconnect attachment will only be assigned IPv4 addresses. + IPV4_ONLY = 22373798; + + } + + // [Output Only] The current state of this attachment's functionality. Enum values ACTIVE and UNPROVISIONED are shared by DEDICATED/PRIVATE, PARTNER, and PARTNER_PROVIDER interconnect attachments, while enum values PENDING_PARTNER, PARTNER_REQUEST_RECEIVED, and PENDING_CUSTOMER are used for only PARTNER and PARTNER_PROVIDER interconnect attachments. This state can take one of the following values: - ACTIVE: The attachment has been turned up and is ready to use. - UNPROVISIONED: The attachment is not ready to use yet, because turnup is not complete. - PENDING_PARTNER: A newly-created PARTNER attachment that has not yet been configured on the Partner side. - PARTNER_REQUEST_RECEIVED: A PARTNER attachment is in the process of provisioning after a PARTNER_PROVIDER attachment was created that references it. - PENDING_CUSTOMER: A PARTNER or PARTNER_PROVIDER attachment that is waiting for a customer to activate it. - DEFUNCT: The attachment was deleted externally and is no longer functional. This could be because the associated Interconnect was removed, or because the other side of a Partner attachment was deleted. + enum State { + // A value indicating that the enum field is not set. + UNDEFINED_STATE = 0; + + // Indicates that attachment has been turned up and is ready to use. + ACTIVE = 314733318; + + // The attachment was deleted externally and is no longer functional. This could be because the associated Interconnect was wiped out, or because the other side of a Partner attachment was deleted. + DEFUNCT = 115891759; + + // A PARTNER attachment is in the process of provisioning after a PARTNER_PROVIDER attachment was created that references it. + PARTNER_REQUEST_RECEIVED = 513587304; + + // PARTNER or PARTNER_PROVIDER attachment that is waiting for the customer to activate. + PENDING_CUSTOMER = 167494054; + + // A newly created PARTNER attachment that has not yet been configured on the Partner side. + PENDING_PARTNER = 387890656; + + STATE_UNSPECIFIED = 470755401; + + // Indicates that attachment is not ready to use yet, because turnup is not complete. + UNPROVISIONED = 517333979; + + } + + // The type of interconnect attachment this is, which can take one of the following values: - DEDICATED: an attachment to a Dedicated Interconnect. - PARTNER: an attachment to a Partner Interconnect, created by the customer. - PARTNER_PROVIDER: an attachment to a Partner Interconnect, created by the partner. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + // Attachment to a dedicated interconnect. + DEDICATED = 258411983; + + // Attachment to a partner interconnect, created by the customer. + PARTNER = 461924520; + + // Attachment to a partner interconnect, created by the partner. + PARTNER_PROVIDER = 483261352; + + } + + // Determines whether this Attachment will carry packets. Not present for PARTNER_PROVIDER. + optional bool admin_enabled = 445675089; + + // Provisioned bandwidth capacity for the interconnect attachment. For attachments of type DEDICATED, the user can set the bandwidth. For attachments of type PARTNER, the Google Partner that is operating the interconnect must set the bandwidth. Output only for PARTNER type, mutable for PARTNER_PROVIDER and DEDICATED, and can take one of the following values: - BPS_50M: 50 Mbit/s - BPS_100M: 100 Mbit/s - BPS_200M: 200 Mbit/s - BPS_300M: 300 Mbit/s - BPS_400M: 400 Mbit/s - BPS_500M: 500 Mbit/s - BPS_1G: 1 Gbit/s - BPS_2G: 2 Gbit/s - BPS_5G: 5 Gbit/s - BPS_10G: 10 Gbit/s - BPS_20G: 20 Gbit/s - BPS_50G: 50 Gbit/s + // Check the Bandwidth enum for the list of possible values. + optional string bandwidth = 181715121; + + // This field is not available. + repeated string candidate_ipv6_subnets = 70682522; + + // Up to 16 candidate prefixes that can be used to restrict the allocation of cloudRouterIpAddress and customerRouterIpAddress for this attachment. All prefixes must be within link-local address space (169.254.0.0/16) and must be /29 or shorter (/28, /27, etc). Google will attempt to select an unused /29 from the supplied candidate prefix(es). The request will fail if all possible /29s are in use on Google's edge. If not supplied, Google will randomly select an unused /29 from all of link-local space. + repeated string candidate_subnets = 237842938; + + // [Output Only] IPv4 address + prefix length to be configured on Cloud Router Interface for this interconnect attachment. + optional string cloud_router_ip_address = 287392776; + + // [Output Only] IPv6 address + prefix length to be configured on Cloud Router Interface for this interconnect attachment. + optional string cloud_router_ipv6_address = 451922376; + + // This field is not available. + optional string cloud_router_ipv6_interface_id = 521282701; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // [Output Only] IPv4 address + prefix length to be configured on the customer router subinterface for this interconnect attachment. + optional string customer_router_ip_address = 332475761; + + // [Output Only] IPv6 address + prefix length to be configured on the customer router subinterface for this interconnect attachment. + optional string customer_router_ipv6_address = 290127089; + + // This field is not available. + optional string customer_router_ipv6_interface_id = 380994308; + + // [Output Only] Dataplane version for this InterconnectAttachment. This field is only present for Dataplane version 2 and higher. Absence of this field in the API output indicates that the Dataplane is version 1. + optional int32 dataplane_version = 34920075; + + // An optional description of this resource. + optional string description = 422937596; + + // Desired availability domain for the attachment. Only available for type PARTNER, at creation time, and can take one of the following values: - AVAILABILITY_DOMAIN_ANY - AVAILABILITY_DOMAIN_1 - AVAILABILITY_DOMAIN_2 For improved reliability, customers should configure a pair of attachments, one per availability domain. The selected availability domain will be provided to the Partner via the pairing key, so that the provisioned circuit will lie in the specified domain. If not specified, the value will default to AVAILABILITY_DOMAIN_ANY. + // Check the EdgeAvailabilityDomain enum for the list of possible values. + optional string edge_availability_domain = 71289510; + + // Indicates the user-supplied encryption option of this VLAN attachment (interconnectAttachment). Can only be specified at attachment creation for PARTNER or DEDICATED attachments. Possible values are: - NONE - This is the default value, which means that the VLAN attachment carries unencrypted traffic. VMs are able to send traffic to, or receive traffic from, such a VLAN attachment. - IPSEC - The VLAN attachment carries only encrypted traffic that is encrypted by an IPsec device, such as an HA VPN gateway or third-party IPsec VPN. VMs cannot directly send traffic to, or receive traffic from, such a VLAN attachment. To use *HA VPN over Cloud Interconnect*, the VLAN attachment must be created with this option. + // Check the Encryption enum for the list of possible values. + optional string encryption = 97980291; + + // [Output Only] Google reference ID, to be used when raising support tickets with Google or otherwise to debug backend connectivity issues. [Deprecated] This field is not used. + optional string google_reference_id = 534944469; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // URL of the underlying Interconnect object that this attachment's traffic will traverse through. + optional string interconnect = 224601230; + + // A list of URLs of addresses that have been reserved for the VLAN attachment. Used only for the VLAN attachment that has the encryption option as IPSEC. The addresses must be regional internal IP address ranges. When creating an HA VPN gateway over the VLAN attachment, if the attachment is configured to use a regional internal IP address, then the VPN gateway's IP address is allocated from the IP address range specified here. For example, if the HA VPN gateway's interface 0 is paired to this VLAN attachment, then a regional internal IP address for the VPN gateway interface 0 will be allocated from the IP address specified for this VLAN attachment. If this field is not specified when creating the VLAN attachment, then later on when creating an HA VPN gateway on this VLAN attachment, the HA VPN gateway's IP address is allocated from the regional external IP address pool. Not currently available publicly. + repeated string ipsec_internal_addresses = 407648565; + + // [Output Only] Type of the resource. Always compute#interconnectAttachment for interconnect attachments. + optional string kind = 3292052; + + // Maximum Transmission Unit (MTU), in bytes, of packets passing through this interconnect attachment. Only 1440 and 1500 are allowed. If not specified, the value will default to 1440. + optional int32 mtu = 108462; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // [Output Only] The current status of whether or not this interconnect attachment is functional, which can take one of the following values: - OS_ACTIVE: The attachment has been turned up and is ready to use. - OS_UNPROVISIONED: The attachment is not ready to use yet, because turnup is not complete. + // Check the OperationalStatus enum for the list of possible values. + optional string operational_status = 201070847; + + // [Output only for type PARTNER. Input only for PARTNER_PROVIDER. Not present for DEDICATED]. The opaque identifier of an PARTNER attachment used to initiate provisioning with a selected partner. Of the form "XXXXX/region/domain" + optional string pairing_key = 439695464; + + // Optional BGP ASN for the router supplied by a Layer 3 Partner if they configured BGP on behalf of the customer. Output only for PARTNER type, input only for PARTNER_PROVIDER, not available for DEDICATED. + optional int64 partner_asn = 438166149; + + // Informational metadata about Partner attachments from Partners to display to customers. Output only for for PARTNER type, mutable for PARTNER_PROVIDER, not available for DEDICATED. + optional InterconnectAttachmentPartnerMetadata partner_metadata = 65908934; + + // [Output Only] Information specific to an InterconnectAttachment. This property is populated if the interconnect that this is attached to is of type DEDICATED. + optional InterconnectAttachmentPrivateInfo private_interconnect_info = 237270531; + + // [Output Only] URL of the region where the regional interconnect attachment resides. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string region = 138946292; + + // URL of the Cloud Router to be used for dynamic routing. This router must be in the same region as this InterconnectAttachment. The InterconnectAttachment will automatically connect the Interconnect to the network & region within which the Cloud Router is configured. + optional string router = 148608841; + + // [Output Only] Reserved for future use. + optional bool satisfies_pzs = 480964267; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // The stack type for this interconnect attachment to identify whether the IPv6 feature is enabled or not. If not specified, IPV4_ONLY will be used. This field can be both set at interconnect attachments creation and update interconnect attachment operations. + // Check the StackType enum for the list of possible values. + optional string stack_type = 425908881; + + // [Output Only] The current state of this attachment's functionality. Enum values ACTIVE and UNPROVISIONED are shared by DEDICATED/PRIVATE, PARTNER, and PARTNER_PROVIDER interconnect attachments, while enum values PENDING_PARTNER, PARTNER_REQUEST_RECEIVED, and PENDING_CUSTOMER are used for only PARTNER and PARTNER_PROVIDER interconnect attachments. This state can take one of the following values: - ACTIVE: The attachment has been turned up and is ready to use. - UNPROVISIONED: The attachment is not ready to use yet, because turnup is not complete. - PENDING_PARTNER: A newly-created PARTNER attachment that has not yet been configured on the Partner side. - PARTNER_REQUEST_RECEIVED: A PARTNER attachment is in the process of provisioning after a PARTNER_PROVIDER attachment was created that references it. - PENDING_CUSTOMER: A PARTNER or PARTNER_PROVIDER attachment that is waiting for a customer to activate it. - DEFUNCT: The attachment was deleted externally and is no longer functional. This could be because the associated Interconnect was removed, or because the other side of a Partner attachment was deleted. + // Check the State enum for the list of possible values. + optional string state = 109757585; + + // The type of interconnect attachment this is, which can take one of the following values: - DEDICATED: an attachment to a Dedicated Interconnect. - PARTNER: an attachment to a Partner Interconnect, created by the customer. - PARTNER_PROVIDER: an attachment to a Partner Interconnect, created by the partner. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + + // The IEEE 802.1Q VLAN tag for this attachment, in the range 2-4093. Only specified at creation time. + optional int32 vlan_tag8021q = 119927836; + +} + +// +message InterconnectAttachmentAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of InterconnectAttachmentsScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#interconnectAttachmentAggregatedList for aggregated lists of interconnect attachments. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Response to the list request, and contains a list of interconnect attachments. +message InterconnectAttachmentList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of InterconnectAttachment resources. + repeated InterconnectAttachment items = 100526016; + + // [Output Only] Type of resource. Always compute#interconnectAttachmentList for lists of interconnect attachments. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Informational metadata about Partner attachments from Partners to display to customers. These fields are propagated from PARTNER_PROVIDER attachments to their corresponding PARTNER attachments. +message InterconnectAttachmentPartnerMetadata { + // Plain text name of the Interconnect this attachment is connected to, as displayed in the Partner's portal. For instance "Chicago 1". This value may be validated to match approved Partner values. + optional string interconnect_name = 514963356; + + // Plain text name of the Partner providing this attachment. This value may be validated to match approved Partner values. + optional string partner_name = 161747874; + + // URL of the Partner's portal for this Attachment. Partners may customise this to be a deep link to the specific resource on the Partner portal. This value may be validated to match approved Partner values. + optional string portal_url = 269182748; + +} + +// Information for an interconnect attachment when this belongs to an interconnect of type DEDICATED. +message InterconnectAttachmentPrivateInfo { + // [Output Only] 802.1q encapsulation tag to be used for traffic between Google and the customer, going to and from this network and region. + optional uint32 tag8021q = 271820992; + +} + +// +message InterconnectAttachmentsScopedList { + // A list of interconnect attachments contained in this scope. + repeated InterconnectAttachment interconnect_attachments = 425388415; + + // Informational warning which replaces the list of addresses when the list is empty. + optional Warning warning = 50704284; + +} + +// Describes a single physical circuit between the Customer and Google. CircuitInfo objects are created by Google, so all fields are output only. +message InterconnectCircuitInfo { + // Customer-side demarc ID for this circuit. + optional string customer_demarc_id = 28771859; + + // Google-assigned unique ID for this circuit. Assigned at circuit turn-up. + optional string google_circuit_id = 262014711; + + // Google-side demarc ID for this circuit. Assigned at circuit turn-up and provided by Google to the customer in the LOA. + optional string google_demarc_id = 448196270; + +} + +// Diagnostics information about interconnect, contains detailed and current technical information about Google's side of the connection. +message InterconnectDiagnostics { + // The aggregation type of the bundle interface. + enum BundleAggregationType { + // A value indicating that the enum field is not set. + UNDEFINED_BUNDLE_AGGREGATION_TYPE = 0; + + // LACP is enabled. + BUNDLE_AGGREGATION_TYPE_LACP = 27758925; + + // LACP is disabled. + BUNDLE_AGGREGATION_TYPE_STATIC = 50678873; + + } + + // The operational status of the bundle interface. + enum BundleOperationalStatus { + // A value indicating that the enum field is not set. + UNDEFINED_BUNDLE_OPERATIONAL_STATUS = 0; + + // If bundleAggregationType is LACP: LACP is not established and/or all links in the bundle have DOWN operational status. If bundleAggregationType is STATIC: one or more links in the bundle has DOWN operational status. + BUNDLE_OPERATIONAL_STATUS_DOWN = 453842693; + + // If bundleAggregationType is LACP: LACP is established and at least one link in the bundle has UP operational status. If bundleAggregationType is STATIC: all links in the bundle (typically just one) have UP operational status. + BUNDLE_OPERATIONAL_STATUS_UP = 161366462; + + } + + // A list of InterconnectDiagnostics.ARPEntry objects, describing individual neighbors currently seen by the Google router in the ARP cache for the Interconnect. This will be empty when the Interconnect is not bundled. + repeated InterconnectDiagnosticsARPEntry arp_caches = 414591761; + + // The aggregation type of the bundle interface. + // Check the BundleAggregationType enum for the list of possible values. + optional string bundle_aggregation_type = 434939028; + + // The operational status of the bundle interface. + // Check the BundleOperationalStatus enum for the list of possible values. + optional string bundle_operational_status = 106433500; + + // A list of InterconnectDiagnostics.LinkStatus objects, describing the status for each link on the Interconnect. + repeated InterconnectDiagnosticsLinkStatus links = 102977465; + + // The MAC address of the Interconnect's bundle interface. + optional string mac_address = 332540164; + +} + +// Describing the ARP neighbor entries seen on this link +message InterconnectDiagnosticsARPEntry { + // The IP address of this ARP neighbor. + optional string ip_address = 406272220; + + // The MAC address of this ARP neighbor. + optional string mac_address = 332540164; + +} + +// +message InterconnectDiagnosticsLinkLACPStatus { + // The state of a LACP link, which can take one of the following values: - ACTIVE: The link is configured and active within the bundle. - DETACHED: The link is not configured within the bundle. This means that the rest of the object should be empty. + enum State { + // A value indicating that the enum field is not set. + UNDEFINED_STATE = 0; + + // The link is configured and active within the bundle. + ACTIVE = 314733318; + + // The link is not configured within the bundle, this means the rest of the object should be empty. + DETACHED = 216562546; + + } + + // System ID of the port on Google's side of the LACP exchange. + optional string google_system_id = 91210405; + + // System ID of the port on the neighbor's side of the LACP exchange. + optional string neighbor_system_id = 343821342; + + // The state of a LACP link, which can take one of the following values: - ACTIVE: The link is configured and active within the bundle. - DETACHED: The link is not configured within the bundle. This means that the rest of the object should be empty. + // Check the State enum for the list of possible values. + optional string state = 109757585; + +} + +// +message InterconnectDiagnosticsLinkOpticalPower { + // The status of the current value when compared to the warning and alarm levels for the receiving or transmitting transceiver. Possible states include: - OK: The value has not crossed a warning threshold. - LOW_WARNING: The value has crossed below the low warning threshold. - HIGH_WARNING: The value has crossed above the high warning threshold. - LOW_ALARM: The value has crossed below the low alarm threshold. - HIGH_ALARM: The value has crossed above the high alarm threshold. + enum State { + // A value indicating that the enum field is not set. + UNDEFINED_STATE = 0; + + // The value has crossed above the high alarm threshold. + HIGH_ALARM = 305363284; + + // The value of the current optical power has crossed above the high warning threshold. + HIGH_WARNING = 220984799; + + // The value of the current optical power has crossed below the low alarm threshold. + LOW_ALARM = 316659046; + + // The value of the current optical power has crossed below the low warning threshold. + LOW_WARNING = 338793841; + + // The value of the current optical power has not crossed a warning threshold. + OK = 2524; + + } + + // The status of the current value when compared to the warning and alarm levels for the receiving or transmitting transceiver. Possible states include: - OK: The value has not crossed a warning threshold. - LOW_WARNING: The value has crossed below the low warning threshold. - HIGH_WARNING: The value has crossed above the high warning threshold. - LOW_ALARM: The value has crossed below the low alarm threshold. - HIGH_ALARM: The value has crossed above the high alarm threshold. + // Check the State enum for the list of possible values. + optional string state = 109757585; + + // Value of the current receiving or transmitting optical power, read in dBm. Take a known good optical value, give it a 10% margin and trigger warnings relative to that value. In general, a -7dBm warning and a -11dBm alarm are good optical value estimates for most links. + optional float value = 111972721; + +} + +// +message InterconnectDiagnosticsLinkStatus { + // The operational status of the link. + enum OperationalStatus { + // A value indicating that the enum field is not set. + UNDEFINED_OPERATIONAL_STATUS = 0; + + // The interface is unable to communicate with the remote end. + LINK_OPERATIONAL_STATUS_DOWN = 281653885; + + // The interface has low level communication with the remote end. + LINK_OPERATIONAL_STATUS_UP = 305879862; + + } + + // A list of InterconnectDiagnostics.ARPEntry objects, describing the ARP neighbor entries seen on this link. This will be empty if the link is bundled + repeated InterconnectDiagnosticsARPEntry arp_caches = 414591761; + + // The unique ID for this link assigned during turn up by Google. + optional string circuit_id = 225180977; + + // The Demarc address assigned by Google and provided in the LoA. + optional string google_demarc = 51084; + + optional InterconnectDiagnosticsLinkLACPStatus lacp_status = 361210415; + + // The operational status of the link. + // Check the OperationalStatus enum for the list of possible values. + optional string operational_status = 201070847; + + // An InterconnectDiagnostics.LinkOpticalPower object, describing the current value and status of the received light level. + optional InterconnectDiagnosticsLinkOpticalPower receiving_optical_power = 244717279; + + // An InterconnectDiagnostics.LinkOpticalPower object, describing the current value and status of the transmitted light level. + optional InterconnectDiagnosticsLinkOpticalPower transmitting_optical_power = 459431197; + +} + +// Response to the list request, and contains a list of interconnects. +message InterconnectList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Interconnect resources. + repeated Interconnect items = 100526016; + + // [Output Only] Type of resource. Always compute#interconnectList for lists of interconnects. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Represents an Interconnect Attachment (VLAN) Location resource. You can use this resource to find location details about an Interconnect attachment (VLAN). For more information about interconnect attachments, read Creating VLAN Attachments. +message InterconnectLocation { + // [Output Only] Continent for this location, which can take one of the following values: - AFRICA - ASIA_PAC - EUROPE - NORTH_AMERICA - SOUTH_AMERICA + enum Continent { + // A value indicating that the enum field is not set. + UNDEFINED_CONTINENT = 0; + + AFRICA = 317443706; + + ASIA_PAC = 119782269; + + C_AFRICA = 71993846; + + C_ASIA_PAC = 465668089; + + C_EUROPE = 200369438; + + C_NORTH_AMERICA = 275697048; + + C_SOUTH_AMERICA = 397149792; + + EUROPE = 445819298; + + NORTH_AMERICA = 448015508; + + SOUTH_AMERICA = 32597340; + + } + + // [Output Only] The status of this InterconnectLocation, which can take one of the following values: - CLOSED: The InterconnectLocation is closed and is unavailable for provisioning new Interconnects. - AVAILABLE: The InterconnectLocation is available for provisioning new Interconnects. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // The InterconnectLocation is available for provisioning new Interconnects. + AVAILABLE = 442079913; + + // The InterconnectLocation is closed for provisioning new Interconnects. + CLOSED = 380163436; + + } + + // [Output Only] The postal address of the Point of Presence, each line in the address is separated by a newline character. + optional string address = 462920692; + + // [Output Only] Availability zone for this InterconnectLocation. Within a metropolitan area (metro), maintenance will not be simultaneously scheduled in more than one availability zone. Example: "zone1" or "zone2". + optional string availability_zone = 158459920; + + // [Output Only] Metropolitan area designator that indicates which city an interconnect is located. For example: "Chicago, IL", "Amsterdam, Netherlands". + optional string city = 3053931; + + // [Output Only] Continent for this location, which can take one of the following values: - AFRICA - ASIA_PAC - EUROPE - NORTH_AMERICA - SOUTH_AMERICA + // Check the Continent enum for the list of possible values. + optional string continent = 133442996; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // [Output Only] An optional description of the resource. + optional string description = 422937596; + + // [Output Only] The name of the provider for this facility (e.g., EQUINIX). + optional string facility_provider = 533303309; + + // [Output Only] A provider-assigned Identifier for this facility (e.g., Ashburn-DC1). + optional string facility_provider_facility_id = 87269125; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#interconnectLocation for interconnect locations. + optional string kind = 3292052; + + // [Output Only] Name of the resource. + optional string name = 3373707; + + // [Output Only] The peeringdb identifier for this facility (corresponding with a netfac type in peeringdb). + optional string peeringdb_facility_id = 536567094; + + // [Output Only] A list of InterconnectLocation.RegionInfo objects, that describe parameters pertaining to the relation between this InterconnectLocation and various Google Cloud regions. + repeated InterconnectLocationRegionInfo region_infos = 312194170; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] The status of this InterconnectLocation, which can take one of the following values: - CLOSED: The InterconnectLocation is closed and is unavailable for provisioning new Interconnects. - AVAILABLE: The InterconnectLocation is available for provisioning new Interconnects. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // [Output Only] Reserved for future use. + optional bool supports_pzs = 83983214; + +} + +// Response to the list request, and contains a list of interconnect locations. +message InterconnectLocationList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of InterconnectLocation resources. + repeated InterconnectLocation items = 100526016; + + // [Output Only] Type of resource. Always compute#interconnectLocationList for lists of interconnect locations. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Information about any potential InterconnectAttachments between an Interconnect at a specific InterconnectLocation, and a specific Cloud Region. +message InterconnectLocationRegionInfo { + // Identifies the network presence of this location. + enum LocationPresence { + // A value indicating that the enum field is not set. + UNDEFINED_LOCATION_PRESENCE = 0; + + // This region is not in any common network presence with this InterconnectLocation. + GLOBAL = 494663587; + + // This region shares the same regional network presence as this InterconnectLocation. + LOCAL_REGION = 403535464; + + // [Deprecated] This region is not in any common network presence with this InterconnectLocation. + LP_GLOBAL = 429584062; + + // [Deprecated] This region shares the same regional network presence as this InterconnectLocation. + LP_LOCAL_REGION = 488598851; + + } + + // Expected round-trip time in milliseconds, from this InterconnectLocation to a VM in this region. + optional int64 expected_rtt_ms = 422543866; + + // Identifies the network presence of this location. + // Check the LocationPresence enum for the list of possible values. + optional string location_presence = 101517893; + + // URL for the region of this location. + optional string region = 138946292; + +} + +// Description of a planned outage on this Interconnect. +message InterconnectOutageNotification { + // Form this outage is expected to take, which can take one of the following values: - OUTAGE: The Interconnect may be completely out of service for some or all of the specified window. - PARTIAL_OUTAGE: Some circuits comprising the Interconnect as a whole should remain up, but with reduced bandwidth. Note that the versions of this enum prefixed with "IT_" have been deprecated in favor of the unprefixed values. + enum IssueType { + // A value indicating that the enum field is not set. + UNDEFINED_ISSUE_TYPE = 0; + + // [Deprecated] The Interconnect may be completely out of service for some or all of the specified window. + IT_OUTAGE = 175779973; + + // [Deprecated] Some circuits comprising the Interconnect will be out of service during the expected window. The interconnect as a whole should remain up, albeit with reduced bandwidth. + IT_PARTIAL_OUTAGE = 92103971; + + // The Interconnect may be completely out of service for some or all of the specified window. + OUTAGE = 195285745; + + // Some circuits comprising the Interconnect will be out of service during the expected window. The interconnect as a whole should remain up, albeit with reduced bandwidth. + PARTIAL_OUTAGE = 147053455; + + } + + // The party that generated this notification, which can take the following value: - GOOGLE: this notification as generated by Google. Note that the value of NSRC_GOOGLE has been deprecated in favor of GOOGLE. + enum Source { + // A value indicating that the enum field is not set. + UNDEFINED_SOURCE = 0; + + // This notification was generated by Google. + GOOGLE = 497439289; + + // [Deprecated] This notification was generated by Google. + NSRC_GOOGLE = 510574562; + + } + + // State of this notification, which can take one of the following values: - ACTIVE: This outage notification is active. The event could be in the past, present, or future. See start_time and end_time for scheduling. - CANCELLED: The outage associated with this notification was cancelled before the outage was due to start. - COMPLETED: The outage associated with this notification is complete. Note that the versions of this enum prefixed with "NS_" have been deprecated in favor of the unprefixed values. + enum State { + // A value indicating that the enum field is not set. + UNDEFINED_STATE = 0; + + // This outage notification is active. The event could be in the future, present, or past. See start_time and end_time for scheduling. + ACTIVE = 314733318; + + // The outage associated with this notification was cancelled before the outage was due to start. + CANCELLED = 41957681; + + // The outage associated with this notification is complete. + COMPLETED = 309921323; + + // [Deprecated] This outage notification is active. The event could be in the future, present, or past. See start_time and end_time for scheduling. + NS_ACTIVE = 252563136; + + // [Deprecated] The outage associated with this notification was canceled before the outage was due to start. + NS_CANCELED = 506579411; + + } + + // If issue_type is IT_PARTIAL_OUTAGE, a list of the Google-side circuit IDs that will be affected. + repeated string affected_circuits = 177717013; + + // A description about the purpose of the outage. + optional string description = 422937596; + + // Scheduled end time for the outage (milliseconds since Unix epoch). + optional int64 end_time = 114938801; + + // Form this outage is expected to take, which can take one of the following values: - OUTAGE: The Interconnect may be completely out of service for some or all of the specified window. - PARTIAL_OUTAGE: Some circuits comprising the Interconnect as a whole should remain up, but with reduced bandwidth. Note that the versions of this enum prefixed with "IT_" have been deprecated in favor of the unprefixed values. + // Check the IssueType enum for the list of possible values. + optional string issue_type = 369639136; + + // Unique identifier for this outage notification. + optional string name = 3373707; + + // The party that generated this notification, which can take the following value: - GOOGLE: this notification as generated by Google. Note that the value of NSRC_GOOGLE has been deprecated in favor of GOOGLE. + // Check the Source enum for the list of possible values. + optional string source = 177235995; + + // Scheduled start time for the outage (milliseconds since Unix epoch). + optional int64 start_time = 37467274; + + // State of this notification, which can take one of the following values: - ACTIVE: This outage notification is active. The event could be in the past, present, or future. See start_time and end_time for scheduling. - CANCELLED: The outage associated with this notification was cancelled before the outage was due to start. - COMPLETED: The outage associated with this notification is complete. Note that the versions of this enum prefixed with "NS_" have been deprecated in favor of the unprefixed values. + // Check the State enum for the list of possible values. + optional string state = 109757585; + +} + +// Response for the InterconnectsGetDiagnosticsRequest. +message InterconnectsGetDiagnosticsResponse { + optional InterconnectDiagnostics result = 139315229; + +} + +// A request message for UrlMaps.InvalidateCache. See the method description for details. +message InvalidateCacheUrlMapRequest { + // The body resource for this request + CacheInvalidationRule cache_invalidation_rule_resource = 312795565 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the UrlMap scoping this request. + string url_map = 367020684 [(google.api.field_behavior) = REQUIRED]; + +} + +// Metadata +message Items { + // Key for the metadata entry. Keys must conform to the following regexp: [a-zA-Z0-9-_]+, and be less than 128 bytes in length. This is reflected as part of a URL in the metadata server. Additionally, to avoid ambiguity, keys must not conflict with any other metadata keys for the project. + optional string key = 106079; + + // Value for the metadata entry. These are free-form strings, and only have meaning as interpreted by the image running in the instance. The only restriction placed on values is that their size must be less than or equal to 262144 bytes (256 KiB). + optional string value = 111972721; + +} + +// Represents a License resource. A License represents billing and aggregate usage data for public and marketplace images. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. +message License { + // [Output Only] Deprecated. This field no longer reflects whether a license charges a usage fee. + optional bool charges_use_fee = 372412622; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional textual description of the resource; provided by the client when the resource is created. + optional string description = 422937596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of resource. Always compute#license for licenses. + optional string kind = 3292052; + + // [Output Only] The unique code used to attach this license to images, snapshots, and disks. + optional uint64 license_code = 1467179; + + // Name of the resource. The name must be 1-63 characters long and comply with RFC1035. + optional string name = 3373707; + + optional LicenseResourceRequirements resource_requirements = 214292769; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // If false, licenses will not be copied from the source resource when creating an image from a disk, disk from snapshot, or snapshot from disk. + optional bool transferable = 4349893; + +} + +// Represents a License Code resource. A License Code is a unique identifier used to represent a license resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. +message LicenseCode { + // [Output Only] Current state of this License Code. + enum State { + // A value indicating that the enum field is not set. + UNDEFINED_STATE = 0; + + // Machines are not allowed to attach boot disks with this License Code. Requests to create new resources with this license will be rejected. + DISABLED = 516696700; + + // Use is allowed for anyone with USE_READ_ONLY access to this License Code. + ENABLED = 182130465; + + // Use of this license is limited to a project whitelist. + RESTRICTED = 261551195; + + STATE_UNSPECIFIED = 470755401; + + // Reserved state. + TERMINATED = 250018339; + + } + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // [Output Only] Description of this License Code. + optional string description = 422937596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of resource. Always compute#licenseCode for licenses. + optional string kind = 3292052; + + // [Output Only] URL and description aliases of Licenses with the same License Code. + repeated LicenseCodeLicenseAlias license_alias = 43550930; + + // [Output Only] Name of the resource. The name is 1-20 characters long and must be a valid 64 bit integer. + optional string name = 3373707; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] Current state of this License Code. + // Check the State enum for the list of possible values. + optional string state = 109757585; + + // [Output Only] If true, the license will remain attached when creating images or snapshots from disks. Otherwise, the license is not transferred. + optional bool transferable = 4349893; + +} + +// +message LicenseCodeLicenseAlias { + // [Output Only] Description of this License Code. + optional string description = 422937596; + + // [Output Only] URL of license corresponding to this License Code. + optional string self_link = 456214797; + +} + +// Commitment for a particular license resource. +message LicenseResourceCommitment { + // The number of licenses purchased. + optional int64 amount = 196759640; + + // Specifies the core range of the instance for which this license applies. + optional string cores_per_license = 32482324; + + // Any applicable license URI. + optional string license = 166757441; + +} + +// +message LicenseResourceRequirements { + // Minimum number of guest cpus required to use the Instance. Enforced at Instance creation and Instance start. + optional int32 min_guest_cpu_count = 477964836; + + // Minimum memory required to use the Instance. Enforced at Instance creation and Instance start. + optional int32 min_memory_mb = 504785894; + +} + +// +message LicensesListResponse { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of License resources. + repeated License items = 100526016; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// A request message for AcceleratorTypes.List. See the method description for details. +message ListAcceleratorTypesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Addresses.List. See the method description for details. +message ListAddressesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for FirewallPolicies.ListAssociations. See the method description for details. +message ListAssociationsFirewallPolicyRequest { + // The target resource to list associations. It is an organization, or a folder. + optional string target_resource = 467318524; + +} + +// A request message for Autoscalers.List. See the method description for details. +message ListAutoscalersRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // Name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionSslPolicies.ListAvailableFeatures. See the method description for details. +message ListAvailableFeaturesRegionSslPoliciesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for SslPolicies.ListAvailableFeatures. See the method description for details. +message ListAvailableFeaturesSslPoliciesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for BackendBuckets.List. See the method description for details. +message ListBackendBucketsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for BackendServices.List. See the method description for details. +message ListBackendServicesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for DiskTypes.List. See the method description for details. +message ListDiskTypesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Disks.List. See the method description for details. +message ListDisksRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InstanceGroupManagers.ListErrors. See the method description for details. +message ListErrorsInstanceGroupManagersRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The name of the managed instance group. It must be a string that meets the requirements in RFC1035, or an unsigned long integer: must match regexp pattern: (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)|1-9{0,19}. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone where the managed instance group is located. It should conform to RFC1035. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionInstanceGroupManagers.ListErrors. See the method description for details. +message ListErrorsRegionInstanceGroupManagersRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The name of the managed instance group. It must be a string that meets the requirements in RFC1035, or an unsigned long integer: must match regexp pattern: (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)|1-9{0,19}. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. This should conform to RFC1035. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for ExternalVpnGateways.List. See the method description for details. +message ListExternalVpnGatewaysRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for FirewallPolicies.List. See the method description for details. +message ListFirewallPoliciesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Parent ID for this request. The ID can be either be "folders/[FOLDER_ID]" if the parent is a folder or "organizations/[ORGANIZATION_ID]" if the parent is an organization. + optional string parent_id = 459714768; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Firewalls.List. See the method description for details. +message ListFirewallsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for ForwardingRules.List. See the method description for details. +message ListForwardingRulesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for GlobalAddresses.List. See the method description for details. +message ListGlobalAddressesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for GlobalForwardingRules.List. See the method description for details. +message ListGlobalForwardingRulesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for GlobalNetworkEndpointGroups.List. See the method description for details. +message ListGlobalNetworkEndpointGroupsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for GlobalOperations.List. See the method description for details. +message ListGlobalOperationsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for GlobalOrganizationOperations.List. See the method description for details. +message ListGlobalOrganizationOperationsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Parent ID for this request. + optional string parent_id = 459714768; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for GlobalPublicDelegatedPrefixes.List. See the method description for details. +message ListGlobalPublicDelegatedPrefixesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for HealthChecks.List. See the method description for details. +message ListHealthChecksRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Images.List. See the method description for details. +message ListImagesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for InstanceGroupManagers.List. See the method description for details. +message ListInstanceGroupManagersRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone where the managed instance group is located. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InstanceGroups.List. See the method description for details. +message ListInstanceGroupsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone where the instance group is located. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InstanceTemplates.List. See the method description for details. +message ListInstanceTemplatesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for InstanceGroups.ListInstances. See the method description for details. +message ListInstancesInstanceGroupsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The name of the instance group from which you want to generate a list of included instances. + string instance_group = 81095253 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstanceGroupsListInstancesRequest instance_groups_list_instances_request_resource = 476255263 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone where the instance group is located. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionInstanceGroups.ListInstances. See the method description for details. +message ListInstancesRegionInstanceGroupsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Name of the regional instance group for which we want to list the instances. + string instance_group = 81095253 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + RegionInstanceGroupsListInstancesRequest region_instance_groups_list_instances_request_resource = 48239828 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Instances.List. See the method description for details. +message ListInstancesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InterconnectAttachments.List. See the method description for details. +message ListInterconnectAttachmentsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for InterconnectLocations.List. See the method description for details. +message ListInterconnectLocationsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Interconnects.List. See the method description for details. +message ListInterconnectsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Licenses.List. See the method description for details. +message ListLicensesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for MachineImages.List. See the method description for details. +message ListMachineImagesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for MachineTypes.List. See the method description for details. +message ListMachineTypesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InstanceGroupManagers.ListManagedInstances. See the method description for details. +message ListManagedInstancesInstanceGroupManagersRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The name of the managed instance group. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone where the managed instance group is located. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionInstanceGroupManagers.ListManagedInstances. See the method description for details. +message ListManagedInstancesRegionInstanceGroupManagersRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The name of the managed instance group. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for NetworkAttachments.List. See the method description for details. +message ListNetworkAttachmentsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region of this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for NetworkEndpointGroups.List. See the method description for details. +message ListNetworkEndpointGroupsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone where the network endpoint group is located. It should comply with RFC1035. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for GlobalNetworkEndpointGroups.ListNetworkEndpoints. See the method description for details. +message ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // The name of the network endpoint group from which you want to generate a list of included network endpoints. It should comply with RFC1035. + string network_endpoint_group = 433907078 [(google.api.field_behavior) = REQUIRED]; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for NetworkEndpointGroups.ListNetworkEndpoints. See the method description for details. +message ListNetworkEndpointsNetworkEndpointGroupsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // The name of the network endpoint group from which you want to generate a list of included network endpoints. It should comply with RFC1035. + string network_endpoint_group = 433907078 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + NetworkEndpointGroupsListEndpointsRequest network_endpoint_groups_list_endpoints_request_resource = 59493390 [(google.api.field_behavior) = REQUIRED]; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone where the network endpoint group is located. It should comply with RFC1035. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NetworkFirewallPolicies.List. See the method description for details. +message ListNetworkFirewallPoliciesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Networks.List. See the method description for details. +message ListNetworksRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for NodeGroups.List. See the method description for details. +message ListNodeGroupsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NodeTemplates.List. See the method description for details. +message ListNodeTemplatesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for NodeTypes.List. See the method description for details. +message ListNodeTypesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NodeGroups.ListNodes. See the method description for details. +message ListNodesNodeGroupsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Name of the NodeGroup resource whose nodes you want to list. + string node_group = 469958146 [(google.api.field_behavior) = REQUIRED]; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for PacketMirrorings.List. See the method description for details. +message ListPacketMirroringsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Networks.ListPeeringRoutes. See the method description for details. +message ListPeeringRoutesNetworksRequest { + // The direction of the exchanged routes. + enum Direction { + // A value indicating that the enum field is not set. + UNDEFINED_DIRECTION = 0; + + // For routes exported from peer network. + INCOMING = 338552870; + + // For routes exported from local network. + OUTGOING = 307438444; + + } + + // The direction of the exchanged routes. + // Check the Direction enum for the list of possible values. + optional string direction = 111150975; + + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Name of the network for this request. + string network = 232872494 [(google.api.field_behavior) = REQUIRED]; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // The response will show routes exchanged over the given peering connection. + optional string peering_name = 249571370; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The region of the request. The response will include all subnet routes, static routes and dynamic routes in the region. + optional string region = 138946292; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for InstanceGroupManagers.ListPerInstanceConfigs. See the method description for details. +message ListPerInstanceConfigsInstanceGroupManagersRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The name of the managed instance group. It should conform to RFC1035. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone where the managed instance group is located. It should conform to RFC1035. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionInstanceGroupManagers.ListPerInstanceConfigs. See the method description for details. +message ListPerInstanceConfigsRegionInstanceGroupManagersRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The name of the managed instance group. It should conform to RFC1035. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request, should conform to RFC1035. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for SecurityPolicies.ListPreconfiguredExpressionSets. See the method description for details. +message ListPreconfiguredExpressionSetsSecurityPoliciesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for PublicAdvertisedPrefixes.List. See the method description for details. +message ListPublicAdvertisedPrefixesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for PublicDelegatedPrefixes.List. See the method description for details. +message ListPublicDelegatedPrefixesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region of this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Instances.ListReferrers. See the method description for details. +message ListReferrersInstancesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // Name of the target instance scoping this request, or '-' if the request should span over all instances in the container. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionAutoscalers.List. See the method description for details. +message ListRegionAutoscalersRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionBackendServices.List. See the method description for details. +message ListRegionBackendServicesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionCommitments.List. See the method description for details. +message ListRegionCommitmentsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionDiskTypes.List. See the method description for details. +message ListRegionDiskTypesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionDisks.List. See the method description for details. +message ListRegionDisksRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionHealthCheckServices.List. See the method description for details. +message ListRegionHealthCheckServicesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionHealthChecks.List. See the method description for details. +message ListRegionHealthChecksRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionInstanceGroupManagers.List. See the method description for details. +message ListRegionInstanceGroupManagersRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionInstanceGroups.List. See the method description for details. +message ListRegionInstanceGroupsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionInstanceTemplates.List. See the method description for details. +message ListRegionInstanceTemplatesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the regions for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionNetworkEndpointGroups.List. See the method description for details. +message ListRegionNetworkEndpointGroupsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region where the network endpoint group is located. It should comply with RFC1035. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionNetworkFirewallPolicies.List. See the method description for details. +message ListRegionNetworkFirewallPoliciesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionNotificationEndpoints.List. See the method description for details. +message ListRegionNotificationEndpointsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionOperations.List. See the method description for details. +message ListRegionOperationsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionSecurityPolicies.List. See the method description for details. +message ListRegionSecurityPoliciesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionSslCertificates.List. See the method description for details. +message ListRegionSslCertificatesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionSslPolicies.List. See the method description for details. +message ListRegionSslPoliciesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionTargetHttpProxies.List. See the method description for details. +message ListRegionTargetHttpProxiesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionTargetHttpsProxies.List. See the method description for details. +message ListRegionTargetHttpsProxiesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionTargetTcpProxies.List. See the method description for details. +message ListRegionTargetTcpProxiesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for RegionUrlMaps.List. See the method description for details. +message ListRegionUrlMapsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Regions.List. See the method description for details. +message ListRegionsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Reservations.List. See the method description for details. +message ListReservationsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // Name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ResourcePolicies.List. See the method description for details. +message ListResourcePoliciesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Routers.List. See the method description for details. +message ListRoutersRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Routes.List. See the method description for details. +message ListRoutesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for SecurityPolicies.List. See the method description for details. +message ListSecurityPoliciesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for ServiceAttachments.List. See the method description for details. +message ListServiceAttachmentsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region of this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Snapshots.List. See the method description for details. +message ListSnapshotsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for SslCertificates.List. See the method description for details. +message ListSslCertificatesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for SslPolicies.List. See the method description for details. +message ListSslPoliciesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Subnetworks.List. See the method description for details. +message ListSubnetworksRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for TargetGrpcProxies.List. See the method description for details. +message ListTargetGrpcProxiesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for TargetHttpProxies.List. See the method description for details. +message ListTargetHttpProxiesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for TargetHttpsProxies.List. See the method description for details. +message ListTargetHttpsProxiesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for TargetInstances.List. See the method description for details. +message ListTargetInstancesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // Name of the zone scoping this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetPools.List. See the method description for details. +message ListTargetPoolsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for TargetSslProxies.List. See the method description for details. +message ListTargetSslProxiesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for TargetTcpProxies.List. See the method description for details. +message ListTargetTcpProxiesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for TargetVpnGateways.List. See the method description for details. +message ListTargetVpnGatewaysRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for UrlMaps.List. See the method description for details. +message ListUrlMapsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Subnetworks.ListUsable. See the method description for details. +message ListUsableSubnetworksRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for VpnGateways.List. See the method description for details. +message ListVpnGatewaysRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for VpnTunnels.List. See the method description for details. +message ListVpnTunnelsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for Projects.ListXpnHosts. See the method description for details. +message ListXpnHostsProjectsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + ProjectsListXpnHostsRequest projects_list_xpn_hosts_request_resource = 238266391 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// A request message for ZoneOperations.List. See the method description for details. +message ListZoneOperationsRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + + // Name of the zone for request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Zones.List. See the method description for details. +message ListZonesRequest { + // A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + optional bool return_partial_success = 517198390; + +} + +// +message LocalDisk { + // Specifies the number of such disks. + optional int32 disk_count = 182933485; + + // Specifies the size of the disk in base-2 GB. + optional int32 disk_size_gb = 316263735; + + // Specifies the desired disk type on the node. This disk type must be a local storage type (e.g.: local-ssd). Note that for nodeTemplates, this should be the name of the disk type and not its URL. + optional string disk_type = 93009052; + +} + +// Provides a localized error message that is safe to return to the user which can be attached to an RPC error. +message LocalizedMessage { + // The locale used following the specification defined at https://www.rfc-editor.org/rfc/bcp/bcp47.txt. Examples are: "en-US", "fr-CH", "es-MX" + optional string locale = 513150554; + + // The localized error message in the above locale. + optional string message = 418054151; + +} + +// Configuration for location policy among multiple possible locations (e.g. preferences for zone selection among zones in a single region). +message LocationPolicy { + // Strategy for distributing VMs across zones in a region. + enum TargetShape { + // A value indicating that the enum field is not set. + UNDEFINED_TARGET_SHAPE = 0; + + // GCE picks zones for creating VM instances to fulfill the requested number of VMs within present resource constraints and to maximize utilization of unused zonal reservations. Recommended for batch workloads that do not require high availability. + ANY = 64972; + + // GCE always selects a single zone for all the VMs, optimizing for resource quotas, available reservations and general capacity. Recommended for batch workloads that cannot tollerate distribution over multiple zones. This the default shape in Bulk Insert and Capacity Advisor APIs. + ANY_SINGLE_ZONE = 61100880; + + // GCE prioritizes acquisition of resources, scheduling VMs in zones where resources are available while distributing VMs as evenly as possible across allowed zones to minimize the impact of zonal failure. Recommended for highly available serving workloads. + BALANCED = 468409608; + + } + + // Location configurations mapped by location name. Currently only zone names are supported and must be represented as valid internal URLs, such as zones/us-central1-a. + map locations = 413423454; + + // Strategy for distributing VMs across zones in a region. + // Check the TargetShape enum for the list of possible values. + optional string target_shape = 338621299; + +} + +// +message LocationPolicyLocation { + // Preference for a given location. Set to either ALLOW or DENY. + enum Preference { + // A value indicating that the enum field is not set. + UNDEFINED_PREFERENCE = 0; + + // Location is allowed for use. + ALLOW = 62368553; + + // Location is prohibited. + DENY = 2094604; + + // Default value, unused. + PREFERENCE_UNSPECIFIED = 496219571; + + } + + // Constraints that the caller requires on the result distribution in this zone. + optional LocationPolicyLocationConstraints constraints = 3909174; + + // Preference for a given location. Set to either ALLOW or DENY. + // Check the Preference enum for the list of possible values. + optional string preference = 150781147; + +} + +// Per-zone constraints on location policy for this zone. +message LocationPolicyLocationConstraints { + // Maximum number of items that are allowed to be placed in this zone. The value must be non-negative. + optional int32 max_count = 287620724; + +} + +// This is deprecated and has no effect. Do not use. +message LogConfig { + // This is deprecated and has no effect. Do not use. + optional LogConfigCloudAuditOptions cloud_audit = 412852561; + + // This is deprecated and has no effect. Do not use. + optional LogConfigCounterOptions counter = 420959740; + + // This is deprecated and has no effect. Do not use. + optional LogConfigDataAccessOptions data_access = 286633881; + +} + +// This is deprecated and has no effect. Do not use. +message LogConfigCloudAuditOptions { + // This is deprecated and has no effect. Do not use. + enum LogName { + // A value indicating that the enum field is not set. + UNDEFINED_LOG_NAME = 0; + + // This is deprecated and has no effect. Do not use. + ADMIN_ACTIVITY = 427503135; + + // This is deprecated and has no effect. Do not use. + DATA_ACCESS = 238070681; + + // This is deprecated and has no effect. Do not use. + UNSPECIFIED_LOG_NAME = 410515182; + + } + + // This is deprecated and has no effect. Do not use. + optional AuthorizationLoggingOptions authorization_logging_options = 217861624; + + // This is deprecated and has no effect. Do not use. + // Check the LogName enum for the list of possible values. + optional string log_name = 402913958; + +} + +// This is deprecated and has no effect. Do not use. +message LogConfigCounterOptions { + // This is deprecated and has no effect. Do not use. + repeated LogConfigCounterOptionsCustomField custom_fields = 249651015; + + // This is deprecated and has no effect. Do not use. + optional string field = 97427706; + + // This is deprecated and has no effect. Do not use. + optional string metric = 533067184; + +} + +// This is deprecated and has no effect. Do not use. +message LogConfigCounterOptionsCustomField { + // This is deprecated and has no effect. Do not use. + optional string name = 3373707; + + // This is deprecated and has no effect. Do not use. + optional string value = 111972721; + +} + +// This is deprecated and has no effect. Do not use. +message LogConfigDataAccessOptions { + // This is deprecated and has no effect. Do not use. + enum LogMode { + // A value indicating that the enum field is not set. + UNDEFINED_LOG_MODE = 0; + + // This is deprecated and has no effect. Do not use. + LOG_FAIL_CLOSED = 360469778; + + // This is deprecated and has no effect. Do not use. + LOG_MODE_UNSPECIFIED = 88160822; + + } + + // This is deprecated and has no effect. Do not use. + // Check the LogMode enum for the list of possible values. + optional string log_mode = 402897342; + +} + +// Represents a machine image resource. A machine image is a Compute Engine resource that stores all the configuration, metadata, permissions, and data from one or more disks required to create a Virtual machine (VM) instance. For more information, see Machine images. +message MachineImage { + // [Output Only] The status of the machine image. One of the following values: INVALID, CREATING, READY, DELETING, and UPLOADING. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + CREATING = 455564985; + + DELETING = 528602024; + + INVALID = 530283991; + + READY = 77848963; + + UPLOADING = 267603489; + + } + + // [Output Only] The creation timestamp for this machine image in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Input Only] Whether to attempt an application consistent machine image by informing the OS to prepare for the snapshot process. + optional bool guest_flush = 385550813; + + // [Output Only] A unique identifier for this machine image. The server defines this identifier. + optional uint64 id = 3355; + + // [Output Only] Properties of source instance + optional InstanceProperties instance_properties = 215355165; + + // [Output Only] The resource type, which is always compute#machineImage for machine image. + optional string kind = 3292052; + + // Encrypts the machine image using a customer-supplied encryption key. After you encrypt a machine image using a customer-supplied key, you must provide the same key if you use the machine image later. For example, you must provide the encryption key when you create an instance from the encrypted machine image in a future request. Customer-supplied encryption keys do not protect access to metadata of the machine image. If you do not provide an encryption key when creating the machine image, then the machine image will be encrypted using an automatically generated key and you do not need to provide a key to use the machine image later. + optional CustomerEncryptionKey machine_image_encryption_key = 528089087; + + // Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // [Output Only] Reserved for future use. + optional bool satisfies_pzs = 480964267; + + // An array of Machine Image specific properties for disks attached to the source instance + repeated SavedDisk saved_disks = 397424318; + + // [Output Only] The URL for this machine image. The server defines this URL. + optional string self_link = 456214797; + + // [Input Only] The customer-supplied encryption key of the disks attached to the source instance. Required if the source disk is protected by a customer-supplied encryption key. + repeated SourceDiskEncryptionKey source_disk_encryption_keys = 370408498; + + // The source instance used to create the machine image. You can provide this as a partial or full URL to the resource. For example, the following are valid values: - https://www.googleapis.com/compute/v1/projects/project/zones/zone /instances/instance - projects/project/zones/zone/instances/instance + optional string source_instance = 396315705; + + // [Output Only] DEPRECATED: Please use instance_properties instead for source instance related properties. New properties will not be added to this field. + optional SourceInstanceProperties source_instance_properties = 475195641; + + // [Output Only] The status of the machine image. One of the following values: INVALID, CREATING, READY, DELETING, and UPLOADING. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // The regional or multi-regional Cloud Storage bucket location where the machine image is stored. + repeated string storage_locations = 328005274; + + // [Output Only] Total size of the storage used by the machine image. + optional int64 total_storage_bytes = 81855468; + +} + +// A list of machine images. +message MachineImageList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of MachineImage resources. + repeated MachineImage items = 100526016; + + // [Output Only] The resource type, which is always compute#machineImagesListResponse for machine image lists. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Represents a Machine Type resource. You can use specific machine types for your VM instances based on performance and pricing requirements. For more information, read Machine Types. +message MachineType { + // [Output Only] A list of accelerator configurations assigned to this machine type. + repeated Accelerators accelerators = 269577064; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // [Output Only] The deprecation status associated with this machine type. Only applicable if the machine type is unavailable. + optional DeprecationStatus deprecated = 515138995; + + // [Output Only] An optional textual description of the resource. + optional string description = 422937596; + + // [Output Only] The number of virtual CPUs that are available to the instance. + optional int32 guest_cpus = 393356754; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Deprecated] This property is deprecated and will never be populated with any relevant values. + optional int32 image_space_gb = 75331864; + + // [Output Only] Whether this machine type has a shared CPU. See Shared-core machine types for more information. + optional bool is_shared_cpu = 521399555; + + // [Output Only] The type of the resource. Always compute#machineType for machine types. + optional string kind = 3292052; + + // [Output Only] Maximum persistent disks allowed. + optional int32 maximum_persistent_disks = 496220941; + + // [Output Only] Maximum total persistent disks size (GB) allowed. + optional int64 maximum_persistent_disks_size_gb = 154274471; + + // [Output Only] The amount of physical memory available to the instance, defined in MB. + optional int32 memory_mb = 116001171; + + // [Output Only] Name of the resource. + optional string name = 3373707; + + // [Output Only] A list of extended scratch disks assigned to the instance. + repeated ScratchDisks scratch_disks = 480778481; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] The name of the zone where the machine type resides, such as us-central1-a. + optional string zone = 3744684; + +} + +// +message MachineTypeAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of MachineTypesScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#machineTypeAggregatedList for aggregated lists of machine types. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of machine types. +message MachineTypeList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of MachineType resources. + repeated MachineType items = 100526016; + + // [Output Only] Type of resource. Always compute#machineTypeList for lists of machine types. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message MachineTypesScopedList { + // [Output Only] A list of machine types contained in this scope. + repeated MachineType machine_types = 79720065; + + // [Output Only] An informational warning that appears when the machine types list is empty. + optional Warning warning = 50704284; + +} + +// A Managed Instance resource. +message ManagedInstance { + // [Output Only] The current action that the managed instance group has scheduled for the instance. Possible values: - NONE The instance is running, and the managed instance group does not have any scheduled actions for this instance. - CREATING The managed instance group is creating this instance. If the group fails to create this instance, it will try again until it is successful. - CREATING_WITHOUT_RETRIES The managed instance group is attempting to create this instance only once. If the group fails to create this instance, it does not try again and the group's targetSize value is decreased instead. - RECREATING The managed instance group is recreating this instance. - DELETING The managed instance group is permanently deleting this instance. - ABANDONING The managed instance group is abandoning this instance. The instance will be removed from the instance group and from any target pools that are associated with this group. - RESTARTING The managed instance group is restarting the instance. - REFRESHING The managed instance group is applying configuration changes to the instance without stopping it. For example, the group can update the target pool list for an instance without stopping that instance. - VERIFYING The managed instance group has created the instance and it is in the process of being verified. + // Additional supported values which may be not listed in the enum directly due to technical reasons: + // STOPPING + // SUSPENDING + enum CurrentAction { + // A value indicating that the enum field is not set. + UNDEFINED_CURRENT_ACTION = 0; + + // The managed instance group is abandoning this instance. The instance will be removed from the instance group and from any target pools that are associated with this group. + ABANDONING = 388244813; + + // The managed instance group is creating this instance. If the group fails to create this instance, it will try again until it is successful. + CREATING = 455564985; + + // The managed instance group is attempting to create this instance only once. If the group fails to create this instance, it does not try again and the group's targetSize value is decreased. + CREATING_WITHOUT_RETRIES = 428843785; + + // The managed instance group is permanently deleting this instance. + DELETING = 528602024; + + // The managed instance group has not scheduled any actions for this instance. + NONE = 2402104; + + // The managed instance group is recreating this instance. + RECREATING = 287278572; + + // The managed instance group is applying configuration changes to the instance without stopping it. For example, the group can update the target pool list for an instance without stopping that instance. + REFRESHING = 163266343; + + // The managed instance group is restarting this instance. + RESTARTING = 320534387; + + // The managed instance group is resuming this instance. + RESUMING = 446856618; + + // The managed instance group is starting this instance. + STARTING = 488820800; + + // The managed instance group is verifying this already created instance. Verification happens every time the instance is (re)created or restarted and consists of: 1. Waiting until health check specified as part of this managed instance group's autohealing policy reports HEALTHY. Note: Applies only if autohealing policy has a health check specified 2. Waiting for addition verification steps performed as post-instance creation (subject to future extensions). + VERIFYING = 16982185; + + } + + // [Output Only] The status of the instance. This field is empty when the instance does not exist. + // Additional supported values which may be not listed in the enum directly due to technical reasons: + // STOPPING + // SUSPENDING + enum InstanceStatus { + // A value indicating that the enum field is not set. + UNDEFINED_INSTANCE_STATUS = 0; + + // The Nanny is halted and we are performing tear down tasks like network deprogramming, releasing quota, IP, tearing down disks etc. + DEPROVISIONING = 428935662; + + // Resources are being allocated for the instance. + PROVISIONING = 290896621; + + // The instance is in repair. + REPAIRING = 413483285; + + // The instance is running. + RUNNING = 121282975; + + // All required resources have been allocated and the instance is being started. + STAGING = 431072283; + + // The instance has stopped successfully. + STOPPED = 444276141; + + STOPPING = 350791796; + + // The instance has suspended. + SUSPENDED = 51223995; + + SUSPENDING = 514206246; + + // The instance has stopped (either by explicit action or underlying failure). + TERMINATED = 250018339; + + } + + // [Output Only] The current action that the managed instance group has scheduled for the instance. Possible values: - NONE The instance is running, and the managed instance group does not have any scheduled actions for this instance. - CREATING The managed instance group is creating this instance. If the group fails to create this instance, it will try again until it is successful. - CREATING_WITHOUT_RETRIES The managed instance group is attempting to create this instance only once. If the group fails to create this instance, it does not try again and the group's targetSize value is decreased instead. - RECREATING The managed instance group is recreating this instance. - DELETING The managed instance group is permanently deleting this instance. - ABANDONING The managed instance group is abandoning this instance. The instance will be removed from the instance group and from any target pools that are associated with this group. - RESTARTING The managed instance group is restarting the instance. - REFRESHING The managed instance group is applying configuration changes to the instance without stopping it. For example, the group can update the target pool list for an instance without stopping that instance. - VERIFYING The managed instance group has created the instance and it is in the process of being verified. + // Check the CurrentAction enum for the list of possible values. + optional string current_action = 178475964; + + // [Output only] The unique identifier for this resource. This field is empty when instance does not exist. + optional uint64 id = 3355; + + // [Output Only] The URL of the instance. The URL can exist even if the instance has not yet been created. + optional string instance = 18257045; + + // [Output Only] Health state of the instance per health-check. + repeated ManagedInstanceInstanceHealth instance_health = 382667078; + + // [Output Only] The status of the instance. This field is empty when the instance does not exist. + // Check the InstanceStatus enum for the list of possible values. + optional string instance_status = 174577372; + + // [Output Only] Information about the last attempt to create or delete the instance. + optional ManagedInstanceLastAttempt last_attempt = 434771492; + + // [Output Only] Preserved state applied from per-instance config for this instance. + optional PreservedState preserved_state_from_config = 98661858; + + // [Output Only] Preserved state generated based on stateful policy for this instance. + optional PreservedState preserved_state_from_policy = 470783954; + + // [Output Only] Intended version of this instance. + optional ManagedInstanceVersion version = 351608024; + +} + +// +message ManagedInstanceInstanceHealth { + // [Output Only] The current detailed instance health state. + enum DetailedHealthState { + // A value indicating that the enum field is not set. + UNDEFINED_DETAILED_HEALTH_STATE = 0; + + // The instance is being drained. The existing connections to the instance have time to complete, but the new ones are being refused. + DRAINING = 480455402; + + // The instance is reachable i.e. a connection to the application health checking endpoint can be established, and conforms to the requirements defined by the health check. + HEALTHY = 439801213; + + // The instance is unreachable i.e. a connection to the application health checking endpoint cannot be established, or the server does not respond within the specified timeout. + TIMEOUT = 477813057; + + // The instance is reachable, but does not conform to the requirements defined by the health check. + UNHEALTHY = 462118084; + + // The health checking system is aware of the instance but its health is not known at the moment. + UNKNOWN = 433141802; + + } + + // [Output Only] The current detailed instance health state. + // Check the DetailedHealthState enum for the list of possible values. + optional string detailed_health_state = 510470173; + + // [Output Only] The URL for the health check that verifies whether the instance is healthy. + optional string health_check = 308876645; + +} + +// +message ManagedInstanceLastAttempt { + // [Output Only] Encountered errors during the last attempt to create or delete the instance. + optional Errors errors = 315977579; + +} + +// +message ManagedInstanceVersion { + // [Output Only] The intended template of the instance. This field is empty when current_action is one of { DELETING, ABANDONING }. + optional string instance_template = 309248228; + + // [Output Only] Name of the version. + optional string name = 3373707; + +} + +// A metadata key/value entry. +message Metadata { + // Specifies a fingerprint for this request, which is essentially a hash of the metadata's contents and used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update metadata. You must always provide an up-to-date fingerprint hash in order to update or change metadata, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve the resource. + optional string fingerprint = 234678500; + + // Array of key/value pairs. The total size of all keys and values must be less than 512 KB. + repeated Items items = 100526016; + + // [Output Only] Type of the resource. Always compute#metadata for metadata. + optional string kind = 3292052; + +} + +// Opaque filter criteria used by load balancers to restrict routing configuration to a limited set of load balancing proxies. Proxies and sidecars involved in load balancing would typically present metadata to the load balancers that need to match criteria specified here. If a match takes place, the relevant configuration is made available to those proxies. For each metadataFilter in this list, if its filterMatchCriteria is set to MATCH_ANY, at least one of the filterLabels must match the corresponding label provided in the metadata. If its filterMatchCriteria is set to MATCH_ALL, then all of its filterLabels must match with corresponding labels provided in the metadata. An example for using metadataFilters would be: if load balancing involves Envoys, they receive routing configuration when values in metadataFilters match values supplied in of their XDS requests to loadbalancers. +message MetadataFilter { + // Specifies how individual filter label matches within the list of filterLabels and contributes toward the overall metadataFilter match. Supported values are: - MATCH_ANY: at least one of the filterLabels must have a matching label in the provided metadata. - MATCH_ALL: all filterLabels must have matching labels in the provided metadata. + enum FilterMatchCriteria { + // A value indicating that the enum field is not set. + UNDEFINED_FILTER_MATCH_CRITERIA = 0; + + // Specifies that all filterLabels must match for the metadataFilter to be considered a match. + MATCH_ALL = 180663271; + + // Specifies that any filterLabel must match for the metadataFilter to be considered a match. + MATCH_ANY = 180663346; + + // Indicates that the match criteria was not set. A metadataFilter must never be created with this value. + NOT_SET = 163646646; + + } + + // The list of label value pairs that must match labels in the provided metadata based on filterMatchCriteria This list must not be empty and can have at the most 64 entries. + repeated MetadataFilterLabelMatch filter_labels = 307903142; + + // Specifies how individual filter label matches within the list of filterLabels and contributes toward the overall metadataFilter match. Supported values are: - MATCH_ANY: at least one of the filterLabels must have a matching label in the provided metadata. - MATCH_ALL: all filterLabels must have matching labels in the provided metadata. + // Check the FilterMatchCriteria enum for the list of possible values. + optional string filter_match_criteria = 239970368; + +} + +// MetadataFilter label name value pairs that are expected to match corresponding labels presented as metadata to the load balancer. +message MetadataFilterLabelMatch { + // Name of metadata label. The name can have a maximum length of 1024 characters and must be at least 1 character long. + optional string name = 3373707; + + // The value of the label must match the specified value. value can have a maximum length of 1024 characters. + optional string value = 111972721; + +} + +// A request message for Projects.MoveDisk. See the method description for details. +message MoveDiskProjectRequest { + // The body resource for this request + DiskMoveRequest disk_move_request_resource = 313008458 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for FirewallPolicies.Move. See the method description for details. +message MoveFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The new parent of the firewall policy. The ID can be either be "folders/[FOLDER_ID]" if the parent is a folder or "organizations/[ORGANIZATION_ID]" if the parent is an organization. + string parent_id = 459714768 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "parent_id" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Projects.MoveInstance. See the method description for details. +message MoveInstanceProjectRequest { + // The body resource for this request + InstanceMoveRequest instance_move_request_resource = 311664194 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// The named port. For example: <"http", 80>. +message NamedPort { + // The name for this named port. The name must be 1-63 characters long, and comply with RFC1035. + optional string name = 3373707; + + // The port number, which can be a value between 1 and 65535. + optional int32 port = 3446913; + +} + +// Represents a VPC Network resource. Networks connect resources to each other and to the internet. For more information, read Virtual Private Cloud (VPC) Network. +message Network { + // The network firewall policy enforcement order. Can be either AFTER_CLASSIC_FIREWALL or BEFORE_CLASSIC_FIREWALL. Defaults to AFTER_CLASSIC_FIREWALL if the field is not specified. + enum NetworkFirewallPolicyEnforcementOrder { + // A value indicating that the enum field is not set. + UNDEFINED_NETWORK_FIREWALL_POLICY_ENFORCEMENT_ORDER = 0; + + AFTER_CLASSIC_FIREWALL = 154582608; + + BEFORE_CLASSIC_FIREWALL = 338458349; + + } + + // Deprecated in favor of subnet mode networks. The range of internal addresses that are legal on this network. This range is a CIDR specification, for example: 192.168.0.0/16. Provided by the client when the network is created. + optional string I_pv4_range = 59234358; + + // Must be set to create a VPC network. If not set, a legacy network is created. When set to true, the VPC network is created in auto mode. When set to false, the VPC network is created in custom mode. An auto mode VPC network starts with one subnet per region. Each subnet has a predetermined range as described in Auto mode VPC network IP ranges. For custom mode VPC networks, you can add subnets using the subnetworks insert method. + optional bool auto_create_subnetworks = 256156690; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this field when you create the resource. + optional string description = 422937596; + + // Enable ULA internal ipv6 on this network. Enabling this feature will assign a /48 from google defined ULA prefix fd20::/20. . + optional bool enable_ula_internal_ipv6 = 423757720; + + // [Output Only] URL of the firewall policy the network is associated with. + optional string firewall_policy = 498173265; + + // [Output Only] The gateway address for default routing out of the network, selected by GCP. + optional string gateway_i_pv4 = 178678877; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // When enabling ula internal ipv6, caller optionally can specify the /48 range they want from the google defined ULA prefix fd20::/20. The input must be a valid /48 ULA IPv6 address and must be within the fd20::/20. Operation will fail if the speficied /48 is already in used by another resource. If the field is not speficied, then a /48 range will be randomly allocated from fd20::/20 and returned via this field. . + optional string internal_ipv6_range = 277456807; + + // [Output Only] Type of the resource. Always compute#network for networks. + optional string kind = 3292052; + + // Maximum Transmission Unit in bytes. The minimum value for this field is 1300 and the maximum value is 8896. The suggested value is 1500, which is the default MTU used on the Internet, or 8896 if you want to use Jumbo frames. If unspecified, the value defaults to 1460. + optional int32 mtu = 108462; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`. The first character must be a lowercase letter, and all following characters (except for the last character) must be a dash, lowercase letter, or digit. The last character must be a lowercase letter or digit. + optional string name = 3373707; + + // The network firewall policy enforcement order. Can be either AFTER_CLASSIC_FIREWALL or BEFORE_CLASSIC_FIREWALL. Defaults to AFTER_CLASSIC_FIREWALL if the field is not specified. + // Check the NetworkFirewallPolicyEnforcementOrder enum for the list of possible values. + optional string network_firewall_policy_enforcement_order = 6504784; + + // [Output Only] A list of network peerings for the resource. + repeated NetworkPeering peerings = 69883187; + + // The network-level routing configuration for this network. Used by Cloud Router to determine what type of network-wide routing behavior to enforce. + optional NetworkRoutingConfig routing_config = 523556059; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] Server-defined URL for this resource with the resource id. + optional string self_link_with_id = 44520962; + + // [Output Only] Server-defined fully-qualified URLs for all subnetworks in this VPC network. + repeated string subnetworks = 415853125; + +} + +// NetworkAttachments A network attachment resource ... +message NetworkAttachment { + // + enum ConnectionPreference { + // A value indicating that the enum field is not set. + UNDEFINED_CONNECTION_PREFERENCE = 0; + + ACCEPT_AUTOMATIC = 75250580; + + ACCEPT_MANUAL = 373061341; + + INVALID = 530283991; + + } + + // [Output Only] An array of connections for all the producers connected to this network attachment. + repeated NetworkAttachmentConnectedEndpoint connection_endpoints = 326078813; + + // + // Check the ConnectionPreference enum for the list of possible values. + optional string connection_preference = 285818076; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. An up-to-date fingerprint must be provided in order to patch. + optional string fingerprint = 234678500; + + // [Output Only] The unique identifier for the resource type. The server generates this identifier. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // [Output Only] The URL of the network which the Network Attachment belongs to. + optional string network = 232872494; + + // Projects that are allowed to connect to this network attachment. The project can be specified using its id or number. + repeated string producer_accept_lists = 202804523; + + // Projects that are not allowed to connect to this network attachment. The project can be specified using its id or number. + repeated string producer_reject_lists = 4112002; + + // [Output Only] URL of the region where the network attachment resides. This field applies only to the region resource. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] Server-defined URL for this resource's resource id. + optional string self_link_with_id = 44520962; + + // An array of URLs where each entry is the URL of a subnet provided by the service consumer to use for endpoints in the producers that connect to this network attachment. + repeated string subnetworks = 415853125; + +} + +// Contains a list of NetworkAttachmentsScopedList. +message NetworkAttachmentAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of NetworkAttachmentsScopedList resources. + map items = 100526016; + + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// [Output Only] A connection connected to this network attachment. +message NetworkAttachmentConnectedEndpoint { + // The status of a connected endpoint to this network attachment. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // The consumer allows traffic from the producer to reach its VPC. + ACCEPTED = 246714279; + + // The consumer network attachment no longer exists. + CLOSED = 380163436; + + // The consumer needs to take further action before traffic can be served. + NEEDS_ATTENTION = 344491452; + + // The consumer neither allows nor prohibits traffic from the producer to reach its VPC. + PENDING = 35394935; + + // The consumer prohibits traffic from the producer to reach its VPC. + REJECTED = 174130302; + + STATUS_UNSPECIFIED = 42133066; + + } + + // The IP address assigned to the producer instance network interface. This value will be a range in case of Serverless. + optional string ip_address = 406272220; + + // The project id or number of the interface to which the IP was assigned. + optional string project_id_or_num = 349783336; + + // Alias IP ranges from the same subnetwork + repeated string secondary_ip_cidr_ranges = 117184788; + + // The status of a connected endpoint to this network attachment. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // The subnetwork used to assign the IP to the producer instance network interface. + optional string subnetwork = 307827694; + +} + +// +message NetworkAttachmentList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of NetworkAttachment resources. + repeated NetworkAttachment items = 100526016; + + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message NetworkAttachmentsScopedList { + // A list of NetworkAttachments contained in this scope. + repeated NetworkAttachment network_attachments = 521514783; + + // Informational warning which replaces the list of network attachments when the list is empty. + optional Warning warning = 50704284; + +} + +// Represents a Google Cloud Armor network edge security service resource. +message NetworkEdgeSecurityService { + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a NetworkEdgeSecurityService. An up-to-date fingerprint must be provided in order to update the NetworkEdgeSecurityService, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve a NetworkEdgeSecurityService. + optional string fingerprint = 234678500; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output only] Type of the resource. Always compute#networkEdgeSecurityService for NetworkEdgeSecurityServices + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // [Output Only] URL of the region where the resource resides. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string region = 138946292; + + // The resource URL for the network edge security service associated with this network edge security service. + optional string security_policy = 171082513; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] Server-defined URL for this resource with the resource id. + optional string self_link_with_id = 44520962; + +} + +// +message NetworkEdgeSecurityServiceAggregatedList { + optional string etag = 3123477; + + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of NetworkEdgeSecurityServicesScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#networkEdgeSecurityServiceAggregatedList for lists of Network Edge Security Services. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message NetworkEdgeSecurityServicesScopedList { + // A list of NetworkEdgeSecurityServices contained in this scope. + repeated NetworkEdgeSecurityService network_edge_security_services = 35530156; + + // Informational warning which replaces the list of security policies when the list is empty. + optional Warning warning = 50704284; + +} + +// The network endpoint. +message NetworkEndpoint { + // Metadata defined as annotations on the network endpoint. + map annotations = 112032548; + + // Optional fully qualified domain name of network endpoint. This can only be specified when NetworkEndpointGroup.network_endpoint_type is NON_GCP_FQDN_PORT. + optional string fqdn = 3150485; + + // The name for a specific VM instance that the IP address belongs to. This is required for network endpoints of type GCE_VM_IP_PORT. The instance must be in the same zone of network endpoint group. The name must be 1-63 characters long, and comply with RFC1035. + optional string instance = 18257045; + + // Optional IPv4 address of network endpoint. The IP address must belong to a VM in Compute Engine (either the primary IP or as part of an aliased IP range). If the IP address is not specified, then the primary IP address for the VM instance in the network that the network endpoint group belongs to will be used. + optional string ip_address = 406272220; + + // Optional port number of network endpoint. If not specified, the defaultPort for the network endpoint group will be used. + optional int32 port = 3446913; + +} + +// Represents a collection of network endpoints. A network endpoint group (NEG) defines how a set of endpoints should be reached, whether they are reachable, and where they are located. For more information about using NEGs, see Setting up external HTTP(S) Load Balancing with internet NEGs, Setting up zonal NEGs, or Setting up external HTTP(S) Load Balancing with serverless NEGs. +message NetworkEndpointGroup { + // Type of network endpoints in this network endpoint group. Can be one of GCE_VM_IP, GCE_VM_IP_PORT, NON_GCP_PRIVATE_IP_PORT, INTERNET_FQDN_PORT, INTERNET_IP_PORT, SERVERLESS, PRIVATE_SERVICE_CONNECT. + enum NetworkEndpointType { + // A value indicating that the enum field is not set. + UNDEFINED_NETWORK_ENDPOINT_TYPE = 0; + + // The network endpoint is represented by an IP address. + GCE_VM_IP = 401880793; + + // The network endpoint is represented by IP address and port pair. + GCE_VM_IP_PORT = 501838375; + + // The network endpoint is represented by fully qualified domain name and port. + INTERNET_FQDN_PORT = 404154477; + + // The network endpoint is represented by an internet IP address and port. + INTERNET_IP_PORT = 477719963; + + // The network endpoint is represented by an IP address and port. The endpoint belongs to a VM or pod running in a customer's on-premises. + NON_GCP_PRIVATE_IP_PORT = 336447968; + + // The network endpoint is either public Google APIs or services exposed by other GCP Project with a Service Attachment. The connection is set up by private service connect + PRIVATE_SERVICE_CONNECT = 48134724; + + // The network endpoint is handled by specified serverless infrastructure. + SERVERLESS = 270492508; + + } + + // Metadata defined as annotations on the network endpoint group. + map annotations = 112032548; + + // Only valid when networkEndpointType is "SERVERLESS". Only one of cloudRun, appEngine or cloudFunction may be set. + optional NetworkEndpointGroupAppEngine app_engine = 340788768; + + // Only valid when networkEndpointType is "SERVERLESS". Only one of cloudRun, appEngine or cloudFunction may be set. + optional NetworkEndpointGroupCloudFunction cloud_function = 519893666; + + // Only valid when networkEndpointType is "SERVERLESS". Only one of cloudRun, appEngine or cloudFunction may be set. + optional NetworkEndpointGroupCloudRun cloud_run = 111060353; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // The default port used if the port number is not specified in the network endpoint. + optional int32 default_port = 423377855; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#networkEndpointGroup for network endpoint group. + optional string kind = 3292052; + + // Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // The URL of the network to which all network endpoints in the NEG belong. Uses "default" project network if unspecified. + optional string network = 232872494; + + // Type of network endpoints in this network endpoint group. Can be one of GCE_VM_IP, GCE_VM_IP_PORT, NON_GCP_PRIVATE_IP_PORT, INTERNET_FQDN_PORT, INTERNET_IP_PORT, SERVERLESS, PRIVATE_SERVICE_CONNECT. + // Check the NetworkEndpointType enum for the list of possible values. + optional string network_endpoint_type = 118301523; + + optional NetworkEndpointGroupPscData psc_data = 71937481; + + // The target service url used to set up private service connection to a Google API or a PSC Producer Service Attachment. An example value is: "asia-northeast3-cloudkms.googleapis.com" + optional string psc_target_service = 269132134; + + // [Output Only] The URL of the region where the network endpoint group is located. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output only] Number of network endpoints in the network endpoint group. + optional int32 size = 3530753; + + // Optional URL of the subnetwork to which all network endpoints in the NEG belong. + optional string subnetwork = 307827694; + + // [Output Only] The URL of the zone where the network endpoint group is located. + optional string zone = 3744684; + +} + +// +message NetworkEndpointGroupAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of NetworkEndpointGroupsScopedList resources. + map items = 100526016; + + // [Output Only] The resource type, which is always compute#networkEndpointGroupAggregatedList for aggregated lists of network endpoint groups. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Configuration for an App Engine network endpoint group (NEG). The service is optional, may be provided explicitly or in the URL mask. The version is optional and can only be provided explicitly or in the URL mask when service is present. Note: App Engine service must be in the same project and located in the same region as the Serverless NEG. +message NetworkEndpointGroupAppEngine { + // Optional serving service. The service name is case-sensitive and must be 1-63 characters long. Example value: "default", "my-service". + optional string service = 373540533; + + // A template to parse service and version fields from a request URL. URL mask allows for routing to multiple App Engine services without having to create multiple Network Endpoint Groups and backend services. For example, the request URLs "foo1-dot-appname.appspot.com/v1" and "foo1-dot-appname.appspot.com/v2" can be backed by the same Serverless NEG with URL mask "-dot-appname.appspot.com/". The URL mask will parse them to { service = "foo1", version = "v1" } and { service = "foo1", version = "v2" } respectively. + optional string url_mask = 103352252; + + // Optional serving version. The version name is case-sensitive and must be 1-100 characters long. Example value: "v1", "v2". + optional string version = 351608024; + +} + +// Configuration for a Cloud Function network endpoint group (NEG). The function must be provided explicitly or in the URL mask. Note: Cloud Function must be in the same project and located in the same region as the Serverless NEG. +message NetworkEndpointGroupCloudFunction { + // A user-defined name of the Cloud Function. The function name is case-sensitive and must be 1-63 characters long. Example value: "func1". + optional string function = 307196888; + + // A template to parse function field from a request URL. URL mask allows for routing to multiple Cloud Functions without having to create multiple Network Endpoint Groups and backend services. For example, request URLs " mydomain.com/function1" and "mydomain.com/function2" can be backed by the same Serverless NEG with URL mask "/". The URL mask will parse them to { function = "function1" } and { function = "function2" } respectively. + optional string url_mask = 103352252; + +} + +// Configuration for a Cloud Run network endpoint group (NEG). The service must be provided explicitly or in the URL mask. The tag is optional, may be provided explicitly or in the URL mask. Note: Cloud Run service must be in the same project and located in the same region as the Serverless NEG. +message NetworkEndpointGroupCloudRun { + // Cloud Run service is the main resource of Cloud Run. The service must be 1-63 characters long, and comply with RFC1035. Example value: "run-service". + optional string service = 373540533; + + // Optional Cloud Run tag represents the "named-revision" to provide additional fine-grained traffic routing information. The tag must be 1-63 characters long, and comply with RFC1035. Example value: "revision-0010". + optional string tag = 114586; + + // A template to parse and fields from a request URL. URL mask allows for routing to multiple Run services without having to create multiple network endpoint groups and backend services. For example, request URLs "foo1.domain.com/bar1" and "foo1.domain.com/bar2" can be backed by the same Serverless Network Endpoint Group (NEG) with URL mask ".domain.com/". The URL mask will parse them to { service="bar1", tag="foo1" } and { service="bar2", tag="foo2" } respectively. + optional string url_mask = 103352252; + +} + +// +message NetworkEndpointGroupList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of NetworkEndpointGroup resources. + repeated NetworkEndpointGroup items = 100526016; + + // [Output Only] The resource type, which is always compute#networkEndpointGroupList for network endpoint group lists. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// All data that is specifically relevant to only network endpoint groups of type PRIVATE_SERVICE_CONNECT. +message NetworkEndpointGroupPscData { + // [Output Only] The connection status of the PSC Forwarding Rule. + enum PscConnectionStatus { + // A value indicating that the enum field is not set. + UNDEFINED_PSC_CONNECTION_STATUS = 0; + + // The connection has been accepted by the producer. + ACCEPTED = 246714279; + + // The connection has been closed by the producer and will not serve traffic going forward. + CLOSED = 380163436; + + // The connection has been accepted by the producer, but the producer needs to take further action before the forwarding rule can serve traffic. + NEEDS_ATTENTION = 344491452; + + // The connection is pending acceptance by the producer. + PENDING = 35394935; + + // The connection has been rejected by the producer. + REJECTED = 174130302; + + STATUS_UNSPECIFIED = 42133066; + + } + + // [Output Only] Address allocated from given subnetwork for PSC. This IP address acts as a VIP for a PSC NEG, allowing it to act as an endpoint in L7 PSC-XLB. + optional string consumer_psc_address = 452646572; + + // [Output Only] The PSC connection id of the PSC Network Endpoint Group Consumer. + optional uint64 psc_connection_id = 292082397; + + // [Output Only] The connection status of the PSC Forwarding Rule. + // Check the PscConnectionStatus enum for the list of possible values. + optional string psc_connection_status = 184149172; + +} + +// +message NetworkEndpointGroupsAttachEndpointsRequest { + // The list of network endpoints to be attached. + repeated NetworkEndpoint network_endpoints = 149850285; + +} + +// +message NetworkEndpointGroupsDetachEndpointsRequest { + // The list of network endpoints to be detached. + repeated NetworkEndpoint network_endpoints = 149850285; + +} + +// +message NetworkEndpointGroupsListEndpointsRequest { + // Optional query parameter for showing the health status of each network endpoint. Valid options are SKIP or SHOW. If you don't specify this parameter, the health status of network endpoints will not be provided. + enum HealthStatus { + // A value indicating that the enum field is not set. + UNDEFINED_HEALTH_STATUS = 0; + + // Show the health status for each network endpoint. Impacts latency of the call. + SHOW = 2544381; + + // Health status for network endpoints will not be provided. + SKIP = 2547071; + + } + + // Optional query parameter for showing the health status of each network endpoint. Valid options are SKIP or SHOW. If you don't specify this parameter, the health status of network endpoints will not be provided. + // Check the HealthStatus enum for the list of possible values. + optional string health_status = 380545845; + +} + +// +message NetworkEndpointGroupsListNetworkEndpoints { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of NetworkEndpointWithHealthStatus resources. + repeated NetworkEndpointWithHealthStatus items = 100526016; + + // [Output Only] The resource type, which is always compute#networkEndpointGroupsListNetworkEndpoints for the list of network endpoints in the specified network endpoint group. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message NetworkEndpointGroupsScopedList { + // [Output Only] The list of network endpoint groups that are contained in this scope. + repeated NetworkEndpointGroup network_endpoint_groups = 29346733; + + // [Output Only] An informational warning that replaces the list of network endpoint groups when the list is empty. + optional Warning warning = 50704284; + +} + +// +message NetworkEndpointWithHealthStatus { + // [Output only] The health status of network endpoint; + repeated HealthStatusForNetworkEndpoint healths = 258689431; + + // [Output only] The network endpoint; + optional NetworkEndpoint network_endpoint = 56789126; + +} + +// A network interface resource attached to an instance. +message NetworkInterface { + // [Output Only] One of EXTERNAL, INTERNAL to indicate whether the IP can be accessed from the Internet. This field is always inherited from its subnetwork. Valid only if stackType is IPV4_IPV6. + enum Ipv6AccessType { + // A value indicating that the enum field is not set. + UNDEFINED_IPV6_ACCESS_TYPE = 0; + + // This network interface can have external IPv6. + EXTERNAL = 35607499; + + // This network interface can have internal IPv6. + INTERNAL = 279295677; + + UNSPECIFIED_IPV6_ACCESS_TYPE = 313080613; + + } + + // The type of vNIC to be used on this interface. This may be gVNIC or VirtioNet. + enum NicType { + // A value indicating that the enum field is not set. + UNDEFINED_NIC_TYPE = 0; + + // GVNIC + GVNIC = 68209305; + + // No type specified. + UNSPECIFIED_NIC_TYPE = 67411801; + + // VIRTIO + VIRTIO_NET = 452123481; + + } + + // The stack type for this network interface to identify whether the IPv6 feature is enabled or not. If not specified, IPV4_ONLY will be used. This field can be both set at instance creation and update network interface operations. + enum StackType { + // A value indicating that the enum field is not set. + UNDEFINED_STACK_TYPE = 0; + + // The network interface can have both IPv4 and IPv6 addresses. + IPV4_IPV6 = 22197249; + + // The network interface will be assigned IPv4 address. + IPV4_ONLY = 22373798; + + UNSPECIFIED_STACK_TYPE = 298084569; + + } + + // An array of configurations for this interface. Currently, only one access config, ONE_TO_ONE_NAT, is supported. If there are no accessConfigs specified, then this instance will have no external internet access. + repeated AccessConfig access_configs = 111058326; + + // An array of alias IP ranges for this network interface. You can only specify this field for network interfaces in VPC networks. + repeated AliasIpRange alias_ip_ranges = 165085631; + + // Fingerprint hash of contents stored in this network interface. This field will be ignored when inserting an Instance or adding a NetworkInterface. An up-to-date fingerprint must be provided in order to update the NetworkInterface. The request will fail with error 400 Bad Request if the fingerprint is not provided, or 412 Precondition Failed if the fingerprint is out of date. + optional string fingerprint = 234678500; + + // The prefix length of the primary internal IPv6 range. + optional int32 internal_ipv6_prefix_length = 203833757; + + // An array of IPv6 access configurations for this interface. Currently, only one IPv6 access config, DIRECT_IPV6, is supported. If there is no ipv6AccessConfig specified, then this instance will have no external IPv6 Internet access. + repeated AccessConfig ipv6_access_configs = 483472110; + + // [Output Only] One of EXTERNAL, INTERNAL to indicate whether the IP can be accessed from the Internet. This field is always inherited from its subnetwork. Valid only if stackType is IPV4_IPV6. + // Check the Ipv6AccessType enum for the list of possible values. + optional string ipv6_access_type = 504658653; + + // An IPv6 internal network address for this network interface. To use a static internal IP address, it must be unused and in the same region as the instance's zone. If not specified, Google Cloud will automatically assign an internal IPv6 address from the instance's subnetwork. + optional string ipv6_address = 341563804; + + // [Output Only] Type of the resource. Always compute#networkInterface for network interfaces. + optional string kind = 3292052; + + // [Output Only] The name of the network interface, which is generated by the server. For a VM, the network interface uses the nicN naming format. Where N is a value between 0 and 7. The default interface value is nic0. + optional string name = 3373707; + + // URL of the VPC network resource for this instance. When creating an instance, if neither the network nor the subnetwork is specified, the default network global/networks/default is used. If the selected project doesn't have the default network, you must specify a network or subnet. If the network is not specified but the subnetwork is specified, the network is inferred. If you specify this property, you can specify the network as a full or partial URL. For example, the following are all valid URLs: - https://www.googleapis.com/compute/v1/projects/project/global/networks/ network - projects/project/global/networks/network - global/networks/default + optional string network = 232872494; + + // The URL of the network attachment that this interface should connect to in the following format: projects/{project_number}/regions/{region_name}/networkAttachments/{network_attachment_name}. + optional string network_attachment = 224644052; + + // An IPv4 internal IP address to assign to the instance for this network interface. If not specified by the user, an unused internal IP is assigned by the system. + optional string network_i_p = 207181961; + + // The type of vNIC to be used on this interface. This may be gVNIC or VirtioNet. + // Check the NicType enum for the list of possible values. + optional string nic_type = 59810577; + + // The networking queue count that's specified by users for the network interface. Both Rx and Tx queues will be set to this number. It'll be empty if not specified by the users. + optional int32 queue_count = 503708769; + + // The stack type for this network interface to identify whether the IPv6 feature is enabled or not. If not specified, IPV4_ONLY will be used. This field can be both set at instance creation and update network interface operations. + // Check the StackType enum for the list of possible values. + optional string stack_type = 425908881; + + // The URL of the Subnetwork resource for this instance. If the network resource is in legacy mode, do not specify this field. If the network is in auto subnet mode, specifying the subnetwork is optional. If the network is in custom subnet mode, specifying the subnetwork is required. If you specify this field, you can specify the subnetwork as a full or partial URL. For example, the following are all valid URLs: - https://www.googleapis.com/compute/v1/projects/project/regions/region /subnetworks/subnetwork - regions/region/subnetworks/subnetwork + optional string subnetwork = 307827694; + +} + +// Contains a list of networks. +message NetworkList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Network resources. + repeated Network items = 100526016; + + // [Output Only] Type of resource. Always compute#networkList for lists of networks. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// A network peering attached to a network resource. The message includes the peering name, peer network, peering state, and a flag indicating whether Google Compute Engine should automatically create routes for the peering. +message NetworkPeering { + // Which IP version(s) of traffic and routes are allowed to be imported or exported between peer networks. The default value is IPV4_ONLY. + enum StackType { + // A value indicating that the enum field is not set. + UNDEFINED_STACK_TYPE = 0; + + // This Peering will allow IPv4 traffic and routes to be exchanged. Additionally if the matching peering is IPV4_IPV6, IPv6 traffic and routes will be exchanged as well. + IPV4_IPV6 = 22197249; + + // This Peering will only allow IPv4 traffic and routes to be exchanged, even if the matching peering is IPV4_IPV6. + IPV4_ONLY = 22373798; + + } + + // [Output Only] State for the peering, either `ACTIVE` or `INACTIVE`. The peering is `ACTIVE` when there's a matching configuration in the peer network. + enum State { + // A value indicating that the enum field is not set. + UNDEFINED_STATE = 0; + + // Matching configuration exists on the peer. + ACTIVE = 314733318; + + // There is no matching configuration on the peer, including the case when peer does not exist. + INACTIVE = 270421099; + + } + + // This field will be deprecated soon. Use the exchange_subnet_routes field instead. Indicates whether full mesh connectivity is created and managed automatically between peered networks. Currently this field should always be true since Google Compute Engine will automatically create and manage subnetwork routes between two networks when peering state is ACTIVE. + optional bool auto_create_routes = 57454941; + + // Indicates whether full mesh connectivity is created and managed automatically between peered networks. Currently this field should always be true since Google Compute Engine will automatically create and manage subnetwork routes between two networks when peering state is ACTIVE. + optional bool exchange_subnet_routes = 26322256; + + // Whether to export the custom routes to peer network. The default value is false. + optional bool export_custom_routes = 60281485; + + // Whether subnet routes with public IP range are exported. The default value is true, all subnet routes are exported. IPv4 special-use ranges are always exported to peers and are not controlled by this field. + optional bool export_subnet_routes_with_public_ip = 97940834; + + // Whether to import the custom routes from peer network. The default value is false. + optional bool import_custom_routes = 197982398; + + // Whether subnet routes with public IP range are imported. The default value is false. IPv4 special-use ranges are always imported from peers and are not controlled by this field. + optional bool import_subnet_routes_with_public_ip = 14419729; + + // Name of this peering. Provided by the client when the peering is created. The name must comply with RFC1035. Specifically, the name must be 1-63 characters long and match regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`. The first character must be a lowercase letter, and all the following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // The URL of the peer network. It can be either full URL or partial URL. The peer network may belong to a different project. If the partial URL does not contain project, it is assumed that the peer network is in the same project as the current network. + optional string network = 232872494; + + // Maximum Transmission Unit in bytes. + optional int32 peer_mtu = 69584721; + + // Which IP version(s) of traffic and routes are allowed to be imported or exported between peer networks. The default value is IPV4_ONLY. + // Check the StackType enum for the list of possible values. + optional string stack_type = 425908881; + + // [Output Only] State for the peering, either `ACTIVE` or `INACTIVE`. The peering is `ACTIVE` when there's a matching configuration in the peer network. + // Check the State enum for the list of possible values. + optional string state = 109757585; + + // [Output Only] Details about the current state of the peering. + optional string state_details = 95566996; + +} + +// +message NetworkPerformanceConfig { + // + enum TotalEgressBandwidthTier { + // A value indicating that the enum field is not set. + UNDEFINED_TOTAL_EGRESS_BANDWIDTH_TIER = 0; + + DEFAULT = 115302945; + + TIER_1 = 326919444; + + } + + // + // Check the TotalEgressBandwidthTier enum for the list of possible values. + optional string total_egress_bandwidth_tier = 130109439; + +} + +// A routing configuration attached to a network resource. The message includes the list of routers associated with the network, and a flag indicating the type of routing behavior to enforce network-wide. +message NetworkRoutingConfig { + // The network-wide routing mode to use. If set to REGIONAL, this network's Cloud Routers will only advertise routes with subnets of this network in the same region as the router. If set to GLOBAL, this network's Cloud Routers will advertise routes with all subnets of this network, across regions. + enum RoutingMode { + // A value indicating that the enum field is not set. + UNDEFINED_ROUTING_MODE = 0; + + GLOBAL = 494663587; + + REGIONAL = 92288543; + + } + + // The network-wide routing mode to use. If set to REGIONAL, this network's Cloud Routers will only advertise routes with subnets of this network in the same region as the router. If set to GLOBAL, this network's Cloud Routers will advertise routes with all subnets of this network, across regions. + // Check the RoutingMode enum for the list of possible values. + optional string routing_mode = 475143548; + +} + +// +message NetworksAddPeeringRequest { + // This field will be deprecated soon. Use exchange_subnet_routes in network_peering instead. Indicates whether full mesh connectivity is created and managed automatically between peered networks. Currently this field should always be true since Google Compute Engine will automatically create and manage subnetwork routes between two networks when peering state is ACTIVE. + optional bool auto_create_routes = 57454941; + + // Name of the peering, which should conform to RFC1035. + optional string name = 3373707; + + // Network peering parameters. In order to specify route policies for peering using import and export custom routes, you must specify all peering related parameters (name, peer network, exchange_subnet_routes) in the network_peering field. The corresponding fields in NetworksAddPeeringRequest will be deprecated soon. + optional NetworkPeering network_peering = 328926767; + + // URL of the peer network. It can be either full URL or partial URL. The peer network may belong to a different project. If the partial URL does not contain project, it is assumed that the peer network is in the same project as the current network. + optional string peer_network = 500625489; + +} + +// +message NetworksGetEffectiveFirewallsResponse { + // Effective firewalls from firewall policy. + repeated NetworksGetEffectiveFirewallsResponseEffectiveFirewallPolicy firewall_policys = 410985794; + + // Effective firewalls on the network. + repeated Firewall firewalls = 272245619; + +} + +// +message NetworksGetEffectiveFirewallsResponseEffectiveFirewallPolicy { + // [Output Only] The type of the firewall policy. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + HIERARCHY = 69902869; + + NETWORK = 413984270; + + UNSPECIFIED = 526786327; + + } + + // [Output Only] Deprecated, please use short name instead. The display name of the firewall policy. + optional string display_name = 4473832; + + // [Output Only] The name of the firewall policy. + optional string name = 3373707; + + // The rules that apply to the network. + repeated FirewallPolicyRule rules = 108873975; + + // [Output Only] The short name of the firewall policy. + optional string short_name = 492051566; + + // [Output Only] The type of the firewall policy. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// +message NetworksRemovePeeringRequest { + // Name of the peering, which should conform to RFC1035. + optional string name = 3373707; + +} + +// +message NetworksUpdatePeeringRequest { + optional NetworkPeering network_peering = 328926767; + +} + +// Represents a sole-tenant Node Group resource. A sole-tenant node is a physical server that is dedicated to hosting VM instances only for your specific project. Use sole-tenant nodes to keep your instances physically separated from instances in other projects, or to group your instances together on the same host hardware. For more information, read Sole-tenant nodes. +message NodeGroup { + // Specifies how to handle instances when a node in the group undergoes maintenance. Set to one of: DEFAULT, RESTART_IN_PLACE, or MIGRATE_WITHIN_NODE_GROUP. The default value is DEFAULT. For more information, see Maintenance policies. + enum MaintenancePolicy { + // A value indicating that the enum field is not set. + UNDEFINED_MAINTENANCE_POLICY = 0; + + // Allow the node and corresponding instances to retain default maintenance behavior. + DEFAULT = 115302945; + + MAINTENANCE_POLICY_UNSPECIFIED = 72964182; + + // When maintenance must be done on a node, the instances on that node will be moved to other nodes in the group. Instances with onHostMaintenance = MIGRATE will live migrate to their destinations while instances with onHostMaintenance = TERMINATE will terminate and then restart on their destination nodes if automaticRestart = true. + MIGRATE_WITHIN_NODE_GROUP = 153483394; + + // Instances in this group will restart on the same node when maintenance has completed. Instances must have onHostMaintenance = TERMINATE, and they will only restart if automaticRestart = true. + RESTART_IN_PLACE = 228647325; + + } + + // + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + CREATING = 455564985; + + DELETING = 528602024; + + INVALID = 530283991; + + READY = 77848963; + + } + + // Specifies how autoscaling should behave. + optional NodeGroupAutoscalingPolicy autoscaling_policy = 221950041; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + optional string fingerprint = 234678500; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] The type of the resource. Always compute#nodeGroup for node group. + optional string kind = 3292052; + + // An opaque location hint used to place the Node close to other resources. This field is for use by internal tools that use the public API. The location hint here on the NodeGroup overrides any location_hint present in the NodeTemplate. + optional string location_hint = 350519505; + + // Specifies how to handle instances when a node in the group undergoes maintenance. Set to one of: DEFAULT, RESTART_IN_PLACE, or MIGRATE_WITHIN_NODE_GROUP. The default value is DEFAULT. For more information, see Maintenance policies. + // Check the MaintenancePolicy enum for the list of possible values. + optional string maintenance_policy = 528327646; + + optional NodeGroupMaintenanceWindow maintenance_window = 186374812; + + // The name of the resource, provided by the client when initially creating the resource. The resource name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // URL of the node template to create the node group from. + optional string node_template = 323154455; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // Share-settings for the node group + optional ShareSettings share_settings = 266668163; + + // [Output Only] The total number of nodes in the node group. + optional int32 size = 3530753; + + // + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // [Output Only] The name of the zone where the node group resides, such as us-central1-a. + optional string zone = 3744684; + +} + +// +message NodeGroupAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of NodeGroupsScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource.Always compute#nodeGroupAggregatedList for aggregated lists of node groups. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message NodeGroupAutoscalingPolicy { + // The autoscaling mode. Set to one of: ON, OFF, or ONLY_SCALE_OUT. For more information, see Autoscaler modes. + enum Mode { + // A value indicating that the enum field is not set. + UNDEFINED_MODE = 0; + + MODE_UNSPECIFIED = 371348091; + + // Autoscaling is disabled. + OFF = 78159; + + // Autocaling is fully enabled. + ON = 2527; + + // Autoscaling will only scale out and will not remove nodes. + ONLY_SCALE_OUT = 152713670; + + } + + // The maximum number of nodes that the group should have. Must be set if autoscaling is enabled. Maximum value allowed is 100. + optional int32 max_nodes = 297762838; + + // The minimum number of nodes that the group should have. + optional int32 min_nodes = 533370500; + + // The autoscaling mode. Set to one of: ON, OFF, or ONLY_SCALE_OUT. For more information, see Autoscaler modes. + // Check the Mode enum for the list of possible values. + optional string mode = 3357091; + +} + +// Contains a list of nodeGroups. +message NodeGroupList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of NodeGroup resources. + repeated NodeGroup items = 100526016; + + // [Output Only] Type of resource.Always compute#nodeGroupList for lists of node groups. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Time window specified for daily maintenance operations. GCE's internal maintenance will be performed within this window. +message NodeGroupMaintenanceWindow { + // [Output only] A predetermined duration for the window, automatically chosen to be the smallest possible in the given scenario. + optional Duration maintenance_duration = 525291840; + + // Start time of the window. This must be in UTC format that resolves to one of 00:00, 04:00, 08:00, 12:00, 16:00, or 20:00. For example, both 13:00-5 and 08:00 are valid. + optional string start_time = 37467274; + +} + +// +message NodeGroupNode { + // CPU overcommit. + enum CpuOvercommitType { + // A value indicating that the enum field is not set. + UNDEFINED_CPU_OVERCOMMIT_TYPE = 0; + + CPU_OVERCOMMIT_TYPE_UNSPECIFIED = 520665615; + + ENABLED = 182130465; + + NONE = 2402104; + + } + + // + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + CREATING = 455564985; + + DELETING = 528602024; + + INVALID = 530283991; + + READY = 77848963; + + REPAIRING = 413483285; + + } + + // Accelerators for this node. + repeated AcceleratorConfig accelerators = 269577064; + + // Node resources that are reserved by all instances. + optional InstanceConsumptionInfo consumed_resources = 334527118; + + // CPU overcommit. + // Check the CpuOvercommitType enum for the list of possible values. + optional string cpu_overcommit_type = 247727959; + + // Local disk configurations. + repeated LocalDisk disks = 95594102; + + // Instance data that shows consumed resources on the node. + repeated InstanceConsumptionData instance_consumption_data = 84715576; + + // Instances scheduled on this node. + repeated string instances = 29097598; + + // The name of the node. + optional string name = 3373707; + + // The type of this node. + optional string node_type = 465832791; + + // [Output Only] Reserved for future use. + optional bool satisfies_pzs = 480964267; + + // Binding properties for the physical server. + optional ServerBinding server_binding = 208179593; + + // Server ID associated with this node. + optional string server_id = 339433367; + + // + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // Total amount of available resources on the node. + optional InstanceConsumptionInfo total_resources = 97406698; + +} + +// +message NodeGroupsAddNodesRequest { + // Count of additional nodes to be added to the node group. + optional int32 additional_node_count = 134997930; + +} + +// +message NodeGroupsDeleteNodesRequest { + // Names of the nodes to delete. + repeated string nodes = 104993457; + +} + +// +message NodeGroupsListNodes { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Node resources. + repeated NodeGroupNode items = 100526016; + + // [Output Only] The resource type, which is always compute.nodeGroupsListNodes for the list of nodes in the specified node group. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message NodeGroupsScopedList { + // [Output Only] A list of node groups contained in this scope. + repeated NodeGroup node_groups = 73188017; + + // [Output Only] An informational warning that appears when the nodeGroup list is empty. + optional Warning warning = 50704284; + +} + +// +message NodeGroupsSetNodeTemplateRequest { + // Full or partial URL of the node template resource to be updated for this node group. + optional string node_template = 323154455; + +} + +// +message NodeGroupsSimulateMaintenanceEventRequest { + // Names of the nodes to go under maintenance simulation. + repeated string nodes = 104993457; + +} + +// Represent a sole-tenant Node Template resource. You can use a template to define properties for nodes in a node group. For more information, read Creating node groups and instances. +message NodeTemplate { + // CPU overcommit. + enum CpuOvercommitType { + // A value indicating that the enum field is not set. + UNDEFINED_CPU_OVERCOMMIT_TYPE = 0; + + CPU_OVERCOMMIT_TYPE_UNSPECIFIED = 520665615; + + ENABLED = 182130465; + + NONE = 2402104; + + } + + // [Output Only] The status of the node template. One of the following values: CREATING, READY, and DELETING. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // Resources are being allocated. + CREATING = 455564985; + + // The node template is currently being deleted. + DELETING = 528602024; + + // Invalid status. + INVALID = 530283991; + + // The node template is ready. + READY = 77848963; + + } + + repeated AcceleratorConfig accelerators = 269577064; + + // CPU overcommit. + // Check the CpuOvercommitType enum for the list of possible values. + optional string cpu_overcommit_type = 247727959; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + repeated LocalDisk disks = 95594102; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] The type of the resource. Always compute#nodeTemplate for node templates. + optional string kind = 3292052; + + // The name of the resource, provided by the client when initially creating the resource. The resource name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // Labels to use for node affinity, which will be used in instance scheduling. + map node_affinity_labels = 339007161; + + // The node type to use for nodes group that are created from this template. + optional string node_type = 465832791; + + // Do not use. Instead, use the node_type property. + optional NodeTemplateNodeTypeFlexibility node_type_flexibility = 315257905; + + // [Output Only] The name of the region where the node template resides, such as us-central1. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // Sets the binding properties for the physical server. Valid values include: - *[Default]* RESTART_NODE_ON_ANY_SERVER: Restarts VMs on any available physical server - RESTART_NODE_ON_MINIMAL_SERVER: Restarts VMs on the same physical server whenever possible See Sole-tenant node options for more information. + optional ServerBinding server_binding = 208179593; + + // [Output Only] The status of the node template. One of the following values: CREATING, READY, and DELETING. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // [Output Only] An optional, human-readable explanation of the status. + optional string status_message = 297428154; + +} + +// +message NodeTemplateAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of NodeTemplatesScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource.Always compute#nodeTemplateAggregatedList for aggregated lists of node templates. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of node templates. +message NodeTemplateList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of NodeTemplate resources. + repeated NodeTemplate items = 100526016; + + // [Output Only] Type of resource.Always compute#nodeTemplateList for lists of node templates. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message NodeTemplateNodeTypeFlexibility { + optional string cpus = 3060683; + + optional string local_ssd = 405741360; + + optional string memory = 532856065; + +} + +// +message NodeTemplatesScopedList { + // [Output Only] A list of node templates contained in this scope. + repeated NodeTemplate node_templates = 354111804; + + // [Output Only] An informational warning that appears when the node templates list is empty. + optional Warning warning = 50704284; + +} + +// Represent a sole-tenant Node Type resource. Each node within a node group must have a node type. A node type specifies the total amount of cores and memory for that node. Currently, the only available node type is n1-node-96-624 node type that has 96 vCPUs and 624 GB of memory, available in multiple zones. For more information read Node types. +message NodeType { + // [Output Only] The CPU platform used by this node type. + optional string cpu_platform = 410285354; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // [Output Only] The deprecation status associated with this node type. + optional DeprecationStatus deprecated = 515138995; + + // [Output Only] An optional textual description of the resource. + optional string description = 422937596; + + // [Output Only] The number of virtual CPUs that are available to the node type. + optional int32 guest_cpus = 393356754; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] The type of the resource. Always compute#nodeType for node types. + optional string kind = 3292052; + + // [Output Only] Local SSD available to the node type, defined in GB. + optional int32 local_ssd_gb = 329237578; + + // [Output Only] The amount of physical memory available to the node type, defined in MB. + optional int32 memory_mb = 116001171; + + // [Output Only] Name of the resource. + optional string name = 3373707; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] The name of the zone where the node type resides, such as us-central1-a. + optional string zone = 3744684; + +} + +// +message NodeTypeAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of NodeTypesScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource.Always compute#nodeTypeAggregatedList for aggregated lists of node types. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of node types. +message NodeTypeList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of NodeType resources. + repeated NodeType items = 100526016; + + // [Output Only] Type of resource.Always compute#nodeTypeList for lists of node types. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message NodeTypesScopedList { + // [Output Only] A list of node types contained in this scope. + repeated NodeType node_types = 482172924; + + // [Output Only] An informational warning that appears when the node types list is empty. + optional Warning warning = 50704284; + +} + +// Represents a notification endpoint. A notification endpoint resource defines an endpoint to receive notifications when there are status changes detected by the associated health check service. For more information, see Health checks overview. +message NotificationEndpoint { + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Settings of the gRPC notification endpoint including the endpoint URL and the retry duration. + optional NotificationEndpointGrpcSettings grpc_settings = 456139556; + + // [Output Only] A unique identifier for this resource type. The server generates this identifier. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#notificationEndpoint for notification endpoints. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // [Output Only] URL of the region where the notification endpoint resides. This field applies only to the regional resource. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + +} + +// Represents a gRPC setting that describes one gRPC notification endpoint and the retry duration attempting to send notification to this endpoint. +message NotificationEndpointGrpcSettings { + // Optional. If specified, this field is used to set the authority header by the sender of notifications. See https://tools.ietf.org/html/rfc7540#section-8.1.2.3 + optional string authority = 401868611; + + // Endpoint to which gRPC notifications are sent. This must be a valid gRPCLB DNS name. + optional string endpoint = 130489749; + + // Optional. If specified, this field is used to populate the "name" field in gRPC requests. + optional string payload_name = 300358300; + + // Optional. This field is used to configure how often to send a full update of all non-healthy backends. If unspecified, full updates are not sent. If specified, must be in the range between 600 seconds to 3600 seconds. Nanos are disallowed. Can only be set for regional notification endpoints. + optional Duration resend_interval = 478288969; + + // How much time (in seconds) is spent attempting notification retries until a successful response is received. Default is 30s. Limit is 20m (1200s). Must be a positive number. + optional uint32 retry_duration_sec = 115681117; + +} + +// +message NotificationEndpointList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of NotificationEndpoint resources. + repeated NotificationEndpoint items = 100526016; + + // [Output Only] Type of the resource. Always compute#notificationEndpoint for notification endpoints. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Represents an Operation resource. Google Compute Engine has three Operation resources: * [Global](/compute/docs/reference/rest/v1/globalOperations) * [Regional](/compute/docs/reference/rest/v1/regionOperations) * [Zonal](/compute/docs/reference/rest/v1/zoneOperations) You can use an operation resource to manage asynchronous API requests. For more information, read Handling API responses. Operations can be global, regional or zonal. - For global operations, use the `globalOperations` resource. - For regional operations, use the `regionOperations` resource. - For zonal operations, use the `zonalOperations` resource. For more information, read Global, Regional, and Zonal Resources. +message Operation { + // [Output Only] The status of the operation, which can be one of the following: `PENDING`, `RUNNING`, or `DONE`. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + DONE = 2104194; + + PENDING = 35394935; + + RUNNING = 121282975; + + } + + // [Output Only] The value of `requestId` if you provided it in the request. Not present otherwise. + optional string client_operation_id = 297240295; + + // [Deprecated] This field is deprecated. + optional string creation_timestamp = 30525366; + + // [Output Only] A textual description of the operation, which is set when the operation is created. + optional string description = 422937596; + + // [Output Only] The time that this operation was completed. This value is in RFC3339 text format. + optional string end_time = 114938801; + + // [Output Only] If errors are generated during processing of the operation, this field will be populated. + optional Error error = 96784904; + + // [Output Only] If the operation fails, this field contains the HTTP error message that was returned, such as `NOT FOUND`. + optional string http_error_message = 202521945 [(google.cloud.operation_field) = ERROR_MESSAGE]; + + // [Output Only] If the operation fails, this field contains the HTTP error status code that was returned. For example, a `404` means the resource was not found. + optional int32 http_error_status_code = 312345196 [(google.cloud.operation_field) = ERROR_CODE]; + + // [Output Only] The unique identifier for the operation. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] The time that this operation was requested. This value is in RFC3339 text format. + optional string insert_time = 433722515; + + // [Output Only] Type of the resource. Always `compute#operation` for Operation resources. + optional string kind = 3292052; + + // [Output Only] Name of the operation. + optional string name = 3373707 [(google.cloud.operation_field) = NAME]; + + // [Output Only] An ID that represents a group of operations, such as when a group of operations results from a `bulkInsert` API request. + optional string operation_group_id = 40171187; + + // [Output Only] The type of operation, such as `insert`, `update`, or `delete`, and so on. + optional string operation_type = 177650450; + + // [Output Only] An optional progress indicator that ranges from 0 to 100. There is no requirement that this be linear or support any granularity of operations. This should not be used to guess when the operation will be complete. This number should monotonically increase as the operation progresses. + optional int32 progress = 72663597; + + // [Output Only] The URL of the region where the operation resides. Only applicable when performing regional operations. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] The time that this operation was started by the server. This value is in RFC3339 text format. + optional string start_time = 37467274; + + // [Output Only] The status of the operation, which can be one of the following: `PENDING`, `RUNNING`, or `DONE`. + optional Status status = 181260274 [(google.cloud.operation_field) = STATUS]; + + // [Output Only] An optional textual description of the current status of the operation. + optional string status_message = 297428154; + + // [Output Only] The unique target ID, which identifies a specific incarnation of the target resource. + optional uint64 target_id = 258165385; + + // [Output Only] The URL of the resource that the operation modifies. For operations related to creating a snapshot, this points to the persistent disk that the snapshot was created from. + optional string target_link = 62671336; + + // [Output Only] User who requested the operation, for example: `user@example.com`. + optional string user = 3599307; + + // [Output Only] If warning messages are generated during processing of the operation, this field will be populated. + repeated Warnings warnings = 498091095; + + // [Output Only] The URL of the zone where the operation resides. Only applicable when performing per-zone operations. + optional string zone = 3744684; + +} + +// +message OperationAggregatedList { + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional string id = 3355; + + // [Output Only] A map of scoped operation lists. + map items = 100526016; + + // [Output Only] Type of resource. Always `compute#operationAggregatedList` for aggregated lists of operations. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than `maxResults`, use the `nextPageToken` as a value for the query parameter `pageToken` in the next list request. Subsequent list requests will have their own `nextPageToken` to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of Operation resources. +message OperationList { + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional string id = 3355; + + // [Output Only] A list of Operation resources. + repeated Operation items = 100526016; + + // [Output Only] Type of resource. Always `compute#operations` for Operations resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than `maxResults`, use the `nextPageToken` as a value for the query parameter `pageToken` in the next list request. Subsequent list requests will have their own `nextPageToken` to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message OperationsScopedList { + // [Output Only] A list of operations contained in this scope. + repeated Operation operations = 4184044; + + // [Output Only] Informational warning which replaces the list of operations when the list is empty. + optional Warning warning = 50704284; + +} + +// Settings controlling the eviction of unhealthy hosts from the load balancing pool for the backend service. +message OutlierDetection { + // The base time that a host is ejected for. The real ejection time is equal to the base ejection time multiplied by the number of times the host has been ejected. Defaults to 30000ms or 30s. + optional Duration base_ejection_time = 80997255; + + // Number of errors before a host is ejected from the connection pool. When the backend host is accessed over HTTP, a 5xx return code qualifies as an error. Defaults to 5. Not supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. + optional int32 consecutive_errors = 387193248; + + // The number of consecutive gateway failures (502, 503, 504 status or connection errors that are mapped to one of those status codes) before a consecutive gateway failure ejection occurs. Defaults to 3. Not supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. + optional int32 consecutive_gateway_failure = 417504250; + + // The percentage chance that a host will be actually ejected when an outlier status is detected through consecutive 5xx. This setting can be used to disable ejection or to ramp it up slowly. Defaults to 0. Not supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. + optional int32 enforcing_consecutive_errors = 213133760; + + // The percentage chance that a host will be actually ejected when an outlier status is detected through consecutive gateway failures. This setting can be used to disable ejection or to ramp it up slowly. Defaults to 100. Not supported when the backend service is referenced by a URL map that is bound to target gRPC proxy that has validateForProxyless field set to true. + optional int32 enforcing_consecutive_gateway_failure = 394440666; + + // The percentage chance that a host will be actually ejected when an outlier status is detected through success rate statistics. This setting can be used to disable ejection or to ramp it up slowly. Defaults to 100. + optional int32 enforcing_success_rate = 194508732; + + // Time interval between ejection analysis sweeps. This can result in both new ejections as well as hosts being returned to service. Defaults to 1 second. + optional Duration interval = 33547461; + + // Maximum percentage of hosts in the load balancing pool for the backend service that can be ejected. Defaults to 50%. + optional int32 max_ejection_percent = 18436888; + + // The number of hosts in a cluster that must have enough request volume to detect success rate outliers. If the number of hosts is less than this setting, outlier detection via success rate statistics is not performed for any host in the cluster. Defaults to 5. + optional int32 success_rate_minimum_hosts = 525766903; + + // The minimum number of total requests that must be collected in one interval (as defined by the interval duration above) to include this host in success rate based outlier detection. If the volume is lower than this setting, outlier detection via success rate statistics is not performed for that host. Defaults to 100. + optional int32 success_rate_request_volume = 281425357; + + // This factor is used to determine the ejection threshold for success rate outlier ejection. The ejection threshold is the difference between the mean success rate, and the product of this factor and the standard deviation of the mean success rate: mean - (stdev * success_rate_stdev_factor). This factor is divided by a thousand to get a double. That is, if the desired factor is 1.9, the runtime value should be 1900. Defaults to 1900. + optional int32 success_rate_stdev_factor = 174735773; + +} + +// Next free: 7 +message PacketIntervals { + // From how long ago in the past these intervals were observed. + enum Duration { + // A value indicating that the enum field is not set. + UNDEFINED_DURATION = 0; + + DURATION_UNSPECIFIED = 529071340; + + HOUR = 2223588; + + // From BfdSession object creation time. + MAX = 76100; + + MINUTE = 126786068; + + } + + // The type of packets for which inter-packet intervals were computed. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + // Only applies to Echo packets. This shows the intervals between sending and receiving the same packet. + LOOPBACK = 356174219; + + // Intervals between received packets. + RECEIVE = 189660867; + + // Intervals between transmitted packets. + TRANSMIT = 452903600; + + TYPE_UNSPECIFIED = 437714322; + + } + + // Average observed inter-packet interval in milliseconds. + optional int64 avg_ms = 204811827; + + // From how long ago in the past these intervals were observed. + // Check the Duration enum for the list of possible values. + optional string duration = 155471252; + + // Maximum observed inter-packet interval in milliseconds. + optional int64 max_ms = 529474145; + + // Minimum observed inter-packet interval in milliseconds. + optional int64 min_ms = 536564403; + + // Number of inter-packet intervals from which these statistics were derived. + optional int64 num_intervals = 186329813; + + // The type of packets for which inter-packet intervals were computed. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// Represents a Packet Mirroring resource. Packet Mirroring clones the traffic of specified instances in your Virtual Private Cloud (VPC) network and forwards it to a collector destination, such as an instance group of an internal TCP/UDP load balancer, for analysis or examination. For more information about setting up Packet Mirroring, see Using Packet Mirroring. +message PacketMirroring { + // Indicates whether or not this packet mirroring takes effect. If set to FALSE, this packet mirroring policy will not be enforced on the network. The default is TRUE. + enum Enable { + // A value indicating that the enum field is not set. + UNDEFINED_ENABLE = 0; + + FALSE = 66658563; + + TRUE = 2583950; + + } + + // The Forwarding Rule resource of type loadBalancingScheme=INTERNAL that will be used as collector for mirrored traffic. The specified forwarding rule must have isMirroringCollector set to true. + optional PacketMirroringForwardingRuleInfo collector_ilb = 426607853; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Indicates whether or not this packet mirroring takes effect. If set to FALSE, this packet mirroring policy will not be enforced on the network. The default is TRUE. + // Check the Enable enum for the list of possible values. + optional string enable = 311764355; + + // Filter for mirrored traffic. If unspecified, all traffic is mirrored. + optional PacketMirroringFilter filter = 336120696; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#packetMirroring for packet mirrorings. + optional string kind = 3292052; + + // PacketMirroring mirroredResourceInfos. MirroredResourceInfo specifies a set of mirrored VM instances, subnetworks and/or tags for which traffic from/to all VM instances will be mirrored. + optional PacketMirroringMirroredResourceInfo mirrored_resources = 124817348; + + // Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // Specifies the mirrored VPC network. Only packets in this network will be mirrored. All mirrored VMs should have a NIC in the given network. All mirrored subnetworks should belong to the given network. + optional PacketMirroringNetworkInfo network = 232872494; + + // The priority of applying this configuration. Priority is used to break ties in cases where there is more than one matching rule. In the case of two rules that apply for a given Instance, the one with the lowest-numbered priority value wins. Default value is 1000. Valid range is 0 through 65535. + optional uint32 priority = 445151652; + + // [Output Only] URI of the region where the packetMirroring resides. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + +} + +// Contains a list of packetMirrorings. +message PacketMirroringAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of PacketMirroring resources. + map items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message PacketMirroringFilter { + // Direction of traffic to mirror, either INGRESS, EGRESS, or BOTH. The default is BOTH. + enum Direction { + // A value indicating that the enum field is not set. + UNDEFINED_DIRECTION = 0; + + // Default, both directions are mirrored. + BOTH = 2044801; + + // Only egress traffic is mirrored. + EGRESS = 432880501; + + // Only ingress traffic is mirrored. + INGRESS = 516931221; + + } + + // Protocols that apply as filter on mirrored traffic. If no protocols are specified, all traffic that matches the specified CIDR ranges is mirrored. If neither cidrRanges nor IPProtocols is specified, all traffic is mirrored. + repeated string I_p_protocols = 98544854; + + // IP CIDR ranges that apply as filter on the source (ingress) or destination (egress) IP in the IP header. Only IPv4 is supported. If no ranges are specified, all traffic that matches the specified IPProtocols is mirrored. If neither cidrRanges nor IPProtocols is specified, all traffic is mirrored. + repeated string cidr_ranges = 487901697; + + // Direction of traffic to mirror, either INGRESS, EGRESS, or BOTH. The default is BOTH. + // Check the Direction enum for the list of possible values. + optional string direction = 111150975; + +} + +// +message PacketMirroringForwardingRuleInfo { + // [Output Only] Unique identifier for the forwarding rule; defined by the server. + optional string canonical_url = 512294820; + + // Resource URL to the forwarding rule representing the ILB configured as destination of the mirrored traffic. + optional string url = 116079; + +} + +// Contains a list of PacketMirroring resources. +message PacketMirroringList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of PacketMirroring resources. + repeated PacketMirroring items = 100526016; + + // [Output Only] Type of resource. Always compute#packetMirroring for packetMirrorings. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message PacketMirroringMirroredResourceInfo { + // A set of virtual machine instances that are being mirrored. They must live in zones contained in the same region as this packetMirroring. Note that this config will apply only to those network interfaces of the Instances that belong to the network specified in this packetMirroring. You may specify a maximum of 50 Instances. + repeated PacketMirroringMirroredResourceInfoInstanceInfo instances = 29097598; + + // A set of subnetworks for which traffic from/to all VM instances will be mirrored. They must live in the same region as this packetMirroring. You may specify a maximum of 5 subnetworks. + repeated PacketMirroringMirroredResourceInfoSubnetInfo subnetworks = 415853125; + + // A set of mirrored tags. Traffic from/to all VM instances that have one or more of these tags will be mirrored. + repeated string tags = 3552281; + +} + +// +message PacketMirroringMirroredResourceInfoInstanceInfo { + // [Output Only] Unique identifier for the instance; defined by the server. + optional string canonical_url = 512294820; + + // Resource URL to the virtual machine instance which is being mirrored. + optional string url = 116079; + +} + +// +message PacketMirroringMirroredResourceInfoSubnetInfo { + // [Output Only] Unique identifier for the subnetwork; defined by the server. + optional string canonical_url = 512294820; + + // Resource URL to the subnetwork for which traffic from/to all VM instances will be mirrored. + optional string url = 116079; + +} + +// +message PacketMirroringNetworkInfo { + // [Output Only] Unique identifier for the network; defined by the server. + optional string canonical_url = 512294820; + + // URL of the network resource. + optional string url = 116079; + +} + +// +message PacketMirroringsScopedList { + // A list of packetMirrorings contained in this scope. + repeated PacketMirroring packet_mirrorings = 154615079; + + // Informational warning which replaces the list of packetMirrorings when the list is empty. + optional Warning warning = 50704284; + +} + +// A request message for Autoscalers.Patch. See the method description for details. +message PatchAutoscalerRequest { + // Name of the autoscaler to patch. + optional string autoscaler = 517258967; + + // The body resource for this request + Autoscaler autoscaler_resource = 207616118 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for BackendBuckets.Patch. See the method description for details. +message PatchBackendBucketRequest { + // Name of the BackendBucket resource to patch. + string backend_bucket = 91714037 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + BackendBucket backend_bucket_resource = 380757784 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for BackendServices.Patch. See the method description for details. +message PatchBackendServiceRequest { + // Name of the BackendService resource to patch. + string backend_service = 306946058 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + BackendService backend_service_resource = 347586723 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for FirewallPolicies.Patch. See the method description for details. +message PatchFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + FirewallPolicy firewall_policy_resource = 495049532 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Firewalls.Patch. See the method description for details. +message PatchFirewallRequest { + // Name of the firewall rule to patch. + string firewall = 511016192 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + Firewall firewall_resource = 41425005 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for ForwardingRules.Patch. See the method description for details. +message PatchForwardingRuleRequest { + // Name of the ForwardingRule resource to patch. + string forwarding_rule = 269964030 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + ForwardingRule forwarding_rule_resource = 301211695 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for GlobalForwardingRules.Patch. See the method description for details. +message PatchGlobalForwardingRuleRequest { + // Name of the ForwardingRule resource to patch. + string forwarding_rule = 269964030 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + ForwardingRule forwarding_rule_resource = 301211695 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for GlobalPublicDelegatedPrefixes.Patch. See the method description for details. +message PatchGlobalPublicDelegatedPrefixeRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the PublicDelegatedPrefix resource to patch. + string public_delegated_prefix = 204238440 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + PublicDelegatedPrefix public_delegated_prefix_resource = 47594501 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for HealthChecks.Patch. See the method description for details. +message PatchHealthCheckRequest { + // Name of the HealthCheck resource to patch. + string health_check = 308876645 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + HealthCheck health_check_resource = 201925032 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Images.Patch. See the method description for details. +message PatchImageRequest { + // Name of the image resource to patch. + string image = 100313435 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + Image image_resource = 371171954 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for InstanceGroupManagers.Patch. See the method description for details. +message PatchInstanceGroupManagerRequest { + // The name of the instance group manager. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstanceGroupManager instance_group_manager_resource = 261063946 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where you want to create the managed instance group. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for InterconnectAttachments.Patch. See the method description for details. +message PatchInterconnectAttachmentRequest { + // Name of the interconnect attachment to patch. + string interconnect_attachment = 308135284 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InterconnectAttachment interconnect_attachment_resource = 212341369 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Interconnects.Patch. See the method description for details. +message PatchInterconnectRequest { + // Name of the interconnect to update. + string interconnect = 224601230 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + Interconnect interconnect_resource = 397611167 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for NetworkEdgeSecurityServices.Patch. See the method description for details. +message PatchNetworkEdgeSecurityServiceRequest { + // Name of the network edge security service to update. + string network_edge_security_service = 157011879 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + NetworkEdgeSecurityService network_edge_security_service_resource = 477548966 [(google.api.field_behavior) = REQUIRED]; + + optional string paths = 106438894; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Indicates fields to be updated as part of this request. + optional string update_mask = 500079778; + +} + +// A request message for NetworkFirewallPolicies.Patch. See the method description for details. +message PatchNetworkFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + FirewallPolicy firewall_policy_resource = 495049532 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Networks.Patch. See the method description for details. +message PatchNetworkRequest { + // Name of the network to update. + string network = 232872494 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + Network network_resource = 122105599 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for NodeGroups.Patch. See the method description for details. +message PatchNodeGroupRequest { + // Name of the NodeGroup resource to update. + string node_group = 469958146 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + NodeGroup node_group_resource = 505321899 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for PacketMirrorings.Patch. See the method description for details. +message PatchPacketMirroringRequest { + // Name of the PacketMirroring resource to patch. + string packet_mirroring = 22305996 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + PacketMirroring packet_mirroring_resource = 493501985 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for InstanceGroupManagers.PatchPerInstanceConfigs. See the method description for details. +message PatchPerInstanceConfigsInstanceGroupManagerRequest { + // The name of the managed instance group. It should conform to RFC1035. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstanceGroupManagersPatchPerInstanceConfigsReq instance_group_managers_patch_per_instance_configs_req_resource = 356650495 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where the managed instance group is located. It should conform to RFC1035. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for RegionInstanceGroupManagers.PatchPerInstanceConfigs. See the method description for details. +message PatchPerInstanceConfigsRegionInstanceGroupManagerRequest { + // The name of the managed instance group. It should conform to RFC1035. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request, should conform to RFC1035. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionInstanceGroupManagerPatchInstanceConfigReq region_instance_group_manager_patch_instance_config_req_resource = 197682890 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for PublicAdvertisedPrefixes.Patch. See the method description for details. +message PatchPublicAdvertisedPrefixeRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the PublicAdvertisedPrefix resource to patch. + string public_advertised_prefix = 101874590 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + PublicAdvertisedPrefix public_advertised_prefix_resource = 233614223 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for PublicDelegatedPrefixes.Patch. See the method description for details. +message PatchPublicDelegatedPrefixeRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the PublicDelegatedPrefix resource to patch. + string public_delegated_prefix = 204238440 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + PublicDelegatedPrefix public_delegated_prefix_resource = 47594501 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionAutoscalers.Patch. See the method description for details. +message PatchRegionAutoscalerRequest { + // Name of the autoscaler to patch. + optional string autoscaler = 517258967; + + // The body resource for this request + Autoscaler autoscaler_resource = 207616118 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionBackendServices.Patch. See the method description for details. +message PatchRegionBackendServiceRequest { + // Name of the BackendService resource to patch. + string backend_service = 306946058 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + BackendService backend_service_resource = 347586723 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionHealthChecks.Patch. See the method description for details. +message PatchRegionHealthCheckRequest { + // Name of the HealthCheck resource to patch. + string health_check = 308876645 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + HealthCheck health_check_resource = 201925032 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionHealthCheckServices.Patch. See the method description for details. +message PatchRegionHealthCheckServiceRequest { + // Name of the HealthCheckService to update. The name must be 1-63 characters long, and comply with RFC1035. + string health_check_service = 408374747 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + HealthCheckService health_check_service_resource = 477367794 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionInstanceGroupManagers.Patch. See the method description for details. +message PatchRegionInstanceGroupManagerRequest { + // The name of the instance group manager. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstanceGroupManager instance_group_manager_resource = 261063946 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionNetworkFirewallPolicies.Patch. See the method description for details. +message PatchRegionNetworkFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + FirewallPolicy firewall_policy_resource = 495049532 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionSecurityPolicies.Patch. See the method description for details. +message PatchRegionSecurityPolicyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the security policy to update. + string security_policy = 171082513 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + SecurityPolicy security_policy_resource = 216159612 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionSslPolicies.Patch. See the method description for details. +message PatchRegionSslPolicyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the SSL policy to update. The name must be 1-63 characters long, and comply with RFC1035. + string ssl_policy = 295190213 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + SslPolicy ssl_policy_resource = 274891848 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionTargetHttpsProxies.Patch. See the method description for details. +message PatchRegionTargetHttpsProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetHttpsProxy resource to patch. + string target_https_proxy = 52336748 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TargetHttpsProxy target_https_proxy_resource = 433657473 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionUrlMaps.Patch. See the method description for details. +message PatchRegionUrlMapRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // begin_interface: MixerMutationRequestBuilder Request ID to support idempotency. + optional string request_id = 37109963; + + // Name of the UrlMap resource to patch. + string url_map = 367020684 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + UrlMap url_map_resource = 168675425 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Routers.Patch. See the method description for details. +message PatchRouterRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the Router resource to patch. + string router = 148608841 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + Router router_resource = 155222084 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for FirewallPolicies.PatchRule. See the method description for details. +message PatchRuleFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + FirewallPolicyRule firewall_policy_rule_resource = 250523523 [(google.api.field_behavior) = REQUIRED]; + + // The priority of the rule to patch. + optional int32 priority = 445151652; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for NetworkFirewallPolicies.PatchRule. See the method description for details. +message PatchRuleNetworkFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + FirewallPolicyRule firewall_policy_rule_resource = 250523523 [(google.api.field_behavior) = REQUIRED]; + + // The priority of the rule to patch. + optional int32 priority = 445151652; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionNetworkFirewallPolicies.PatchRule. See the method description for details. +message PatchRuleRegionNetworkFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + FirewallPolicyRule firewall_policy_rule_resource = 250523523 [(google.api.field_behavior) = REQUIRED]; + + // The priority of the rule to patch. + optional int32 priority = 445151652; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for SecurityPolicies.PatchRule. See the method description for details. +message PatchRuleSecurityPolicyRequest { + // The priority of the rule to patch. + optional int32 priority = 445151652; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the security policy to update. + string security_policy = 171082513 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + SecurityPolicyRule security_policy_rule_resource = 402693443 [(google.api.field_behavior) = REQUIRED]; + + // If true, the request will not be committed. + optional bool validate_only = 242744629; + +} + +// A request message for SecurityPolicies.Patch. See the method description for details. +message PatchSecurityPolicyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the security policy to update. + string security_policy = 171082513 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + SecurityPolicy security_policy_resource = 216159612 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ServiceAttachments.Patch. See the method description for details. +message PatchServiceAttachmentRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The region scoping this request and should conform to RFC1035. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The resource id of the ServiceAttachment to patch. It should conform to RFC1035 resource name or be a string form on an unsigned long number. + string service_attachment = 338957549 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + ServiceAttachment service_attachment_resource = 472980256 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for SslPolicies.Patch. See the method description for details. +message PatchSslPolicyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the SSL policy to update. The name must be 1-63 characters long, and comply with RFC1035. + string ssl_policy = 295190213 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + SslPolicy ssl_policy_resource = 274891848 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Subnetworks.Patch. See the method description for details. +message PatchSubnetworkRequest { + // The drain timeout specifies the upper bound in seconds on the amount of time allowed to drain connections from the current ACTIVE subnetwork to the current BACKUP subnetwork. The drain timeout is only applicable when the following conditions are true: - the subnetwork being patched has purpose = INTERNAL_HTTPS_LOAD_BALANCER - the subnetwork being patched has role = BACKUP - the patch request is setting the role to ACTIVE. Note that after this patch operation the roles of the ACTIVE and BACKUP subnetworks will be swapped. + optional int32 drain_timeout_seconds = 357707098; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the Subnetwork resource to patch. + string subnetwork = 307827694 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + Subnetwork subnetwork_resource = 42233151 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetGrpcProxies.Patch. See the method description for details. +message PatchTargetGrpcProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetGrpcProxy resource to patch. + string target_grpc_proxy = 5020283 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TargetGrpcProxy target_grpc_proxy_resource = 328922450 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetHttpProxies.Patch. See the method description for details. +message PatchTargetHttpProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetHttpProxy resource to patch. + string target_http_proxy = 206872421 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TargetHttpProxy target_http_proxy_resource = 24696744 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetHttpsProxies.Patch. See the method description for details. +message PatchTargetHttpsProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetHttpsProxy resource to patch. + string target_https_proxy = 52336748 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TargetHttpsProxy target_https_proxy_resource = 433657473 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for UrlMaps.Patch. See the method description for details. +message PatchUrlMapRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the UrlMap resource to patch. + string url_map = 367020684 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + UrlMap url_map_resource = 168675425 [(google.api.field_behavior) = REQUIRED]; + +} + +// A matcher for the path portion of the URL. The BackendService from the longest-matched rule will serve the URL. If no rule was matched, the default service is used. +message PathMatcher { + // defaultRouteAction takes effect when none of the pathRules or routeRules match. The load balancer performs advanced routing actions, such as URL rewrites and header transformations, before forwarding the request to the selected backend. If defaultRouteAction specifies any weightedBackendServices, defaultService must not be set. Conversely if defaultService is set, defaultRouteAction cannot contain any weightedBackendServices. Only one of defaultRouteAction or defaultUrlRedirect must be set. URL maps for Classic external HTTP(S) load balancers only support the urlRewrite action within a path matcher's defaultRouteAction. + optional HttpRouteAction default_route_action = 378919466; + + // The full or partial URL to the BackendService resource. This URL is used if none of the pathRules or routeRules defined by this PathMatcher are matched. For example, the following are all valid URLs to a BackendService resource: - https://www.googleapis.com/compute/v1/projects/project /global/backendServices/backendService - compute/v1/projects/project/global/backendServices/backendService - global/backendServices/backendService If defaultRouteAction is also specified, advanced routing actions, such as URL rewrites, take effect before sending the request to the backend. However, if defaultService is specified, defaultRouteAction cannot contain any weightedBackendServices. Conversely, if defaultRouteAction specifies any weightedBackendServices, defaultService must not be specified. Only one of defaultService, defaultUrlRedirect , or defaultRouteAction.weightedBackendService must be set. Authorization requires one or more of the following Google IAM permissions on the specified resource default_service: - compute.backendBuckets.use - compute.backendServices.use + optional string default_service = 370242231; + + // When none of the specified pathRules or routeRules match, the request is redirected to a URL specified by defaultUrlRedirect. If defaultUrlRedirect is specified, defaultService or defaultRouteAction must not be set. Not supported when the URL map is bound to a target gRPC proxy. + optional HttpRedirectAction default_url_redirect = 359503338; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Specifies changes to request and response headers that need to take effect for the selected backend service. HeaderAction specified here are applied after the matching HttpRouteRule HeaderAction and before the HeaderAction in the UrlMap HeaderAction is not supported for load balancers that have their loadBalancingScheme set to EXTERNAL. Not supported when the URL map is bound to a target gRPC proxy that has validateForProxyless field set to true. + optional HttpHeaderAction header_action = 328077352; + + // The name to which this PathMatcher is referred by the HostRule. + optional string name = 3373707; + + // The list of path rules. Use this list instead of routeRules when routing based on simple path matching is all that's required. The order by which path rules are specified does not matter. Matches are always done on the longest-path-first basis. For example: a pathRule with a path /a/b/c/* will match before /a/b/* irrespective of the order in which those paths appear in this list. Within a given pathMatcher, only one of pathRules or routeRules must be set. + repeated PathRule path_rules = 104439901; + + // The list of HTTP route rules. Use this list instead of pathRules when advanced route matching and routing actions are desired. routeRules are evaluated in order of priority, from the lowest to highest number. Within a given pathMatcher, you can set only one of pathRules or routeRules. + repeated HttpRouteRule route_rules = 376292225; + +} + +// A path-matching rule for a URL. If matched, will use the specified BackendService to handle the traffic arriving at this URL. +message PathRule { + // The list of path patterns to match. Each must start with / and the only place a * is allowed is at the end following a /. The string fed to the path matcher does not include any text after the first ? or #, and those chars are not allowed here. + repeated string paths = 106438894; + + // In response to a matching path, the load balancer performs advanced routing actions, such as URL rewrites and header transformations, before forwarding the request to the selected backend. If routeAction specifies any weightedBackendServices, service must not be set. Conversely if service is set, routeAction cannot contain any weightedBackendServices. Only one of routeAction or urlRedirect must be set. URL maps for Classic external HTTP(S) load balancers only support the urlRewrite action within a path rule's routeAction. + optional HttpRouteAction route_action = 424563948; + + // The full or partial URL of the backend service resource to which traffic is directed if this rule is matched. If routeAction is also specified, advanced routing actions, such as URL rewrites, take effect before sending the request to the backend. However, if service is specified, routeAction cannot contain any weightedBackendServices. Conversely, if routeAction specifies any weightedBackendServices, service must not be specified. Only one of urlRedirect, service or routeAction.weightedBackendService must be set. + optional string service = 373540533; + + // When a path pattern is matched, the request is redirected to a URL specified by urlRedirect. If urlRedirect is specified, service or routeAction must not be set. Not supported when the URL map is bound to a target gRPC proxy. + optional HttpRedirectAction url_redirect = 405147820; + +} + +// +message PerInstanceConfig { + // The status of applying this per-instance configuration on the corresponding managed instance. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // The per-instance configuration is being applied to the instance, but is not yet effective, possibly waiting for the instance to, for example, REFRESH. + APPLYING = 352003508; + + // The per-instance configuration deletion is being applied on the instance, possibly waiting for the instance to, for example, REFRESH. + DELETING = 528602024; + + // The per-instance configuration is effective on the instance, meaning that all disks, ips and metadata specified in this configuration are attached or set on the instance. + EFFECTIVE = 244201863; + + // *[Default]* The default status, when no per-instance configuration exists. + NONE = 2402104; + + // The per-instance configuration is set on an instance but not been applied yet. + UNAPPLIED = 483935140; + + // The per-instance configuration has been deleted, but the deletion is not yet applied. + UNAPPLIED_DELETION = 313956873; + + } + + // Fingerprint of this per-instance config. This field can be used in optimistic locking. It is ignored when inserting a per-instance config. An up-to-date fingerprint must be provided in order to update an existing per-instance configuration or the field needs to be unset. + optional string fingerprint = 234678500; + + // The name of a per-instance configuration and its corresponding instance. Serves as a merge key during UpdatePerInstanceConfigs operations, that is, if a per-instance configuration with the same name exists then it will be updated, otherwise a new one will be created for the VM instance with the same name. An attempt to create a per-instance configconfiguration for a VM instance that either doesn't exist or is not part of the group will result in an error. + optional string name = 3373707; + + // The intended preserved state for the given instance. Does not contain preserved state generated from a stateful policy. + optional PreservedState preserved_state = 2634026; + + // The status of applying this per-instance configuration on the corresponding managed instance. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + +} + +// An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. A `Policy` is a collection of `bindings`. A `binding` binds one or more `members`, or principals, to a single `role`. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions; each `role` can be an IAM predefined role or a user-created custom role. For some types of Google Cloud resources, a `binding` can also specify a `condition`, which is a logical expression that allows access to a resource only if the expression evaluates to `true`. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). **JSON example:** { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 } **YAML example:** bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3 For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/). +message Policy { + // Specifies cloud audit logging configuration for this policy. + repeated AuditConfig audit_configs = 328080653; + + // Associates a list of `members`, or principals, with a `role`. Optionally, may specify a `condition` that determines how and when the `bindings` are applied. Each of the `bindings` must contain at least one principal. The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 of these principals can be Google groups. Each occurrence of a principal counts towards these limits. For example, if the `bindings` grant 50 different roles to `user:alice@example.com`, and not to any other principal, then you can add another 1,450 principals to the `bindings` in the `Policy`. + repeated Binding bindings = 403251854; + + // `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform policy updates in order to avoid race conditions: An `etag` is returned in the response to `getIamPolicy`, and systems are expected to put that etag in the request to `setIamPolicy` to ensure that their change will be applied to the same version of the policy. **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. + optional string etag = 3123477; + + optional bool iam_owned = 450566203; + + // This is deprecated and has no effect. Do not use. + repeated Rule rules = 108873975; + + // Specifies the format of the policy. Valid values are `0`, `1`, and `3`. Requests that specify an invalid value are rejected. Any operation that affects conditional role bindings must specify version `3`. This requirement applies to the following operations: * Getting a policy that includes a conditional role binding * Adding a conditional role binding to a policy * Changing a conditional role binding in a policy * Removing any role binding, with or without a condition, from a policy that includes conditions **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. If a policy does not include any conditions, operations on that policy may specify any valid version or leave the field unset. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). + optional int32 version = 351608024; + +} + +// +message PreconfiguredWafSet { + // List of entities that are currently supported for WAF rules. + repeated WafExpressionSet expression_sets = 474011032; + +} + +// Preserved state for a given instance. +message PreservedState { + // Preserved disks defined for this instance. This map is keyed with the device names of the disks. + map disks = 95594102; + + // Preserved metadata defined for this instance. + map metadata = 86866735; + +} + +// +message PreservedStatePreservedDisk { + // These stateful disks will never be deleted during autohealing, update, instance recreate operations. This flag is used to configure if the disk should be deleted after it is no longer used by the group, e.g. when the given instance or the whole MIG is deleted. Note: disks attached in READ_ONLY mode cannot be auto-deleted. + enum AutoDelete { + // A value indicating that the enum field is not set. + UNDEFINED_AUTO_DELETE = 0; + + NEVER = 74175084; + + ON_PERMANENT_INSTANCE_DELETION = 95727719; + + } + + // The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode. + enum Mode { + // A value indicating that the enum field is not set. + UNDEFINED_MODE = 0; + + // Attaches this disk in read-only mode. Multiple VM instances can use a disk in READ_ONLY mode at a time. + READ_ONLY = 91950261; + + // *[Default]* Attaches this disk in READ_WRITE mode. Only one VM instance at a time can be attached to a disk in READ_WRITE mode. + READ_WRITE = 173607894; + + } + + // These stateful disks will never be deleted during autohealing, update, instance recreate operations. This flag is used to configure if the disk should be deleted after it is no longer used by the group, e.g. when the given instance or the whole MIG is deleted. Note: disks attached in READ_ONLY mode cannot be auto-deleted. + // Check the AutoDelete enum for the list of possible values. + optional string auto_delete = 464761403; + + // The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode. + // Check the Mode enum for the list of possible values. + optional string mode = 3357091; + + // The URL of the disk resource that is stateful and should be attached to the VM instance. + optional string source = 177235995; + +} + +// A request message for Routers.Preview. See the method description for details. +message PreviewRouterRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name of the Router resource to query. + string router = 148608841 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + Router router_resource = 155222084 [(google.api.field_behavior) = REQUIRED]; + +} + +// Represents a Project resource. A project is used to organize resources in a Google Cloud Platform environment. For more information, read about the Resource Hierarchy. +message Project { + // This signifies the default network tier used for configuring resources of the project and can only take the following values: PREMIUM, STANDARD. Initially the default network tier is PREMIUM. + enum DefaultNetworkTier { + // A value indicating that the enum field is not set. + UNDEFINED_DEFAULT_NETWORK_TIER = 0; + + // Public internet quality with fixed bandwidth. + FIXED_STANDARD = 310464328; + + // High quality, Google-grade network tier, support for all networking products. + PREMIUM = 399530551; + + // Public internet quality, only limited support for other networking products. + STANDARD = 484642493; + + // (Output only) Temporary tier for FIXED_STANDARD when fixed standard tier is expired or not configured. + STANDARD_OVERRIDES_FIXED_STANDARD = 465847234; + + } + + // [Output Only] Default internal DNS setting used by VMs running in this project. + enum VmDnsSetting { + // A value indicating that the enum field is not set. + UNDEFINED_VM_DNS_SETTING = 0; + + GLOBAL_DEFAULT = 345419141; + + UNSPECIFIED_VM_DNS_SETTING = 35691930; + + ZONAL_DEFAULT = 368475782; + + ZONAL_ONLY = 521198951; + + } + + // [Output Only] The role this project has in a shared VPC configuration. Currently, only projects with the host role, which is specified by the value HOST, are differentiated. + enum XpnProjectStatus { + // A value indicating that the enum field is not set. + UNDEFINED_XPN_PROJECT_STATUS = 0; + + HOST = 2223528; + + UNSPECIFIED_XPN_PROJECT_STATUS = 340393257; + + } + + // Metadata key/value pairs available to all instances contained in this project. See Custom metadata for more information. + optional Metadata common_instance_metadata = 185794117; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // This signifies the default network tier used for configuring resources of the project and can only take the following values: PREMIUM, STANDARD. Initially the default network tier is PREMIUM. + // Check the DefaultNetworkTier enum for the list of possible values. + optional string default_network_tier = 471753361; + + // [Output Only] Default service account used by VMs running in this project. + optional string default_service_account = 298712229; + + // An optional textual description of the resource. + optional string description = 422937596; + + // Restricted features enabled for use on this project. + repeated string enabled_features = 469017467; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. This is *not* the project ID, and is just a unique ID used by Compute Engine to identify resources. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#project for projects. + optional string kind = 3292052; + + // The project ID. For example: my-example-project. Use the project ID to make requests to Compute Engine. + optional string name = 3373707; + + // [Output Only] Quotas assigned to this project. + repeated Quota quotas = 125341947; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // The naming prefix for daily usage reports and the Google Cloud Storage bucket where they are stored. + optional UsageExportLocation usage_export_location = 347543874; + + // [Output Only] Default internal DNS setting used by VMs running in this project. + // Check the VmDnsSetting enum for the list of possible values. + optional string vm_dns_setting = 58856370; + + // [Output Only] The role this project has in a shared VPC configuration. Currently, only projects with the host role, which is specified by the value HOST, are differentiated. + // Check the XpnProjectStatus enum for the list of possible values. + optional string xpn_project_status = 228419265; + +} + +// +message ProjectsDisableXpnResourceRequest { + // Service resource (a.k.a service project) ID. + optional XpnResourceId xpn_resource = 133384631; + +} + +// +message ProjectsEnableXpnResourceRequest { + // Service resource (a.k.a service project) ID. + optional XpnResourceId xpn_resource = 133384631; + +} + +// +message ProjectsGetXpnResources { + // [Output Only] Type of resource. Always compute#projectsGetXpnResources for lists of service resources (a.k.a service projects) + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // Service resources (a.k.a service projects) attached to this project as their shared VPC host. + repeated XpnResourceId resources = 164412965; + +} + +// +message ProjectsListXpnHostsRequest { + // Optional organization ID managed by Cloud Resource Manager, for which to list shared VPC host projects. If not specified, the organization will be inferred from the project. + optional string organization = 105180467; + +} + +// +message ProjectsSetDefaultNetworkTierRequest { + // Default network tier to be set. + enum NetworkTier { + // A value indicating that the enum field is not set. + UNDEFINED_NETWORK_TIER = 0; + + // Public internet quality with fixed bandwidth. + FIXED_STANDARD = 310464328; + + // High quality, Google-grade network tier, support for all networking products. + PREMIUM = 399530551; + + // Public internet quality, only limited support for other networking products. + STANDARD = 484642493; + + // (Output only) Temporary tier for FIXED_STANDARD when fixed standard tier is expired or not configured. + STANDARD_OVERRIDES_FIXED_STANDARD = 465847234; + + } + + // Default network tier to be set. + // Check the NetworkTier enum for the list of possible values. + optional string network_tier = 517397843; + +} + +// A public advertised prefix represents an aggregated IP prefix or netblock which customers bring to cloud. The IP prefix is a single unit of route advertisement and is announced globally to the internet. +message PublicAdvertisedPrefix { + // The status of the public advertised prefix. Possible values include: - `INITIAL`: RPKI validation is complete. - `PTR_CONFIGURED`: User has configured the PTR. - `VALIDATED`: Reverse DNS lookup is successful. - `REVERSE_DNS_LOOKUP_FAILED`: Reverse DNS lookup failed. - `PREFIX_CONFIGURATION_IN_PROGRESS`: The prefix is being configured. - `PREFIX_CONFIGURATION_COMPLETE`: The prefix is fully configured. - `PREFIX_REMOVAL_IN_PROGRESS`: The prefix is being removed. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // RPKI validation is complete. + INITIAL = 518841124; + + // The prefix is fully configured. + PREFIX_CONFIGURATION_COMPLETE = 480889551; + + // The prefix is being configured. + PREFIX_CONFIGURATION_IN_PROGRESS = 378550961; + + // The prefix is being removed. + PREFIX_REMOVAL_IN_PROGRESS = 284375783; + + // User has configured the PTR. + PTR_CONFIGURED = 513497167; + + // Reverse DNS lookup failed. + REVERSE_DNS_LOOKUP_FAILED = 295755183; + + // Reverse DNS lookup is successful. + VALIDATED = 66197998; + + } + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // The IPv4 address to be used for reverse DNS verification. + optional string dns_verification_ip = 241011381; + + // Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a new PublicAdvertisedPrefix. An up-to-date fingerprint must be provided in order to update the PublicAdvertisedPrefix, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve a PublicAdvertisedPrefix. + optional string fingerprint = 234678500; + + // [Output Only] The unique identifier for the resource type. The server generates this identifier. + optional uint64 id = 3355; + + // The IPv4 address range, in CIDR format, represented by this public advertised prefix. + optional string ip_cidr_range = 98117322; + + // [Output Only] Type of the resource. Always compute#publicAdvertisedPrefix for public advertised prefixes. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // [Output Only] The list of public delegated prefixes that exist for this public advertised prefix. + repeated PublicAdvertisedPrefixPublicDelegatedPrefix public_delegated_prefixs = 425811723; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] The shared secret to be used for reverse DNS verification. + optional string shared_secret = 381932490; + + // The status of the public advertised prefix. Possible values include: - `INITIAL`: RPKI validation is complete. - `PTR_CONFIGURED`: User has configured the PTR. - `VALIDATED`: Reverse DNS lookup is successful. - `REVERSE_DNS_LOOKUP_FAILED`: Reverse DNS lookup failed. - `PREFIX_CONFIGURATION_IN_PROGRESS`: The prefix is being configured. - `PREFIX_CONFIGURATION_COMPLETE`: The prefix is fully configured. - `PREFIX_REMOVAL_IN_PROGRESS`: The prefix is being removed. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + +} + +// +message PublicAdvertisedPrefixList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of PublicAdvertisedPrefix resources. + repeated PublicAdvertisedPrefix items = 100526016; + + // [Output Only] Type of the resource. Always compute#publicAdvertisedPrefix for public advertised prefixes. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Represents a CIDR range which can be used to assign addresses. +message PublicAdvertisedPrefixPublicDelegatedPrefix { + // The IP address range of the public delegated prefix + optional string ip_range = 145092645; + + // The name of the public delegated prefix + optional string name = 3373707; + + // The project number of the public delegated prefix + optional string project = 227560217; + + // The region of the public delegated prefix if it is regional. If absent, the prefix is global. + optional string region = 138946292; + + // The status of the public delegated prefix. Possible values are: INITIALIZING: The public delegated prefix is being initialized and addresses cannot be created yet. ANNOUNCED: The public delegated prefix is active. + optional string status = 181260274; + +} + +// A PublicDelegatedPrefix resource represents an IP block within a PublicAdvertisedPrefix that is configured within a single cloud scope (global or region). IPs in the block can be allocated to resources within that scope. Public delegated prefixes may be further broken up into smaller IP blocks in the same scope as the parent block. +message PublicDelegatedPrefix { + // [Output Only] The status of the public delegated prefix, which can be one of following values: - `INITIALIZING` The public delegated prefix is being initialized and addresses cannot be created yet. - `READY_TO_ANNOUNCE` The public delegated prefix is a live migration prefix and is active. - `ANNOUNCED` The public delegated prefix is active. - `DELETING` The public delegated prefix is being deprovsioned. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // The public delegated prefix is active. + ANNOUNCED = 365103355; + + // The public delegated prefix is being deprovsioned. + DELETING = 528602024; + + // The public delegated prefix is being initialized and addresses cannot be created yet. + INITIALIZING = 306588749; + + // The public delegated prefix is currently withdrawn but ready to be announced. + READY_TO_ANNOUNCE = 64641265; + + } + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a new PublicDelegatedPrefix. An up-to-date fingerprint must be provided in order to update the PublicDelegatedPrefix, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve a PublicDelegatedPrefix. + optional string fingerprint = 234678500; + + // [Output Only] The unique identifier for the resource type. The server generates this identifier. + optional uint64 id = 3355; + + // The IPv4 address range, in CIDR format, represented by this public delegated prefix. + optional string ip_cidr_range = 98117322; + + // If true, the prefix will be live migrated. + optional bool is_live_migration = 511823856; + + // [Output Only] Type of the resource. Always compute#publicDelegatedPrefix for public delegated prefixes. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // The URL of parent prefix. Either PublicAdvertisedPrefix or PublicDelegatedPrefix. + optional string parent_prefix = 15233991; + + // The list of sub public delegated prefixes that exist for this public delegated prefix. + repeated PublicDelegatedPrefixPublicDelegatedSubPrefix public_delegated_sub_prefixs = 188940044; + + // [Output Only] URL of the region where the public delegated prefix resides. This field applies only to the region resource. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] The status of the public delegated prefix, which can be one of following values: - `INITIALIZING` The public delegated prefix is being initialized and addresses cannot be created yet. - `READY_TO_ANNOUNCE` The public delegated prefix is a live migration prefix and is active. - `ANNOUNCED` The public delegated prefix is active. - `DELETING` The public delegated prefix is being deprovsioned. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + +} + +// +message PublicDelegatedPrefixAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of PublicDelegatedPrefixesScopedList resources. + map items = 100526016; + + // [Output Only] Type of the resource. Always compute#publicDelegatedPrefixAggregatedList for aggregated lists of public delegated prefixes. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message PublicDelegatedPrefixList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of PublicDelegatedPrefix resources. + repeated PublicDelegatedPrefix items = 100526016; + + // [Output Only] Type of the resource. Always compute#publicDelegatedPrefixList for public delegated prefixes. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Represents a sub PublicDelegatedPrefix. +message PublicDelegatedPrefixPublicDelegatedSubPrefix { + // [Output Only] The status of the sub public delegated prefix. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + ACTIVE = 314733318; + + INACTIVE = 270421099; + + } + + // Name of the project scoping this PublicDelegatedSubPrefix. + optional string delegatee_project = 414860634; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // The IPv4 address range, in CIDR format, represented by this sub public delegated prefix. + optional string ip_cidr_range = 98117322; + + // Whether the sub prefix is delegated to create Address resources in the delegatee project. + optional bool is_address = 352617951; + + // The name of the sub public delegated prefix. + optional string name = 3373707; + + // [Output Only] The region of the sub public delegated prefix if it is regional. If absent, the sub prefix is global. + optional string region = 138946292; + + // [Output Only] The status of the sub public delegated prefix. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + +} + +// +message PublicDelegatedPrefixesScopedList { + // [Output Only] A list of PublicDelegatedPrefixes contained in this scope. + repeated PublicDelegatedPrefix public_delegated_prefixes = 315261206; + + // [Output Only] Informational warning which replaces the list of public delegated prefixes when the list is empty. + optional Warning warning = 50704284; + +} + +// A quotas entry. +message Quota { + // [Output Only] Name of the quota metric. + enum Metric { + // A value indicating that the enum field is not set. + UNDEFINED_METRIC = 0; + + A2_CPUS = 153206585; + + AFFINITY_GROUPS = 108303563; + + AUTOSCALERS = 471248988; + + BACKEND_BUCKETS = 137626846; + + BACKEND_SERVICES = 269623753; + + C2D_CPUS = 508182517; + + C2_CPUS = 317601211; + + C3_CPUS = 346230362; + + COMMITMENTS = 456141790; + + COMMITTED_A2_CPUS = 59330902; + + COMMITTED_C2D_CPUS = 282390904; + + COMMITTED_C2_CPUS = 223725528; + + COMMITTED_C3_CPUS = 252354679; + + COMMITTED_CPUS = 292394702; + + COMMITTED_E2_CPUS = 388120154; + + COMMITTED_LICENSES = 357606869; + + COMMITTED_LOCAL_SSD_TOTAL_GB = 308393480; + + COMMITTED_M3_CPUS = 585985; + + COMMITTED_MEMORY_OPTIMIZED_CPUS = 489057886; + + COMMITTED_N2A_CPUS = 40064304; + + COMMITTED_N2D_CPUS = 125951757; + + COMMITTED_N2_CPUS = 322589603; + + COMMITTED_NVIDIA_A100_80GB_GPUS = 464326565; + + COMMITTED_NVIDIA_A100_GPUS = 375799445; + + COMMITTED_NVIDIA_K80_GPUS = 3857188; + + COMMITTED_NVIDIA_P100_GPUS = 107528100; + + COMMITTED_NVIDIA_P4_GPUS = 347952897; + + COMMITTED_NVIDIA_T4_GPUS = 139871237; + + COMMITTED_NVIDIA_V100_GPUS = 219562; + + COMMITTED_T2A_CPUS = 296378986; + + COMMITTED_T2D_CPUS = 382266439; + + // Guest CPUs + CPUS = 2075595; + + CPUS_ALL_REGIONS = 470911149; + + DISKS_TOTAL_GB = 353520543; + + E2_CPUS = 481995837; + + EXTERNAL_MANAGED_FORWARDING_RULES = 150790089; + + EXTERNAL_NETWORK_LB_FORWARDING_RULES = 374298265; + + EXTERNAL_PROTOCOL_FORWARDING_RULES = 63478888; + + EXTERNAL_VPN_GATEWAYS = 272457134; + + FIREWALLS = 374485843; + + FORWARDING_RULES = 432668949; + + GLOBAL_EXTERNAL_MANAGED_BACKEND_SERVICES = 164566753; + + GLOBAL_EXTERNAL_MANAGED_FORWARDING_RULES = 327611949; + + GLOBAL_EXTERNAL_PROXY_LB_BACKEND_SERVICES = 400256169; + + GLOBAL_INTERNAL_ADDRESSES = 42738332; + + GLOBAL_INTERNAL_MANAGED_BACKEND_SERVICES = 256608303; + + GLOBAL_INTERNAL_TRAFFIC_DIRECTOR_BACKEND_SERVICES = 323514196; + + GPUS_ALL_REGIONS = 39387177; + + HEALTH_CHECKS = 289347502; + + IMAGES = 15562360; + + INSTANCES = 131337822; + + INSTANCE_GROUPS = 355919038; + + INSTANCE_GROUP_MANAGERS = 101798192; + + INSTANCE_TEMPLATES = 226188271; + + INTERCONNECTS = 415204741; + + INTERCONNECT_ATTACHMENTS_PER_REGION = 159968086; + + INTERCONNECT_ATTACHMENTS_TOTAL_MBPS = 425090419; + + INTERCONNECT_TOTAL_GBPS = 285341866; + + INTERNAL_ADDRESSES = 197899392; + + INTERNAL_TRAFFIC_DIRECTOR_FORWARDING_RULES = 266433668; + + IN_PLACE_SNAPSHOTS = 151359133; + + IN_USE_ADDRESSES = 402125072; + + IN_USE_BACKUP_SCHEDULES = 32786705; + + IN_USE_SNAPSHOT_SCHEDULES = 462104083; + + LOCAL_SSD_TOTAL_GB = 330878021; + + M1_CPUS = 37203366; + + M2_CPUS = 65832517; + + M3_CPUS = 94461668; + + MACHINE_IMAGES = 446986640; + + N2A_CPUS = 265855917; + + N2D_CPUS = 351743370; + + N2_CPUS = 416465286; + + NETWORKS = 485481477; + + NETWORK_ATTACHMENTS = 149028575; + + NETWORK_ENDPOINT_GROUPS = 102144909; + + NETWORK_FIREWALL_POLICIES = 101117374; + + NODE_GROUPS = 24624817; + + NODE_TEMPLATES = 474896668; + + NVIDIA_A100_80GB_GPUS = 286389320; + + NVIDIA_A100_GPUS = 504872978; + + NVIDIA_K80_GPUS = 163886599; + + NVIDIA_P100_GPUS = 236601633; + + NVIDIA_P100_VWS_GPUS = 213970574; + + NVIDIA_P4_GPUS = 283841470; + + NVIDIA_P4_VWS_GPUS = 528296619; + + NVIDIA_T4_GPUS = 75759810; + + NVIDIA_T4_VWS_GPUS = 319813039; + + NVIDIA_V100_GPUS = 129293095; + + PACKET_MIRRORINGS = 15578407; + + PD_EXTREME_TOTAL_PROVISIONED_IOPS = 69593965; + + PREEMPTIBLE_CPUS = 251184841; + + PREEMPTIBLE_LOCAL_SSD_GB = 260819336; + + PREEMPTIBLE_NVIDIA_A100_80GB_GPUS = 151942410; + + PREEMPTIBLE_NVIDIA_A100_GPUS = 68832784; + + PREEMPTIBLE_NVIDIA_K80_GPUS = 374960201; + + PREEMPTIBLE_NVIDIA_P100_GPUS = 337432351; + + PREEMPTIBLE_NVIDIA_P100_VWS_GPUS = 313544076; + + PREEMPTIBLE_NVIDIA_P4_GPUS = 429197628; + + PREEMPTIBLE_NVIDIA_P4_VWS_GPUS = 252981545; + + PREEMPTIBLE_NVIDIA_T4_GPUS = 221115968; + + PREEMPTIBLE_NVIDIA_T4_VWS_GPUS = 44497965; + + PREEMPTIBLE_NVIDIA_V100_GPUS = 230123813; + + PSC_ILB_CONSUMER_FORWARDING_RULES_PER_PRODUCER_NETWORK = 231164291; + + PSC_INTERNAL_LB_FORWARDING_RULES = 169005435; + + PUBLIC_ADVERTISED_PREFIXES = 471371980; + + PUBLIC_DELEGATED_PREFIXES = 532465974; + + REGIONAL_AUTOSCALERS = 29363772; + + REGIONAL_EXTERNAL_MANAGED_BACKEND_SERVICES = 4240989; + + REGIONAL_EXTERNAL_NETWORK_LB_BACKEND_SERVICES = 409564525; + + REGIONAL_INSTANCE_GROUP_MANAGERS = 37543696; + + REGIONAL_INTERNAL_LB_BACKEND_SERVICES = 137983760; + + REGIONAL_INTERNAL_MANAGED_BACKEND_SERVICES = 96282539; + + RESERVATIONS = 32644647; + + RESOURCE_POLICIES = 83955297; + + ROUTERS = 493018666; + + ROUTES = 275680074; + + SECURITY_POLICIES = 189518703; + + SECURITY_POLICIES_PER_REGION = 249041734; + + SECURITY_POLICY_CEVAL_RULES = 470815689; + + SECURITY_POLICY_RULES = 203549225; + + SECURITY_POLICY_RULES_PER_REGION = 126510156; + + SERVICE_ATTACHMENTS = 471521510; + + // The total number of snapshots allowed for a single project. + SNAPSHOTS = 343405327; + + SSD_TOTAL_GB = 161732561; + + SSL_CERTIFICATES = 378372399; + + STATIC_ADDRESSES = 93624049; + + STATIC_BYOIP_ADDRESSES = 275809649; + + STATIC_EXTERNAL_IPV6_ADDRESS_RANGES = 472346774; + + SUBNETWORKS = 421330469; + + T2A_CPUS = 522170599; + + T2D_CPUS = 71187140; + + TARGET_HTTPS_PROXIES = 219522506; + + TARGET_HTTP_PROXIES = 164117155; + + TARGET_INSTANCES = 284519728; + + TARGET_POOLS = 348261257; + + TARGET_SSL_PROXIES = 159216235; + + TARGET_TCP_PROXIES = 182243136; + + TARGET_VPN_GATEWAYS = 75029928; + + URL_MAPS = 378660743; + + VPN_GATEWAYS = 35620282; + + VPN_TUNNELS = 104327296; + + XPN_SERVICE_PROJECTS = 95191981; + + } + + // [Output Only] Quota limit for this metric. + optional double limit = 102976443; + + // [Output Only] Name of the quota metric. + // Check the Metric enum for the list of possible values. + optional string metric = 533067184; + + // [Output Only] Owning resource. This is the resource on which this quota is applied. + optional string owner = 106164915; + + // [Output Only] Current usage of this metric. + optional double usage = 111574433; + +} + +// Additional details for quota exceeded error for resource quota. +message QuotaExceededInfo { + // The map holding related quota dimensions. + map dimensions = 414334925; + + // Current effective quota limit. The limit's unit depends on the quota type or metric. + optional double limit = 102976443; + + // The name of the quota limit. + optional string limit_name = 398197903; + + // The Compute Engine quota metric name. + optional string metric_name = 409881530; + +} + +// The parameters of the raw disk image. +message RawDisk { + // The format used to encode and transmit the block device, which should be TAR. This is just a container and transmission format and not a runtime format. Provided by the client when the disk image is created. + enum ContainerType { + // A value indicating that the enum field is not set. + UNDEFINED_CONTAINER_TYPE = 0; + + TAR = 82821; + + } + + // The format used to encode and transmit the block device, which should be TAR. This is just a container and transmission format and not a runtime format. Provided by the client when the disk image is created. + // Check the ContainerType enum for the list of possible values. + optional string container_type = 318809144; + + // [Deprecated] This field is deprecated. An optional SHA1 checksum of the disk image before unpackaging provided by the client when the disk image is created. + optional string sha1_checksum = 314444349; + + // The full Google Cloud Storage URL where the raw disk image archive is stored. The following are valid formats for the URL: - https://storage.googleapis.com/bucket_name/image_archive_name - https://storage.googleapis.com/bucket_name/folder_name/ image_archive_name In order to create an image, you must provide the full or partial URL of one of the following: - The rawDisk.source URL - The sourceDisk URL - The sourceImage URL - The sourceSnapshot URL + optional string source = 177235995; + +} + +// A request message for InstanceGroupManagers.RecreateInstances. See the method description for details. +message RecreateInstancesInstanceGroupManagerRequest { + // The name of the managed instance group. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstanceGroupManagersRecreateInstancesRequest instance_group_managers_recreate_instances_request_resource = 21405952 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where the managed instance group is located. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for RegionInstanceGroupManagers.RecreateInstances. See the method description for details. +message RecreateInstancesRegionInstanceGroupManagerRequest { + // Name of the managed instance group. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionInstanceGroupManagersRecreateRequest region_instance_group_managers_recreate_request_resource = 170999316 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// Represents a reference to a resource. +message Reference { + // [Output Only] Type of the resource. Always compute#reference for references. + optional string kind = 3292052; + + // A description of the reference type with no implied semantics. Possible values include: 1. MEMBER_OF + optional string reference_type = 247521198; + + // URL of the resource which refers to the target. + optional string referrer = 351173663; + + // URL of the resource to which this reference points. + optional string target = 192835985; + +} + +// Represents a Region resource. A region is a geographical area where a resource is located. For more information, read Regions and Zones. +message Region { + // [Output Only] Status of the region, either UP or DOWN. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + DOWN = 2104482; + + UP = 2715; + + } + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // [Output Only] The deprecation status associated with this region. + optional DeprecationStatus deprecated = 515138995; + + // [Output Only] Textual description of the resource. + optional string description = 422937596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#region for regions. + optional string kind = 3292052; + + // [Output Only] Name of the resource. + optional string name = 3373707; + + // [Output Only] Quotas assigned to this region. + repeated Quota quotas = 125341947; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] Status of the region, either UP or DOWN. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // [Output Only] Reserved for future use. + optional bool supports_pzs = 83983214; + + // [Output Only] A list of zones available in this region, in the form of resource URLs. + repeated string zones = 116085319; + +} + +// Contains a list of autoscalers. +message RegionAutoscalerList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Autoscaler resources. + repeated Autoscaler items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message RegionDiskTypeList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of DiskType resources. + repeated DiskType items = 100526016; + + // [Output Only] Type of resource. Always compute#regionDiskTypeList for region disk types. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message RegionDisksAddResourcePoliciesRequest { + // Resource policies to be added to this disk. + repeated string resource_policies = 22220385; + +} + +// +message RegionDisksRemoveResourcePoliciesRequest { + // Resource policies to be removed from this disk. + repeated string resource_policies = 22220385; + +} + +// +message RegionDisksResizeRequest { + // The new size of the regional persistent disk, which is specified in GB. + optional int64 size_gb = 494929369; + +} + +// Contains a list of InstanceGroup resources. +message RegionInstanceGroupList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of InstanceGroup resources. + repeated InstanceGroup items = 100526016; + + // The resource type. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// RegionInstanceGroupManagers.deletePerInstanceConfigs +message RegionInstanceGroupManagerDeleteInstanceConfigReq { + // The list of instance names for which we want to delete per-instance configs on this managed instance group. + repeated string names = 104585032; + +} + +// Contains a list of managed instance groups. +message RegionInstanceGroupManagerList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of InstanceGroupManager resources. + repeated InstanceGroupManager items = 100526016; + + // [Output Only] The resource type, which is always compute#instanceGroupManagerList for a list of managed instance groups that exist in th regional scope. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// RegionInstanceGroupManagers.patchPerInstanceConfigs +message RegionInstanceGroupManagerPatchInstanceConfigReq { + // The list of per-instance configurations to insert or patch on this managed instance group. + repeated PerInstanceConfig per_instance_configs = 526265001; + +} + +// RegionInstanceGroupManagers.updatePerInstanceConfigs +message RegionInstanceGroupManagerUpdateInstanceConfigReq { + // The list of per-instance configurations to insert or patch on this managed instance group. + repeated PerInstanceConfig per_instance_configs = 526265001; + +} + +// +message RegionInstanceGroupManagersAbandonInstancesRequest { + // The URLs of one or more instances to abandon. This can be a full URL or a partial URL, such as zones/[ZONE]/instances/[INSTANCE_NAME]. + repeated string instances = 29097598; + +} + +// RegionInstanceGroupManagers.applyUpdatesToInstances +message RegionInstanceGroupManagersApplyUpdatesRequest { + // The minimal action that you want to perform on each instance during the update: - REPLACE: At minimum, delete the instance and create it again. - RESTART: Stop the instance and start it again. - REFRESH: Do not stop the instance. - NONE: Do not disrupt the instance at all. By default, the minimum action is NONE. If your update requires a more disruptive action than you set with this flag, the necessary action is performed to execute the update. + // Additional supported values which may be not listed in the enum directly due to technical reasons: + // NONE + // REFRESH + // REPLACE + // RESTART + enum MinimalAction { + // A value indicating that the enum field is not set. + UNDEFINED_MINIMAL_ACTION = 0; + + } + + // The most disruptive action that you want to perform on each instance during the update: - REPLACE: Delete the instance and create it again. - RESTART: Stop the instance and start it again. - REFRESH: Do not stop the instance. - NONE: Do not disrupt the instance at all. By default, the most disruptive allowed action is REPLACE. If your update requires a more disruptive action than you set with this flag, the update request will fail. + // Additional supported values which may be not listed in the enum directly due to technical reasons: + // NONE + // REFRESH + // REPLACE + // RESTART + enum MostDisruptiveAllowedAction { + // A value indicating that the enum field is not set. + UNDEFINED_MOST_DISRUPTIVE_ALLOWED_ACTION = 0; + + } + + // Flag to update all instances instead of specified list of “instances”. If the flag is set to true then the instances may not be specified in the request. + optional bool all_instances = 403676512; + + // The list of URLs of one or more instances for which you want to apply updates. Each URL can be a full URL or a partial URL, such as zones/[ZONE]/instances/[INSTANCE_NAME]. + repeated string instances = 29097598; + + // The minimal action that you want to perform on each instance during the update: - REPLACE: At minimum, delete the instance and create it again. - RESTART: Stop the instance and start it again. - REFRESH: Do not stop the instance. - NONE: Do not disrupt the instance at all. By default, the minimum action is NONE. If your update requires a more disruptive action than you set with this flag, the necessary action is performed to execute the update. + // Check the MinimalAction enum for the list of possible values. + optional string minimal_action = 270567060; + + // The most disruptive action that you want to perform on each instance during the update: - REPLACE: Delete the instance and create it again. - RESTART: Stop the instance and start it again. - REFRESH: Do not stop the instance. - NONE: Do not disrupt the instance at all. By default, the most disruptive allowed action is REPLACE. If your update requires a more disruptive action than you set with this flag, the update request will fail. + // Check the MostDisruptiveAllowedAction enum for the list of possible values. + optional string most_disruptive_allowed_action = 66103053; + +} + +// RegionInstanceGroupManagers.createInstances +message RegionInstanceGroupManagersCreateInstancesRequest { + // [Required] List of specifications of per-instance configs. + repeated PerInstanceConfig instances = 29097598; + +} + +// +message RegionInstanceGroupManagersDeleteInstancesRequest { + // The URLs of one or more instances to delete. This can be a full URL or a partial URL, such as zones/[ZONE]/instances/[INSTANCE_NAME]. + repeated string instances = 29097598; + + // Specifies whether the request should proceed despite the inclusion of instances that are not members of the group or that are already in the process of being deleted or abandoned. If this field is set to `false` and such an instance is specified in the request, the operation fails. The operation always fails if the request contains a malformed instance URL or a reference to an instance that exists in a zone or region other than the group's zone or region. + optional bool skip_instances_on_validation_error = 40631073; + +} + +// +message RegionInstanceGroupManagersListErrorsResponse { + // [Output Only] The list of errors of the managed instance group. + repeated InstanceManagedByIgmError items = 100526016; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + +} + +// +message RegionInstanceGroupManagersListInstanceConfigsResp { + // [Output Only] The list of PerInstanceConfig. + repeated PerInstanceConfig items = 100526016; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message RegionInstanceGroupManagersListInstancesResponse { + // A list of managed instances. + repeated ManagedInstance managed_instances = 336219614; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + +} + +// +message RegionInstanceGroupManagersRecreateRequest { + // The URLs of one or more instances to recreate. This can be a full URL or a partial URL, such as zones/[ZONE]/instances/[INSTANCE_NAME]. + repeated string instances = 29097598; + +} + +// +message RegionInstanceGroupManagersSetTargetPoolsRequest { + // Fingerprint of the target pools information, which is a hash of the contents. This field is used for optimistic locking when you update the target pool entries. This field is optional. + optional string fingerprint = 234678500; + + // The URL of all TargetPool resources to which instances in the instanceGroup field are added. The target pools automatically apply to all of the instances in the managed instance group. + repeated string target_pools = 336072617; + +} + +// +message RegionInstanceGroupManagersSetTemplateRequest { + // URL of the InstanceTemplate resource from which all new instances will be created. + optional string instance_template = 309248228; + +} + +// +message RegionInstanceGroupsListInstances { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of InstanceWithNamedPorts resources. + repeated InstanceWithNamedPorts items = 100526016; + + // The resource type. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message RegionInstanceGroupsListInstancesRequest { + // Instances in which state should be returned. Valid options are: 'ALL', 'RUNNING'. By default, it lists all instances. + enum InstanceState { + // A value indicating that the enum field is not set. + UNDEFINED_INSTANCE_STATE = 0; + + // Matches any status of the instances, running, non-running and others. + ALL = 64897; + + // Instance is in RUNNING state if it is running. + RUNNING = 121282975; + + } + + // Instances in which state should be returned. Valid options are: 'ALL', 'RUNNING'. By default, it lists all instances. + // Check the InstanceState enum for the list of possible values. + optional string instance_state = 92223591; + + // Name of port user is interested in. It is optional. If it is set, only information about this ports will be returned. If it is not set, all the named ports will be returned. Always lists all instances. + optional string port_name = 41534345; + +} + +// +message RegionInstanceGroupsSetNamedPortsRequest { + // The fingerprint of the named ports information for this instance group. Use this optional property to prevent conflicts when multiple users change the named ports settings concurrently. Obtain the fingerprint with the instanceGroups.get method. Then, include the fingerprint in your request to ensure that you do not overwrite changes that were applied from another concurrent request. + optional string fingerprint = 234678500; + + // The list of named ports to set for this instance group. + repeated NamedPort named_ports = 427598732; + +} + +// Contains a list of region resources. +message RegionList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Region resources. + repeated Region items = 100526016; + + // [Output Only] Type of resource. Always compute#regionList for lists of regions. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse { + // Effective firewalls from firewall policy. + repeated RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponseEffectiveFirewallPolicy firewall_policys = 410985794; + + // Effective firewalls on the network. + repeated Firewall firewalls = 272245619; + +} + +// +message RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponseEffectiveFirewallPolicy { + // [Output Only] The type of the firewall policy. Can be one of HIERARCHY, NETWORK, NETWORK_REGIONAL. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + HIERARCHY = 69902869; + + NETWORK = 413984270; + + NETWORK_REGIONAL = 190804272; + + UNSPECIFIED = 526786327; + + } + + // [Output Only] The display name of the firewall policy. + optional string display_name = 4473832; + + // [Output Only] The name of the firewall policy. + optional string name = 3373707; + + // The rules that apply to the network. + repeated FirewallPolicyRule rules = 108873975; + + // [Output Only] The type of the firewall policy. Can be one of HIERARCHY, NETWORK, NETWORK_REGIONAL. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// +message RegionSetLabelsRequest { + // The fingerprint of the previous set of labels for this resource, used to detect conflicts. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update labels. You must always provide an up-to-date fingerprint hash in order to update or change labels. Make a get() request to the resource to get the latest fingerprint. + optional string label_fingerprint = 178124825; + + // The labels to set for this resource. + map labels = 500195327; + +} + +// +message RegionSetPolicyRequest { + // Flatten Policy to create a backwacd compatible wire-format. Deprecated. Use 'policy' to specify bindings. + repeated Binding bindings = 403251854; + + // Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify the etag. + optional string etag = 3123477; + + // REQUIRED: The complete policy to be applied to the 'resource'. The size of the policy is limited to a few 10s of KB. An empty policy is in general a valid policy but certain services (like Projects) might reject them. + optional Policy policy = 91071794; + +} + +// +message RegionTargetHttpsProxiesSetSslCertificatesRequest { + // New set of SslCertificate resources to associate with this TargetHttpsProxy resource. + repeated string ssl_certificates = 366006543; + +} + +// +message RegionUrlMapsValidateRequest { + // Content of the UrlMap to be validated. + optional UrlMap resource = 195806222; + +} + +// A request message for FirewallPolicies.RemoveAssociation. See the method description for details. +message RemoveAssociationFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // Name for the attachment that will be removed. + optional string name = 3373707; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for NetworkFirewallPolicies.RemoveAssociation. See the method description for details. +message RemoveAssociationNetworkFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // Name for the attachment that will be removed. + optional string name = 3373707; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionNetworkFirewallPolicies.RemoveAssociation. See the method description for details. +message RemoveAssociationRegionNetworkFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // Name for the association that will be removed. + optional string name = 3373707; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for TargetPools.RemoveHealthCheck. See the method description for details. +message RemoveHealthCheckTargetPoolRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the target pool to remove health checks from. + string target_pool = 62796298 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TargetPoolsRemoveHealthCheckRequest target_pools_remove_health_check_request_resource = 304985011 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetPools.RemoveInstance. See the method description for details. +message RemoveInstanceTargetPoolRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetPool resource to remove instances from. + string target_pool = 62796298 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TargetPoolsRemoveInstanceRequest target_pools_remove_instance_request_resource = 29548547 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InstanceGroups.RemoveInstances. See the method description for details. +message RemoveInstancesInstanceGroupRequest { + // The name of the instance group where the specified instances will be removed. + string instance_group = 81095253 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstanceGroupsRemoveInstancesRequest instance_groups_remove_instances_request_resource = 390981817 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where the instance group is located. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Networks.RemovePeering. See the method description for details. +message RemovePeeringNetworkRequest { + // Name of the network resource to remove peering from. + string network = 232872494 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + NetworksRemovePeeringRequest networks_remove_peering_request_resource = 421162494 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Disks.RemoveResourcePolicies. See the method description for details. +message RemoveResourcePoliciesDiskRequest { + // The disk name for this request. + string disk = 3083677 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + DisksRemoveResourcePoliciesRequest disks_remove_resource_policies_request_resource = 436756718 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Instances.RemoveResourcePolicies. See the method description for details. +message RemoveResourcePoliciesInstanceRequest { + // The instance name for this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstancesRemoveResourcePoliciesRequest instances_remove_resource_policies_request_resource = 49229558 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for RegionDisks.RemoveResourcePolicies. See the method description for details. +message RemoveResourcePoliciesRegionDiskRequest { + // The disk name for this request. + string disk = 3083677 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionDisksRemoveResourcePoliciesRequest region_disks_remove_resource_policies_request_resource = 8741283 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for FirewallPolicies.RemoveRule. See the method description for details. +message RemoveRuleFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The priority of the rule to remove from the firewall policy. + optional int32 priority = 445151652; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for NetworkFirewallPolicies.RemoveRule. See the method description for details. +message RemoveRuleNetworkFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The priority of the rule to remove from the firewall policy. + optional int32 priority = 445151652; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionNetworkFirewallPolicies.RemoveRule. See the method description for details. +message RemoveRuleRegionNetworkFirewallPolicyRequest { + // Name of the firewall policy to update. + string firewall_policy = 498173265 [(google.api.field_behavior) = REQUIRED]; + + // The priority of the rule to remove from the firewall policy. + optional int32 priority = 445151652; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for SecurityPolicies.RemoveRule. See the method description for details. +message RemoveRuleSecurityPolicyRequest { + // The priority of the rule to remove from the security policy. + optional int32 priority = 445151652; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the security policy to update. + string security_policy = 171082513 [(google.api.field_behavior) = REQUIRED]; + +} + +// A policy that specifies how requests intended for the route's backends are shadowed to a separate mirrored backend service. The load balancer doesn't wait for responses from the shadow service. Before sending traffic to the shadow service, the host or authority header is suffixed with -shadow. +message RequestMirrorPolicy { + // The full or partial URL to the BackendService resource being mirrored to. The backend service configured for a mirroring policy must reference backends that are of the same type as the original backend service matched in the URL map. Serverless NEG backends are not currently supported as a mirrored backend service. + optional string backend_service = 306946058; + +} + +// Represents a reservation resource. A reservation ensures that capacity is held in a specific zone even if the reserved VMs are not running. For more information, read Reserving zonal resources. +message Reservation { + // [Output Only] The status of the reservation. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // Resources are being allocated for the reservation. + CREATING = 455564985; + + // Reservation is currently being deleted. + DELETING = 528602024; + + INVALID = 530283991; + + // Reservation has allocated all its resources. + READY = 77848963; + + // Reservation is currently being resized. + UPDATING = 494614342; + + } + + // [Output Only] Full or partial URL to a parent commitment. This field displays for reservations that are tied to a commitment. + optional string commitment = 482134805; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#reservations for reservations. + optional string kind = 3292052; + + // The name of the resource, provided by the client when initially creating the resource. The resource name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // Resource policies to be added to this reservation. The key is defined by user, and the value is resource policy url. This is to define placement policy with reservation. + map resource_policies = 22220385; + + // [Output Only] Status information for Reservation resource. + optional AllocationResourceStatus resource_status = 249429315; + + // [Output Only] Reserved for future use. + optional bool satisfies_pzs = 480964267; + + // [Output Only] Server-defined fully-qualified URL for this resource. + optional string self_link = 456214797; + + // Specify share-settings to create a shared reservation. This property is optional. For more information about the syntax and options for this field and its subfields, see the guide for creating a shared reservation. + optional ShareSettings share_settings = 266668163; + + // Reservation for instances with specific machine shapes. + optional AllocationSpecificSKUReservation specific_reservation = 404901951; + + // Indicates whether the reservation can be consumed by VMs with affinity for "any" reservation. If the field is set, then only VMs that target the reservation by name can consume from this reservation. + optional bool specific_reservation_required = 226550687; + + // [Output Only] The status of the reservation. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // Zone in which the reservation resides. A zone must be provided if the reservation is created within a commitment. + optional string zone = 3744684; + +} + +// Specifies the reservations that this instance can consume from. +message ReservationAffinity { + // Specifies the type of reservation from which this instance can consume resources: ANY_RESERVATION (default), SPECIFIC_RESERVATION, or NO_RESERVATION. See Consuming reserved instances for examples. + enum ConsumeReservationType { + // A value indicating that the enum field is not set. + UNDEFINED_CONSUME_RESERVATION_TYPE = 0; + + // Consume any allocation available. + ANY_RESERVATION = 200008121; + + // Do not consume from any allocated capacity. + NO_RESERVATION = 169322030; + + // Must consume from a specific reservation. Must specify key value fields for specifying the reservations. + SPECIFIC_RESERVATION = 229889055; + + UNSPECIFIED = 526786327; + + } + + // Specifies the type of reservation from which this instance can consume resources: ANY_RESERVATION (default), SPECIFIC_RESERVATION, or NO_RESERVATION. See Consuming reserved instances for examples. + // Check the ConsumeReservationType enum for the list of possible values. + optional string consume_reservation_type = 300736944; + + // Corresponds to the label key of a reservation resource. To target a SPECIFIC_RESERVATION by name, specify googleapis.com/reservation-name as the key and specify the name of your reservation as its value. + optional string key = 106079; + + // Corresponds to the label values of a reservation resource. This can be either a name to a reservation in the same project or "projects/different-project/reservations/some-reservation-name" to target a shared reservation in the same zone but in a different project. + repeated string values = 249928994; + +} + +// Contains a list of reservations. +message ReservationAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Allocation resources. + map items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message ReservationList { + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional string id = 3355; + + // [Output Only] A list of Allocation resources. + repeated Reservation items = 100526016; + + // [Output Only] Type of resource.Always compute#reservationsList for listsof reservations + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message ReservationsResizeRequest { + // Number of allocated resources can be resized with minimum = 1 and maximum = 1000. + optional int64 specific_sku_count = 13890720; + +} + +// +message ReservationsScopedList { + // A list of reservations contained in this scope. + repeated Reservation reservations = 399717927; + + // Informational warning which replaces the list of reservations when the list is empty. + optional Warning warning = 50704284; + +} + +// A request message for Instances.Reset. See the method description for details. +message ResetInstanceRequest { + // Name of the instance scoping this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Disks.Resize. See the method description for details. +message ResizeDiskRequest { + // The name of the persistent disk. + string disk = 3083677 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + DisksResizeRequest disks_resize_request_resource = 78307616 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for InstanceGroupManagers.Resize. See the method description for details. +message ResizeInstanceGroupManagerRequest { + // The name of the managed instance group. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The number of running instances that the managed instance group should maintain at any given time. The group automatically adds or removes instances to maintain the number of instances specified by this parameter. + int32 size = 3530753 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone where the managed instance group is located. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for RegionDisks.Resize. See the method description for details. +message ResizeRegionDiskRequest { + // Name of the regional persistent disk. + string disk = 3083677 [(google.api.field_behavior) = REQUIRED]; + + // The project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionDisksResizeRequest region_disks_resize_request_resource = 446633237 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionInstanceGroupManagers.Resize. See the method description for details. +message ResizeRegionInstanceGroupManagerRequest { + // Name of the managed instance group. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Number of instances that should exist in this instance group manager. + int32 size = 3530753 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Reservations.Resize. See the method description for details. +message ResizeReservationRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the reservation to update. + string reservation = 47530956 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + ReservationsResizeRequest reservations_resize_request_resource = 389262801 [(google.api.field_behavior) = REQUIRED]; + + // Name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// Commitment for a particular resource (a Commitment is composed of one or more of these). +message ResourceCommitment { + // Type of resource for which this commitment applies. Possible values are VCPU, MEMORY, LOCAL_SSD, and ACCELERATOR. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + ACCELERATOR = 429815371; + + LOCAL_SSD = 508934896; + + MEMORY = 123056385; + + UNSPECIFIED = 526786327; + + VCPU = 2628978; + + } + + // Name of the accelerator type resource. Applicable only when the type is ACCELERATOR. + optional string accelerator_type = 138031246; + + // The amount of the resource purchased (in a type-dependent unit, such as bytes). For vCPUs, this can just be an integer. For memory, this must be provided in MB. Memory must be a multiple of 256 MB, with up to 6.5GB of memory per every vCPU. + optional int64 amount = 196759640; + + // Type of resource for which this commitment applies. Possible values are VCPU, MEMORY, LOCAL_SSD, and ACCELERATOR. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// +message ResourceGroupReference { + // A URI referencing one of the instance groups or network endpoint groups listed in the backend service. + optional string group = 98629247; + +} + +// +message ResourcePoliciesScopedList { + // A list of resourcePolicies contained in this scope. + repeated ResourcePolicy resource_policies = 22220385; + + // Informational warning which replaces the list of resourcePolicies when the list is empty. + optional Warning warning = 50704284; + +} + +// Represents a Resource Policy resource. You can use resource policies to schedule actions for some Compute Engine resources. For example, you can use them to schedule persistent disk snapshots. +message ResourcePolicy { + // [Output Only] The status of resource policy creation. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // Resource policy is being created. + CREATING = 455564985; + + // Resource policy is being deleted. + DELETING = 528602024; + + // Resource policy is expired and will not run again. + EXPIRED = 482489093; + + INVALID = 530283991; + + // Resource policy is ready to be used. + READY = 77848963; + + } + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + optional string description = 422937596; + + // Resource policy for instances for placement configuration. + optional ResourcePolicyGroupPlacementPolicy group_placement_policy = 10931596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // Resource policy for scheduling instance operations. + optional ResourcePolicyInstanceSchedulePolicy instance_schedule_policy = 344877104; + + // [Output Only] Type of the resource. Always compute#resource_policies for resource policies. + optional string kind = 3292052; + + // The name of the resource, provided by the client when initially creating the resource. The resource name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + optional string region = 138946292; + + // [Output Only] The system status of the resource policy. + optional ResourcePolicyResourceStatus resource_status = 249429315; + + // [Output Only] Server-defined fully-qualified URL for this resource. + optional string self_link = 456214797; + + // Resource policy for persistent disks for creating snapshots. + optional ResourcePolicySnapshotSchedulePolicy snapshot_schedule_policy = 218131295; + + // [Output Only] The status of resource policy creation. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + +} + +// Contains a list of resourcePolicies. +message ResourcePolicyAggregatedList { + optional string etag = 3123477; + + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of ResourcePolicy resources. + map items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Time window specified for daily operations. +message ResourcePolicyDailyCycle { + // Defines a schedule with units measured in days. The value determines how many days pass between the start of each cycle. + optional int32 days_in_cycle = 369790004; + + // [Output only] A predetermined duration for the window, automatically chosen to be the smallest possible in the given scenario. + optional string duration = 155471252; + + // Start time of the window. This must be in UTC format that resolves to one of 00:00, 04:00, 08:00, 12:00, 16:00, or 20:00. For example, both 13:00-5 and 08:00 are valid. + optional string start_time = 37467274; + +} + +// A GroupPlacementPolicy specifies resource placement configuration. It specifies the failure bucket separation as well as network locality +message ResourcePolicyGroupPlacementPolicy { + // Specifies network collocation + enum Collocation { + // A value indicating that the enum field is not set. + UNDEFINED_COLLOCATION = 0; + + COLLOCATED = 103257554; + + UNSPECIFIED_COLLOCATION = 464308205; + + } + + // The number of availability domains to spread instances across. If two instances are in different availability domain, they are not in the same low latency network. + optional int32 availability_domain_count = 12453432; + + // Specifies network collocation + // Check the Collocation enum for the list of possible values. + optional string collocation = 511156533; + + // Number of VMs in this placement group. Google does not recommend that you use this field unless you use a compact policy and you want your policy to work only if it contains this exact number of VMs. + optional int32 vm_count = 261463431; + +} + +// Time window specified for hourly operations. +message ResourcePolicyHourlyCycle { + // [Output only] Duration of the time window, automatically chosen to be smallest possible in the given scenario. + optional string duration = 155471252; + + // Defines a schedule with units measured in hours. The value determines how many hours pass between the start of each cycle. + optional int32 hours_in_cycle = 526763132; + + // Time within the window to start the operations. It must be in format "HH:MM", where HH : [00-23] and MM : [00-00] GMT. + optional string start_time = 37467274; + +} + +// An InstanceSchedulePolicy specifies when and how frequent certain operations are performed on the instance. +message ResourcePolicyInstanceSchedulePolicy { + // The expiration time of the schedule. The timestamp is an RFC3339 string. + optional string expiration_time = 230299229; + + // The start time of the schedule. The timestamp is an RFC3339 string. + optional string start_time = 37467274; + + // Specifies the time zone to be used in interpreting Schedule.schedule. The value of this field must be a time zone name from the tz database: https://wikipedia.org/wiki/Tz_database. + optional string time_zone = 36848094; + + // Specifies the schedule for starting instances. + optional ResourcePolicyInstanceSchedulePolicySchedule vm_start_schedule = 17762396; + + // Specifies the schedule for stopping instances. + optional ResourcePolicyInstanceSchedulePolicySchedule vm_stop_schedule = 426242732; + +} + +// Schedule for an instance operation. +message ResourcePolicyInstanceSchedulePolicySchedule { + // Specifies the frequency for the operation, using the unix-cron format. + optional string schedule = 375820951; + +} + +// +message ResourcePolicyList { + optional string etag = 3123477; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional string id = 3355; + + // [Output Only] A list of ResourcePolicy resources. + repeated ResourcePolicy items = 100526016; + + // [Output Only] Type of resource.Always compute#resourcePoliciesList for listsof resourcePolicies + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains output only fields. Use this sub-message for all output fields set on ResourcePolicy. The internal structure of this "status" field should mimic the structure of ResourcePolicy proto specification. +message ResourcePolicyResourceStatus { + // [Output Only] Specifies a set of output values reffering to the instance_schedule_policy system status. This field should have the same name as corresponding policy field. + optional ResourcePolicyResourceStatusInstanceSchedulePolicyStatus instance_schedule_policy = 344877104; + +} + +// +message ResourcePolicyResourceStatusInstanceSchedulePolicyStatus { + // [Output Only] The last time the schedule successfully ran. The timestamp is an RFC3339 string. + optional string last_run_start_time = 303069063; + + // [Output Only] The next time the schedule is planned to run. The actual time might be slightly different. The timestamp is an RFC3339 string. + optional string next_run_start_time = 318642570; + +} + +// A snapshot schedule policy specifies when and how frequently snapshots are to be created for the target disk. Also specifies how many and how long these scheduled snapshots should be retained. +message ResourcePolicySnapshotSchedulePolicy { + // Retention policy applied to snapshots created by this resource policy. + optional ResourcePolicySnapshotSchedulePolicyRetentionPolicy retention_policy = 68625779; + + // A Vm Maintenance Policy specifies what kind of infrastructure maintenance we are allowed to perform on this VM and when. Schedule that is applied to disks covered by this policy. + optional ResourcePolicySnapshotSchedulePolicySchedule schedule = 375820951; + + // Properties with which snapshots are created such as labels, encryption keys. + optional ResourcePolicySnapshotSchedulePolicySnapshotProperties snapshot_properties = 185371278; + +} + +// Policy for retention of scheduled snapshots. +message ResourcePolicySnapshotSchedulePolicyRetentionPolicy { + // Specifies the behavior to apply to scheduled snapshots when the source disk is deleted. + enum OnSourceDiskDelete { + // A value indicating that the enum field is not set. + UNDEFINED_ON_SOURCE_DISK_DELETE = 0; + + APPLY_RETENTION_POLICY = 535071332; + + KEEP_AUTO_SNAPSHOTS = 258925689; + + UNSPECIFIED_ON_SOURCE_DISK_DELETE = 239140769; + + } + + // Maximum age of the snapshot that is allowed to be kept. + optional int32 max_retention_days = 324296979; + + // Specifies the behavior to apply to scheduled snapshots when the source disk is deleted. + // Check the OnSourceDiskDelete enum for the list of possible values. + optional string on_source_disk_delete = 321955529; + +} + +// A schedule for disks where the schedueled operations are performed. +message ResourcePolicySnapshotSchedulePolicySchedule { + optional ResourcePolicyDailyCycle daily_schedule = 86159869; + + optional ResourcePolicyHourlyCycle hourly_schedule = 38328485; + + optional ResourcePolicyWeeklyCycle weekly_schedule = 359548053; + +} + +// Specified snapshot properties for scheduled snapshots created by this policy. +message ResourcePolicySnapshotSchedulePolicySnapshotProperties { + // Chain name that the snapshot is created in. + optional string chain_name = 68644169; + + // Indication to perform a 'guest aware' snapshot. + optional bool guest_flush = 385550813; + + // Labels to apply to scheduled snapshots. These can be later modified by the setLabels method. Label values may be empty. + map labels = 500195327; + + // Cloud Storage bucket storage location of the auto snapshot (regional or multi-regional). + repeated string storage_locations = 328005274; + +} + +// Time window specified for weekly operations. +message ResourcePolicyWeeklyCycle { + // Up to 7 intervals/windows, one for each day of the week. + repeated ResourcePolicyWeeklyCycleDayOfWeek day_of_weeks = 257871834; + +} + +// +message ResourcePolicyWeeklyCycleDayOfWeek { + // Defines a schedule that runs on specific days of the week. Specify one or more days. The following options are available: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY. + enum Day { + // A value indicating that the enum field is not set. + UNDEFINED_DAY = 0; + + FRIDAY = 471398751; + + INVALID = 530283991; + + MONDAY = 132310288; + + SATURDAY = 279037881; + + SUNDAY = 309626320; + + THURSDAY = 207198682; + + TUESDAY = 277509677; + + WEDNESDAY = 422029110; + + } + + // Defines a schedule that runs on specific days of the week. Specify one or more days. The following options are available: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY. + // Check the Day enum for the list of possible values. + optional string day = 99228; + + // [Output only] Duration of the time window, automatically chosen to be smallest possible in the given scenario. + optional string duration = 155471252; + + // Time within the window to start the operations. It must be in format "HH:MM", where HH : [00-23] and MM : [00-00] GMT. + optional string start_time = 37467274; + +} + +// Contains output only fields. Use this sub-message for actual values set on Instance attributes as compared to the value requested by the user (intent) in their instance CRUD calls. +message ResourceStatus { + // [Output Only] An opaque ID of the host on which the VM is running. + optional string physical_host = 464370704; + +} + +// A request message for Instances.Resume. See the method description for details. +message ResumeInstanceRequest { + // Name of the instance resource to resume. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// Represents a Route resource. A route defines a path from VM instances in the VPC network to a specific destination. This destination can be inside or outside the VPC network. For more information, read the Routes overview. +message Route { + // [Output only] The status of the route. + enum RouteStatus { + // A value indicating that the enum field is not set. + UNDEFINED_ROUTE_STATUS = 0; + + // This route is processed and active. + ACTIVE = 314733318; + + // The route is dropped due to the VPC exceeding the dynamic route limit. For dynamic route limit, please refer to the Learned route example + DROPPED = 496235424; + + // This route is processed but inactive due to failure from the backend. The backend may have rejected the route + INACTIVE = 270421099; + + // This route is being processed internally. The status will change once processed. + PENDING = 35394935; + + } + + // [Output Only] The type of this route, which can be one of the following values: - 'TRANSIT' for a transit route that this router learned from another Cloud Router and will readvertise to one of its BGP peers - 'SUBNET' for a route from a subnet of the VPC - 'BGP' for a route learned from a BGP peer of this router - 'STATIC' for a static route + enum RouteType { + // A value indicating that the enum field is not set. + UNDEFINED_ROUTE_TYPE = 0; + + BGP = 65707; + + STATIC = 308331118; + + SUBNET = 309278557; + + TRANSIT = 187793843; + + } + + // [Output Only] AS path. + repeated RouteAsPath as_paths = 137568929; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this field when you create the resource. + optional string description = 422937596; + + // The destination range of outgoing packets that this route applies to. Both IPv4 and IPv6 are supported. + optional string dest_range = 381327712; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of this resource. Always compute#routes for Route resources. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`. The first character must be a lowercase letter, and all following characters (except for the last character) must be a dash, lowercase letter, or digit. The last character must be a lowercase letter or digit. + optional string name = 3373707; + + // Fully-qualified URL of the network that this route applies to. + optional string network = 232872494; + + // The URL to a gateway that should handle matching packets. You can only specify the internet gateway using a full or partial valid URL: projects/ project/global/gateways/default-internet-gateway + optional string next_hop_gateway = 377175298; + + // The URL to a forwarding rule of type loadBalancingScheme=INTERNAL that should handle matching packets or the IP address of the forwarding Rule. For example, the following are all valid URLs: - 10.128.0.56 - https://www.googleapis.com/compute/v1/projects/project/regions/region /forwardingRules/forwardingRule - regions/region/forwardingRules/forwardingRule + optional string next_hop_ilb = 198679901; + + // The URL to an instance that should handle matching packets. You can specify this as a full or partial URL. For example: https://www.googleapis.com/compute/v1/projects/project/zones/zone/instances/ + optional string next_hop_instance = 393508247; + + // The network IP address of an instance that should handle matching packets. Only IPv4 is supported. + optional string next_hop_ip = 110319529; + + // The URL of the local network if it should handle matching packets. + optional string next_hop_network = 262295788; + + // [Output Only] The network peering name that should handle matching packets, which should conform to RFC1035. + optional string next_hop_peering = 412682750; + + // The URL to a VpnTunnel that should handle matching packets. + optional string next_hop_vpn_tunnel = 519844501; + + // The priority of this route. Priority is used to break ties in cases where there is more than one matching route of equal prefix length. In cases where multiple routes have equal prefix length, the one with the lowest-numbered priority value wins. The default value is `1000`. The priority value must be from `0` to `65535`, inclusive. + optional uint32 priority = 445151652; + + // [Output only] The status of the route. + // Check the RouteStatus enum for the list of possible values. + optional string route_status = 418162344; + + // [Output Only] The type of this route, which can be one of the following values: - 'TRANSIT' for a transit route that this router learned from another Cloud Router and will readvertise to one of its BGP peers - 'SUBNET' for a route from a subnet of the VPC - 'BGP' for a route learned from a BGP peer of this router - 'STATIC' for a static route + // Check the RouteType enum for the list of possible values. + optional string route_type = 375888752; + + // [Output Only] Server-defined fully-qualified URL for this resource. + optional string self_link = 456214797; + + // A list of instance tags to which this route applies. + repeated string tags = 3552281; + + // [Output Only] If potential misconfigurations are detected for this route, this field will be populated with warning messages. + repeated Warnings warnings = 498091095; + +} + +// +message RouteAsPath { + // [Output Only] The type of the AS Path, which can be one of the following values: - 'AS_SET': unordered set of autonomous systems that the route in has traversed - 'AS_SEQUENCE': ordered set of autonomous systems that the route has traversed - 'AS_CONFED_SEQUENCE': ordered set of Member Autonomous Systems in the local confederation that the route has traversed - 'AS_CONFED_SET': unordered set of Member Autonomous Systems in the local confederation that the route has traversed + enum PathSegmentType { + // A value indicating that the enum field is not set. + UNDEFINED_PATH_SEGMENT_TYPE = 0; + + AS_CONFED_SEQUENCE = 222152624; + + AS_CONFED_SET = 374040307; + + AS_SEQUENCE = 106735918; + + AS_SET = 329846453; + + } + + // [Output Only] The AS numbers of the AS Path. + repeated uint32 as_lists = 134112584; + + // [Output Only] The type of the AS Path, which can be one of the following values: - 'AS_SET': unordered set of autonomous systems that the route in has traversed - 'AS_SEQUENCE': ordered set of autonomous systems that the route has traversed - 'AS_CONFED_SEQUENCE': ordered set of Member Autonomous Systems in the local confederation that the route has traversed - 'AS_CONFED_SET': unordered set of Member Autonomous Systems in the local confederation that the route has traversed + // Check the PathSegmentType enum for the list of possible values. + optional string path_segment_type = 513464992; + +} + +// Contains a list of Route resources. +message RouteList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Route resources. + repeated Route items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Represents a Cloud Router resource. For more information about Cloud Router, read the Cloud Router overview. +message Router { + // BGP information specific to this router. + optional RouterBgp bgp = 97483; + + // BGP information that must be configured into the routing stack to establish BGP peering. This information must specify the peer ASN and either the interface name, IP address, or peer IP address. Please refer to RFC4273. + repeated RouterBgpPeer bgp_peers = 452695773; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Indicates if a router is dedicated for use with encrypted VLAN attachments (interconnectAttachments). + optional bool encrypted_interconnect_router = 297996575; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // Router interfaces. Each interface requires either one linked resource, (for example, linkedVpnTunnel), or IP address and IP address range (for example, ipRange), or both. + repeated RouterInterface interfaces = 12073562; + + // [Output Only] Type of resource. Always compute#router for routers. + optional string kind = 3292052; + + // Keys used for MD5 authentication. + repeated RouterMd5AuthenticationKey md5_authentication_keys = 71063322; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // A list of NAT services created in this router. + repeated RouterNat nats = 3373938; + + // URI of the network to which this router belongs. + optional string network = 232872494; + + // [Output Only] URI of the region where the router resides. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + +} + +// Description-tagged IP ranges for the router to advertise. +message RouterAdvertisedIpRange { + // User-specified description for the IP range. + optional string description = 422937596; + + // The IP range to advertise. The value must be a CIDR-formatted string. + optional string range = 108280125; + +} + +// Contains a list of routers. +message RouterAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Router resources. + map items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message RouterBgp { + // User-specified flag to indicate which mode to use for advertisement. The options are DEFAULT or CUSTOM. + enum AdvertiseMode { + // A value indicating that the enum field is not set. + UNDEFINED_ADVERTISE_MODE = 0; + + CUSTOM = 388595569; + + DEFAULT = 115302945; + + } + + // + enum AdvertisedGroups { + // A value indicating that the enum field is not set. + UNDEFINED_ADVERTISED_GROUPS = 0; + + // Advertise all available subnets (including peer VPC subnets). + ALL_SUBNETS = 3622872; + + } + + // User-specified flag to indicate which mode to use for advertisement. The options are DEFAULT or CUSTOM. + // Check the AdvertiseMode enum for the list of possible values. + optional string advertise_mode = 312134331; + + // User-specified list of prefix groups to advertise in custom mode. This field can only be populated if advertise_mode is CUSTOM and is advertised to all peers of the router. These groups will be advertised in addition to any specified prefixes. Leave this field blank to advertise no custom groups. + // Check the AdvertisedGroups enum for the list of possible values. + repeated string advertised_groups = 21065526; + + // User-specified list of individual IP ranges to advertise in custom mode. This field can only be populated if advertise_mode is CUSTOM and is advertised to all peers of the router. These IP ranges will be advertised in addition to any specified groups. Leave this field blank to advertise no custom IP ranges. + repeated RouterAdvertisedIpRange advertised_ip_ranges = 35449932; + + // Local BGP Autonomous System Number (ASN). Must be an RFC6996 private ASN, either 16-bit or 32-bit. The value will be fixed for this router resource. All VPN tunnels that link to this router will have the same local ASN. + optional uint32 asn = 96892; + + // The interval in seconds between BGP keepalive messages that are sent to the peer. Hold time is three times the interval at which keepalive messages are sent, and the hold time is the maximum number of seconds allowed to elapse between successive keepalive messages that BGP receives from a peer. BGP will use the smaller of either the local hold time value or the peer's hold time value as the hold time for the BGP connection between the two peers. If set, this value must be between 20 and 60. The default is 20. + optional uint32 keepalive_interval = 276771516; + +} + +// +message RouterBgpPeer { + // User-specified flag to indicate which mode to use for advertisement. + enum AdvertiseMode { + // A value indicating that the enum field is not set. + UNDEFINED_ADVERTISE_MODE = 0; + + CUSTOM = 388595569; + + DEFAULT = 115302945; + + } + + // + enum AdvertisedGroups { + // A value indicating that the enum field is not set. + UNDEFINED_ADVERTISED_GROUPS = 0; + + // Advertise all available subnets (including peer VPC subnets). + ALL_SUBNETS = 3622872; + + } + + // The status of the BGP peer connection. If set to FALSE, any active session with the peer is terminated and all associated routing information is removed. If set to TRUE, the peer connection can be established with routing information. The default is TRUE. + enum Enable { + // A value indicating that the enum field is not set. + UNDEFINED_ENABLE = 0; + + FALSE = 66658563; + + TRUE = 2583950; + + } + + // [Output Only] The resource that configures and manages this BGP peer. - MANAGED_BY_USER is the default value and can be managed by you or other users - MANAGED_BY_ATTACHMENT is a BGP peer that is configured and managed by Cloud Interconnect, specifically by an InterconnectAttachment of type PARTNER. Google automatically creates, updates, and deletes this type of BGP peer when the PARTNER InterconnectAttachment is created, updated, or deleted. + enum ManagementType { + // A value indicating that the enum field is not set. + UNDEFINED_MANAGEMENT_TYPE = 0; + + // The BGP peer is automatically created for PARTNER type InterconnectAttachment; Google will automatically create/delete this BGP peer when the PARTNER InterconnectAttachment is created/deleted, and Google will update the ipAddress and peerIpAddress when the PARTNER InterconnectAttachment is provisioned. This type of BGP peer cannot be created or deleted, but can be modified for all fields except for name, ipAddress and peerIpAddress. + MANAGED_BY_ATTACHMENT = 458926411; + + // Default value, the BGP peer is manually created and managed by user. + MANAGED_BY_USER = 317294067; + + } + + // User-specified flag to indicate which mode to use for advertisement. + // Check the AdvertiseMode enum for the list of possible values. + optional string advertise_mode = 312134331; + + // User-specified list of prefix groups to advertise in custom mode, which currently supports the following option: - ALL_SUBNETS: Advertises all of the router's own VPC subnets. This excludes any routes learned for subnets that use VPC Network Peering. Note that this field can only be populated if advertise_mode is CUSTOM and overrides the list defined for the router (in the "bgp" message). These groups are advertised in addition to any specified prefixes. Leave this field blank to advertise no custom groups. + // Check the AdvertisedGroups enum for the list of possible values. + repeated string advertised_groups = 21065526; + + // User-specified list of individual IP ranges to advertise in custom mode. This field can only be populated if advertise_mode is CUSTOM and overrides the list defined for the router (in the "bgp" message). These IP ranges are advertised in addition to any specified groups. Leave this field blank to advertise no custom IP ranges. + repeated RouterAdvertisedIpRange advertised_ip_ranges = 35449932; + + // The priority of routes advertised to this BGP peer. Where there is more than one matching route of maximum length, the routes with the lowest priority value win. + optional uint32 advertised_route_priority = 186486332; + + // BFD configuration for the BGP peering. + optional RouterBgpPeerBfd bfd = 97440; + + // The status of the BGP peer connection. If set to FALSE, any active session with the peer is terminated and all associated routing information is removed. If set to TRUE, the peer connection can be established with routing information. The default is TRUE. + // Check the Enable enum for the list of possible values. + optional string enable = 311764355; + + // Enable IPv6 traffic over BGP Peer. If not specified, it is disabled by default. + optional bool enable_ipv6 = 181467939; + + // Name of the interface the BGP peer is associated with. + optional string interface_name = 437854673; + + // IP address of the interface inside Google Cloud Platform. Only IPv4 is supported. + optional string ip_address = 406272220; + + // IPv6 address of the interface inside Google Cloud Platform. + optional string ipv6_nexthop_address = 27968211; + + // [Output Only] The resource that configures and manages this BGP peer. - MANAGED_BY_USER is the default value and can be managed by you or other users - MANAGED_BY_ATTACHMENT is a BGP peer that is configured and managed by Cloud Interconnect, specifically by an InterconnectAttachment of type PARTNER. Google automatically creates, updates, and deletes this type of BGP peer when the PARTNER InterconnectAttachment is created, updated, or deleted. + // Check the ManagementType enum for the list of possible values. + optional string management_type = 173703606; + + // Present if MD5 authentication is enabled for the peering. Must be the name of one of the entries in the Router.md5_authentication_keys. The field must comply with RFC1035. + optional string md5_authentication_key_name = 281075345; + + // Name of this BGP peer. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // Peer BGP Autonomous System Number (ASN). Each BGP interface may use a different value. + optional uint32 peer_asn = 69573151; + + // IP address of the BGP interface outside Google Cloud Platform. Only IPv4 is supported. + optional string peer_ip_address = 207735769; + + // IPv6 address of the BGP interface outside Google Cloud Platform. + optional string peer_ipv6_nexthop_address = 491486608; + + // URI of the VM instance that is used as third-party router appliances such as Next Gen Firewalls, Virtual Routers, or Router Appliances. The VM instance must be located in zones contained in the same region as this Cloud Router. The VM instance is the peer side of the BGP session. + optional string router_appliance_instance = 468312989; + +} + +// +message RouterBgpPeerBfd { + // The BFD session initialization mode for this BGP peer. If set to ACTIVE, the Cloud Router will initiate the BFD session for this BGP peer. If set to PASSIVE, the Cloud Router will wait for the peer router to initiate the BFD session for this BGP peer. If set to DISABLED, BFD is disabled for this BGP peer. The default is DISABLED. + enum SessionInitializationMode { + // A value indicating that the enum field is not set. + UNDEFINED_SESSION_INITIALIZATION_MODE = 0; + + ACTIVE = 314733318; + + DISABLED = 516696700; + + PASSIVE = 462813959; + + } + + // The minimum interval, in milliseconds, between BFD control packets received from the peer router. The actual value is negotiated between the two routers and is equal to the greater of this value and the transmit interval of the other router. If set, this value must be between 1000 and 30000. The default is 1000. + optional uint32 min_receive_interval = 186981614; + + // The minimum interval, in milliseconds, between BFD control packets transmitted to the peer router. The actual value is negotiated between the two routers and is equal to the greater of this value and the corresponding receive interval of the other router. If set, this value must be between 1000 and 30000. The default is 1000. + optional uint32 min_transmit_interval = 523282631; + + // The number of consecutive BFD packets that must be missed before BFD declares that a peer is unavailable. If set, the value must be a value between 5 and 16. The default is 5. + optional uint32 multiplier = 191331777; + + // The BFD session initialization mode for this BGP peer. If set to ACTIVE, the Cloud Router will initiate the BFD session for this BGP peer. If set to PASSIVE, the Cloud Router will wait for the peer router to initiate the BFD session for this BGP peer. If set to DISABLED, BFD is disabled for this BGP peer. The default is DISABLED. + // Check the SessionInitializationMode enum for the list of possible values. + optional string session_initialization_mode = 105957049; + +} + +// +message RouterInterface { + // [Output Only] The resource that configures and manages this interface. - MANAGED_BY_USER is the default value and can be managed directly by users. - MANAGED_BY_ATTACHMENT is an interface that is configured and managed by Cloud Interconnect, specifically, by an InterconnectAttachment of type PARTNER. Google automatically creates, updates, and deletes this type of interface when the PARTNER InterconnectAttachment is created, updated, or deleted. + enum ManagementType { + // A value indicating that the enum field is not set. + UNDEFINED_MANAGEMENT_TYPE = 0; + + // The interface is automatically created for PARTNER type InterconnectAttachment, Google will automatically create/update/delete this interface when the PARTNER InterconnectAttachment is created/provisioned/deleted. This type of interface cannot be manually managed by user. + MANAGED_BY_ATTACHMENT = 458926411; + + // Default value, the interface is manually created and managed by user. + MANAGED_BY_USER = 317294067; + + } + + // IP address and range of the interface. The IP range must be in the RFC3927 link-local IP address space. The value must be a CIDR-formatted string, for example: 169.254.0.1/30. NOTE: Do not truncate the address as it represents the IP address of the interface. + optional string ip_range = 145092645; + + // URI of the linked Interconnect attachment. It must be in the same region as the router. Each interface can have one linked resource, which can be a VPN tunnel, an Interconnect attachment, or a virtual machine instance. + optional string linked_interconnect_attachment = 501085518; + + // URI of the linked VPN tunnel, which must be in the same region as the router. Each interface can have one linked resource, which can be a VPN tunnel, an Interconnect attachment, or a virtual machine instance. + optional string linked_vpn_tunnel = 352296953; + + // [Output Only] The resource that configures and manages this interface. - MANAGED_BY_USER is the default value and can be managed directly by users. - MANAGED_BY_ATTACHMENT is an interface that is configured and managed by Cloud Interconnect, specifically, by an InterconnectAttachment of type PARTNER. Google automatically creates, updates, and deletes this type of interface when the PARTNER InterconnectAttachment is created, updated, or deleted. + // Check the ManagementType enum for the list of possible values. + optional string management_type = 173703606; + + // Name of this interface entry. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // The regional private internal IP address that is used to establish BGP sessions to a VM instance acting as a third-party Router Appliance, such as a Next Gen Firewall, a Virtual Router, or an SD-WAN VM. + optional string private_ip_address = 100854040; + + // Name of the interface that will be redundant with the current interface you are creating. The redundantInterface must belong to the same Cloud Router as the interface here. To establish the BGP session to a Router Appliance VM, you must create two BGP peers. The two BGP peers must be attached to two separate interfaces that are redundant with each other. The redundant_interface must be 1-63 characters long, and comply with RFC1035. Specifically, the redundant_interface must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string redundant_interface = 523187303; + + // The URI of the subnetwork resource that this interface belongs to, which must be in the same region as the Cloud Router. When you establish a BGP session to a VM instance using this interface, the VM instance must belong to the same subnetwork as the subnetwork specified here. + optional string subnetwork = 307827694; + +} + +// Contains a list of Router resources. +message RouterList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Router resources. + repeated Router items = 100526016; + + // [Output Only] Type of resource. Always compute#router for routers. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message RouterMd5AuthenticationKey { + // [Input only] Value of the key. For patch and update calls, it can be skipped to copy the value from the previous configuration. This is allowed if the key with the same name existed before the operation. Maximum length is 80 characters. Can only contain printable ASCII characters. + optional string key = 106079; + + // Name used to identify the key. Must be unique within a router. Must be referenced by at least one bgpPeer. Must comply with RFC1035. + optional string name = 3373707; + +} + +// Represents a Nat resource. It enables the VMs within the specified subnetworks to access Internet without external IP addresses. It specifies a list of subnetworks (and the ranges within) that want to use NAT. Customers can also provide the external IPs that would be used for NAT. GCP would auto-allocate ephemeral IPs if no external IPs are provided. +message RouterNat { + // + enum EndpointTypes { + // A value indicating that the enum field is not set. + UNDEFINED_ENDPOINT_TYPES = 0; + + // This is used for Secure Web Gateway endpoints. + ENDPOINT_TYPE_SWG = 159344456; + + // This is the default. + ENDPOINT_TYPE_VM = 57095474; + + } + + // Specify the NatIpAllocateOption, which can take one of the following values: - MANUAL_ONLY: Uses only Nat IP addresses provided by customers. When there are not enough specified Nat IPs, the Nat service fails for new VMs. - AUTO_ONLY: Nat IPs are allocated by Google Cloud Platform; customers can't specify any Nat IPs. When choosing AUTO_ONLY, then nat_ip should be empty. + enum NatIpAllocateOption { + // A value indicating that the enum field is not set. + UNDEFINED_NAT_IP_ALLOCATE_OPTION = 0; + + // Nat IPs are allocated by GCP; customers can not specify any Nat IPs. + AUTO_ONLY = 182333500; + + // Only use Nat IPs provided by customers. When specified Nat IPs are not enough then the Nat service fails for new VMs. + MANUAL_ONLY = 261251205; + + } + + // Specify the Nat option, which can take one of the following values: - ALL_SUBNETWORKS_ALL_IP_RANGES: All of the IP ranges in every Subnetwork are allowed to Nat. - ALL_SUBNETWORKS_ALL_PRIMARY_IP_RANGES: All of the primary IP ranges in every Subnetwork are allowed to Nat. - LIST_OF_SUBNETWORKS: A list of Subnetworks are allowed to Nat (specified in the field subnetwork below) The default is SUBNETWORK_IP_RANGE_TO_NAT_OPTION_UNSPECIFIED. Note that if this field contains ALL_SUBNETWORKS_ALL_IP_RANGES or ALL_SUBNETWORKS_ALL_PRIMARY_IP_RANGES, then there should not be any other Router.Nat section in any Router for this network in this region. + enum SourceSubnetworkIpRangesToNat { + // A value indicating that the enum field is not set. + UNDEFINED_SOURCE_SUBNETWORK_IP_RANGES_TO_NAT = 0; + + // All the IP ranges in every Subnetwork are allowed to Nat. + ALL_SUBNETWORKS_ALL_IP_RANGES = 179964376; + + // All the primary IP ranges in every Subnetwork are allowed to Nat. + ALL_SUBNETWORKS_ALL_PRIMARY_IP_RANGES = 185573819; + + // A list of Subnetworks are allowed to Nat (specified in the field subnetwork below) + LIST_OF_SUBNETWORKS = 517542270; + + } + + // A list of URLs of the IP resources to be drained. These IPs must be valid static external IPs that have been assigned to the NAT. These IPs should be used for updating/patching a NAT only. + repeated string drain_nat_ips = 504078535; + + // Enable Dynamic Port Allocation. If not specified, it is disabled by default. If set to true, - Dynamic Port Allocation will be enabled on this NAT config. - enableEndpointIndependentMapping cannot be set to true. - If minPorts is set, minPortsPerVm must be set to a power of two greater than or equal to 32. If minPortsPerVm is not set, a minimum of 32 ports will be allocated to a VM from this NAT config. + optional bool enable_dynamic_port_allocation = 532106402; + + optional bool enable_endpoint_independent_mapping = 259441819; + + // List of NAT-ted endpoint types supported by the Nat Gateway. If the list is empty, then it will be equivalent to include ENDPOINT_TYPE_VM + // Check the EndpointTypes enum for the list of possible values. + repeated string endpoint_types = 502633807; + + // Timeout (in seconds) for ICMP connections. Defaults to 30s if not set. + optional int32 icmp_idle_timeout_sec = 3647562; + + // Configure logging on this NAT. + optional RouterNatLogConfig log_config = 351299741; + + // Maximum number of ports allocated to a VM from this NAT config when Dynamic Port Allocation is enabled. If Dynamic Port Allocation is not enabled, this field has no effect. If Dynamic Port Allocation is enabled, and this field is set, it must be set to a power of two greater than minPortsPerVm, or 64 if minPortsPerVm is not set. If Dynamic Port Allocation is enabled and this field is not set, a maximum of 65536 ports will be allocated to a VM from this NAT config. + optional int32 max_ports_per_vm = 250062049; + + // Minimum number of ports allocated to a VM from this NAT config. If not set, a default number of ports is allocated to a VM. This is rounded up to the nearest power of 2. For example, if the value of this field is 50, at least 64 ports are allocated to a VM. + optional int32 min_ports_per_vm = 186193587; + + // Unique name of this Nat service. The name must be 1-63 characters long and comply with RFC1035. + optional string name = 3373707; + + // Specify the NatIpAllocateOption, which can take one of the following values: - MANUAL_ONLY: Uses only Nat IP addresses provided by customers. When there are not enough specified Nat IPs, the Nat service fails for new VMs. - AUTO_ONLY: Nat IPs are allocated by Google Cloud Platform; customers can't specify any Nat IPs. When choosing AUTO_ONLY, then nat_ip should be empty. + // Check the NatIpAllocateOption enum for the list of possible values. + optional string nat_ip_allocate_option = 429726845; + + // A list of URLs of the IP resources used for this Nat service. These IP addresses must be valid static external IP addresses assigned to the project. + repeated string nat_ips = 117635086; + + // A list of rules associated with this NAT. + repeated RouterNatRule rules = 108873975; + + // Specify the Nat option, which can take one of the following values: - ALL_SUBNETWORKS_ALL_IP_RANGES: All of the IP ranges in every Subnetwork are allowed to Nat. - ALL_SUBNETWORKS_ALL_PRIMARY_IP_RANGES: All of the primary IP ranges in every Subnetwork are allowed to Nat. - LIST_OF_SUBNETWORKS: A list of Subnetworks are allowed to Nat (specified in the field subnetwork below) The default is SUBNETWORK_IP_RANGE_TO_NAT_OPTION_UNSPECIFIED. Note that if this field contains ALL_SUBNETWORKS_ALL_IP_RANGES or ALL_SUBNETWORKS_ALL_PRIMARY_IP_RANGES, then there should not be any other Router.Nat section in any Router for this network in this region. + // Check the SourceSubnetworkIpRangesToNat enum for the list of possible values. + optional string source_subnetwork_ip_ranges_to_nat = 252213211; + + // A list of Subnetwork resources whose traffic should be translated by NAT Gateway. It is used only when LIST_OF_SUBNETWORKS is selected for the SubnetworkIpRangeToNatOption above. + repeated RouterNatSubnetworkToNat subnetworks = 415853125; + + // Timeout (in seconds) for TCP established connections. Defaults to 1200s if not set. + optional int32 tcp_established_idle_timeout_sec = 223098349; + + // Timeout (in seconds) for TCP connections that are in TIME_WAIT state. Defaults to 120s if not set. + optional int32 tcp_time_wait_timeout_sec = 513596925; + + // Timeout (in seconds) for TCP transitory connections. Defaults to 30s if not set. + optional int32 tcp_transitory_idle_timeout_sec = 205028774; + + // Timeout (in seconds) for UDP connections. Defaults to 30s if not set. + optional int32 udp_idle_timeout_sec = 64919878; + +} + +// Configuration of logging on a NAT. +message RouterNatLogConfig { + // Specify the desired filtering of logs on this NAT. If unspecified, logs are exported for all connections handled by this NAT. This option can take one of the following values: - ERRORS_ONLY: Export logs only for connection failures. - TRANSLATIONS_ONLY: Export logs only for successful connections. - ALL: Export logs for all connections, successful and unsuccessful. + enum Filter { + // A value indicating that the enum field is not set. + UNDEFINED_FILTER = 0; + + // Export logs for all (successful and unsuccessful) connections. + ALL = 64897; + + // Export logs for connection failures only. + ERRORS_ONLY = 307484672; + + // Export logs for successful connections only. + TRANSLATIONS_ONLY = 357212649; + + } + + // Indicates whether or not to export logs. This is false by default. + optional bool enable = 311764355; + + // Specify the desired filtering of logs on this NAT. If unspecified, logs are exported for all connections handled by this NAT. This option can take one of the following values: - ERRORS_ONLY: Export logs only for connection failures. - TRANSLATIONS_ONLY: Export logs only for successful connections. - ALL: Export logs for all connections, successful and unsuccessful. + // Check the Filter enum for the list of possible values. + optional string filter = 336120696; + +} + +// +message RouterNatRule { + // The action to be enforced for traffic that matches this rule. + optional RouterNatRuleAction action = 187661878; + + // An optional description of this rule. + optional string description = 422937596; + + // CEL expression that specifies the match condition that egress traffic from a VM is evaluated against. If it evaluates to true, the corresponding `action` is enforced. The following examples are valid match expressions for public NAT: "inIpRange(destination.ip, '1.1.0.0/16') || inIpRange(destination.ip, '2.2.0.0/16')" "destination.ip == '1.1.0.1' || destination.ip == '8.8.8.8'" The following example is a valid match expression for private NAT: "nexthop.hub == 'https://networkconnectivity.googleapis.com/v1alpha1/projects/my-project/global/hub/hub-1'" + optional string match = 103668165; + + // An integer uniquely identifying a rule in the list. The rule number must be a positive value between 0 and 65000, and must be unique among rules within a NAT. + optional uint32 rule_number = 535211500; + +} + +// +message RouterNatRuleAction { + // A list of URLs of the IP resources used for this NAT rule. These IP addresses must be valid static external IP addresses assigned to the project. This field is used for public NAT. + repeated string source_nat_active_ips = 210378229; + + // A list of URLs of the IP resources to be drained. These IPs must be valid static external IPs that have been assigned to the NAT. These IPs should be used for updating/patching a NAT rule only. This field is used for public NAT. + repeated string source_nat_drain_ips = 340812451; + +} + +// Defines the IP ranges that want to use NAT for a subnetwork. +message RouterNatSubnetworkToNat { + // + enum SourceIpRangesToNat { + // A value indicating that the enum field is not set. + UNDEFINED_SOURCE_IP_RANGES_TO_NAT = 0; + + // The primary and all the secondary ranges are allowed to Nat. + ALL_IP_RANGES = 35608496; + + // A list of secondary ranges are allowed to Nat. + LIST_OF_SECONDARY_IP_RANGES = 192289308; + + // The primary range is allowed to Nat. + PRIMARY_IP_RANGE = 297109954; + + } + + // URL for the subnetwork resource that will use NAT. + optional string name = 3373707; + + // A list of the secondary ranges of the Subnetwork that are allowed to use NAT. This can be populated only if "LIST_OF_SECONDARY_IP_RANGES" is one of the values in source_ip_ranges_to_nat. + repeated string secondary_ip_range_names = 264315097; + + // Specify the options for NAT ranges in the Subnetwork. All options of a single value are valid except NAT_IP_RANGE_OPTION_UNSPECIFIED. The only valid option with multiple values is: ["PRIMARY_IP_RANGE", "LIST_OF_SECONDARY_IP_RANGES"] Default: [ALL_IP_RANGES] + // Check the SourceIpRangesToNat enum for the list of possible values. + repeated string source_ip_ranges_to_nat = 388310386; + +} + +// +message RouterStatus { + // Best routes for this router's network. + repeated Route best_routes = 395826693; + + // Best routes learned by this router. + repeated Route best_routes_for_router = 119389689; + + repeated RouterStatusBgpPeerStatus bgp_peer_status = 218459131; + + repeated RouterStatusNatStatus nat_status = 63098064; + + // URI of the network to which this router belongs. + optional string network = 232872494; + +} + +// +message RouterStatusBgpPeerStatus { + // Status of the BGP peer: {UP, DOWN} + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + DOWN = 2104482; + + UNKNOWN = 433141802; + + UP = 2715; + + } + + // Indicates why particular status was returned. + enum StatusReason { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS_REASON = 0; + + // Indicates internal problems with configuration of MD5 authentication. This particular reason can only be returned when md5AuthEnabled is true and status is DOWN. + MD5_AUTH_INTERNAL_PROBLEM = 140462259; + + STATUS_REASON_UNSPECIFIED = 394331913; + + } + + // Routes that were advertised to the remote BGP peer + repeated Route advertised_routes = 333393068; + + optional BfdStatus bfd_status = 395631729; + + // Enable IPv6 traffic over BGP Peer. If not specified, it is disabled by default. + optional bool enable_ipv6 = 181467939; + + // IP address of the local BGP interface. + optional string ip_address = 406272220; + + // IPv6 address of the local BGP interface. + optional string ipv6_nexthop_address = 27968211; + + // URL of the VPN tunnel that this BGP peer controls. + optional string linked_vpn_tunnel = 352296953; + + // Informs whether MD5 authentication is enabled on this BGP peer. + optional bool md5_auth_enabled = 451152075; + + // Name of this BGP peer. Unique within the Routers resource. + optional string name = 3373707; + + // Number of routes learned from the remote BGP Peer. + optional uint32 num_learned_routes = 135457535; + + // IP address of the remote BGP interface. + optional string peer_ip_address = 207735769; + + // IPv6 address of the remote BGP interface. + optional string peer_ipv6_nexthop_address = 491486608; + + // [Output only] URI of the VM instance that is used as third-party router appliances such as Next Gen Firewalls, Virtual Routers, or Router Appliances. The VM instance is the peer side of the BGP session. + optional string router_appliance_instance = 468312989; + + // The state of the BGP session. For a list of possible values for this field, see BGP session states. + optional string state = 109757585; + + // Status of the BGP peer: {UP, DOWN} + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // Indicates why particular status was returned. + // Check the StatusReason enum for the list of possible values. + optional string status_reason = 342706993; + + // Time this session has been up. Format: 14 years, 51 weeks, 6 days, 23 hours, 59 minutes, 59 seconds + optional string uptime = 235379688; + + // Time this session has been up, in seconds. Format: 145 + optional string uptime_seconds = 104736040; + +} + +// Status of a NAT contained in this router. +message RouterStatusNatStatus { + // A list of IPs auto-allocated for NAT. Example: ["1.1.1.1", "129.2.16.89"] + repeated string auto_allocated_nat_ips = 510794246; + + // A list of IPs auto-allocated for NAT that are in drain mode. Example: ["1.1.1.1", "179.12.26.133"]. + repeated string drain_auto_allocated_nat_ips = 309184557; + + // A list of IPs user-allocated for NAT that are in drain mode. Example: ["1.1.1.1", "179.12.26.133"]. + repeated string drain_user_allocated_nat_ips = 305268553; + + // The number of extra IPs to allocate. This will be greater than 0 only if user-specified IPs are NOT enough to allow all configured VMs to use NAT. This value is meaningful only when auto-allocation of NAT IPs is *not* used. + optional int32 min_extra_nat_ips_needed = 365786338; + + // Unique name of this NAT. + optional string name = 3373707; + + // Number of VM endpoints (i.e., Nics) that can use NAT. + optional int32 num_vm_endpoints_with_nat_mappings = 512367468; + + // Status of rules in this NAT. + repeated RouterStatusNatStatusNatRuleStatus rule_status = 140223125; + + // A list of fully qualified URLs of reserved IP address resources. + repeated string user_allocated_nat_ip_resources = 212776151; + + // A list of IPs user-allocated for NAT. They will be raw IP strings like "179.12.26.133". + repeated string user_allocated_nat_ips = 506878242; + +} + +// Status of a NAT Rule contained in this NAT. +message RouterStatusNatStatusNatRuleStatus { + // A list of active IPs for NAT. Example: ["1.1.1.1", "179.12.26.133"]. + repeated string active_nat_ips = 208517077; + + // A list of IPs for NAT that are in drain mode. Example: ["1.1.1.1", "179.12.26.133"]. + repeated string drain_nat_ips = 504078535; + + // The number of extra IPs to allocate. This will be greater than 0 only if the existing IPs in this NAT Rule are NOT enough to allow all configured VMs to use NAT. + optional int32 min_extra_ips_needed = 353002756; + + // Number of VM endpoints (i.e., NICs) that have NAT Mappings from this NAT Rule. + optional int32 num_vm_endpoints_with_nat_mappings = 512367468; + + // Rule number of the rule. + optional int32 rule_number = 535211500; + +} + +// +message RouterStatusResponse { + // Type of resource. + optional string kind = 3292052; + + optional RouterStatus result = 139315229; + +} + +// +message RoutersPreviewResponse { + // Preview of given router. + optional Router resource = 195806222; + +} + +// +message RoutersScopedList { + // A list of routers contained in this scope. + repeated Router routers = 311906890; + + // Informational warning which replaces the list of routers when the list is empty. + optional Warning warning = 50704284; + +} + +// This is deprecated and has no effect. Do not use. +message Rule { + // This is deprecated and has no effect. Do not use. + enum Action { + // A value indicating that the enum field is not set. + UNDEFINED_ACTION = 0; + + // This is deprecated and has no effect. Do not use. + ALLOW = 62368553; + + // This is deprecated and has no effect. Do not use. + ALLOW_WITH_LOG = 76034177; + + // This is deprecated and has no effect. Do not use. + DENY = 2094604; + + // This is deprecated and has no effect. Do not use. + DENY_WITH_LOG = 351433982; + + // This is deprecated and has no effect. Do not use. + LOG = 75556; + + // This is deprecated and has no effect. Do not use. + NO_ACTION = 260643444; + + } + + // This is deprecated and has no effect. Do not use. + // Check the Action enum for the list of possible values. + optional string action = 187661878; + + // This is deprecated and has no effect. Do not use. + repeated Condition conditions = 142882488; + + // This is deprecated and has no effect. Do not use. + optional string description = 422937596; + + // This is deprecated and has no effect. Do not use. + repeated string ins = 104430; + + // This is deprecated and has no effect. Do not use. + repeated LogConfig log_configs = 152873846; + + // This is deprecated and has no effect. Do not use. + repeated string not_ins = 518443138; + + // This is deprecated and has no effect. Do not use. + repeated string permissions = 59962500; + +} + +// +message SSLHealthCheck { + // Specifies how a port is selected for health checking. Can be one of the following values: USE_FIXED_PORT: Specifies a port number explicitly using the port field in the health check. Supported by backend services for pass-through load balancers and backend services for proxy load balancers. Not supported by target pools. The health check supports all backends supported by the backend service provided the backend can be health checked. For example, GCE_VM_IP network endpoint groups, GCE_VM_IP_PORT network endpoint groups, and instance group backends. USE_NAMED_PORT: Not supported. USE_SERVING_PORT: Provides an indirect method of specifying the health check port by referring to the backend service. Only supported by backend services for proxy load balancers. Not supported by target pools. Not supported by backend services for pass-through load balancers. Supports all backends that can be health checked; for example, GCE_VM_IP_PORT network endpoint groups and instance group backends. For GCE_VM_IP_PORT network endpoint group backends, the health check uses the port number specified for each endpoint in the network endpoint group. For instance group backends, the health check uses the port number determined by looking up the backend service's named port in the instance group's list of named ports. + enum PortSpecification { + // A value indicating that the enum field is not set. + UNDEFINED_PORT_SPECIFICATION = 0; + + // The port number in the health check's port is used for health checking. Applies to network endpoint group and instance group backends. + USE_FIXED_PORT = 190235748; + + // Not supported. + USE_NAMED_PORT = 349300671; + + // For network endpoint group backends, the health check uses the port number specified on each endpoint in the network endpoint group. For instance group backends, the health check uses the port number specified for the backend service's named port defined in the instance group's named ports. + USE_SERVING_PORT = 362637516; + + } + + // Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. + enum ProxyHeader { + // A value indicating that the enum field is not set. + UNDEFINED_PROXY_HEADER = 0; + + NONE = 2402104; + + PROXY_V1 = 334352940; + + } + + // The TCP port number to which the health check prober sends packets. The default value is 443. Valid values are 1 through 65535. + optional int32 port = 3446913; + + // Not supported. + optional string port_name = 41534345; + + // Specifies how a port is selected for health checking. Can be one of the following values: USE_FIXED_PORT: Specifies a port number explicitly using the port field in the health check. Supported by backend services for pass-through load balancers and backend services for proxy load balancers. Not supported by target pools. The health check supports all backends supported by the backend service provided the backend can be health checked. For example, GCE_VM_IP network endpoint groups, GCE_VM_IP_PORT network endpoint groups, and instance group backends. USE_NAMED_PORT: Not supported. USE_SERVING_PORT: Provides an indirect method of specifying the health check port by referring to the backend service. Only supported by backend services for proxy load balancers. Not supported by target pools. Not supported by backend services for pass-through load balancers. Supports all backends that can be health checked; for example, GCE_VM_IP_PORT network endpoint groups and instance group backends. For GCE_VM_IP_PORT network endpoint group backends, the health check uses the port number specified for each endpoint in the network endpoint group. For instance group backends, the health check uses the port number determined by looking up the backend service's named port in the instance group's list of named ports. + // Check the PortSpecification enum for the list of possible values. + optional string port_specification = 51590597; + + // Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. + // Check the ProxyHeader enum for the list of possible values. + optional string proxy_header = 160374142; + + // Instructs the health check prober to send this exact ASCII string, up to 1024 bytes in length, after establishing the TCP connection and SSL handshake. + optional string request = 21951119; + + // Creates a content-based SSL health check. In addition to establishing a TCP connection and the TLS handshake, you can configure the health check to pass only when the backend sends this exact response ASCII string, up to 1024 bytes in length. For details, see: https://cloud.google.com/load-balancing/docs/health-check-concepts#criteria-protocol-ssl-tcp + optional string response = 196547649; + +} + +// DEPRECATED: Please use compute#savedDisk instead. An instance-attached disk resource. +message SavedAttachedDisk { + // Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. + enum Interface { + // A value indicating that the enum field is not set. + UNDEFINED_INTERFACE = 0; + + NVME = 2408800; + + SCSI = 2539686; + + } + + // The mode in which this disk is attached to the source instance, either READ_WRITE or READ_ONLY. + enum Mode { + // A value indicating that the enum field is not set. + UNDEFINED_MODE = 0; + + // Attaches this disk in read-only mode. Multiple virtual machines can use a disk in read-only mode at a time. + READ_ONLY = 91950261; + + // *[Default]* Attaches this disk in read-write mode. Only one virtual machine at a time can be attached to a disk in read-write mode. + READ_WRITE = 173607894; + + } + + // [Output Only] An indicator whether storageBytes is in a stable state or it is being adjusted as a result of shared storage reallocation. This status can either be UPDATING, meaning the size of the snapshot is being updated, or UP_TO_DATE, meaning the size of the snapshot is up-to-date. + enum StorageBytesStatus { + // A value indicating that the enum field is not set. + UNDEFINED_STORAGE_BYTES_STATUS = 0; + + UPDATING = 494614342; + + UP_TO_DATE = 101306702; + + } + + // Specifies the type of the attached disk, either SCRATCH or PERSISTENT. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + PERSISTENT = 460683927; + + SCRATCH = 496778970; + + } + + // Specifies whether the disk will be auto-deleted when the instance is deleted (but not when the disk is detached from the instance). + optional bool auto_delete = 464761403; + + // Indicates that this is a boot disk. The virtual machine will use the first partition of the disk for its root filesystem. + optional bool boot = 3029746; + + // Specifies the name of the disk attached to the source instance. + optional string device_name = 67541716; + + // The encryption key for the disk. + optional CustomerEncryptionKey disk_encryption_key = 271660677; + + // The size of the disk in base-2 GB. + optional int64 disk_size_gb = 316263735; + + // [Output Only] URL of the disk type resource. For example: projects/project /zones/zone/diskTypes/pd-standard or pd-ssd + optional string disk_type = 93009052; + + // A list of features to enable on the guest operating system. Applicable only for bootable images. Read Enabling guest operating system features to see a list of available options. + repeated GuestOsFeature guest_os_features = 79294545; + + // Specifies zero-based index of the disk that is attached to the source instance. + optional int32 index = 100346066; + + // Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. + // Check the Interface enum for the list of possible values. + optional string interface = 502623545; + + // [Output Only] Type of the resource. Always compute#attachedDisk for attached disks. + optional string kind = 3292052; + + // [Output Only] Any valid publicly visible licenses. + repeated string licenses = 337642578; + + // The mode in which this disk is attached to the source instance, either READ_WRITE or READ_ONLY. + // Check the Mode enum for the list of possible values. + optional string mode = 3357091; + + // Specifies a URL of the disk attached to the source instance. + optional string source = 177235995; + + // [Output Only] A size of the storage used by the disk's snapshot by this machine image. + optional int64 storage_bytes = 424631719; + + // [Output Only] An indicator whether storageBytes is in a stable state or it is being adjusted as a result of shared storage reallocation. This status can either be UPDATING, meaning the size of the snapshot is being updated, or UP_TO_DATE, meaning the size of the snapshot is up-to-date. + // Check the StorageBytesStatus enum for the list of possible values. + optional string storage_bytes_status = 490739082; + + // Specifies the type of the attached disk, either SCRATCH or PERSISTENT. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// An instance-attached disk resource. +message SavedDisk { + // [Output Only] The architecture of the attached disk. + enum Architecture { + // A value indicating that the enum field is not set. + UNDEFINED_ARCHITECTURE = 0; + + // Default value indicating Architecture is not set. + ARCHITECTURE_UNSPECIFIED = 394750507; + + // Machines with architecture ARM64 + ARM64 = 62547450; + + // Machines with architecture X86_64 + X86_64 = 425300551; + + } + + // [Output Only] An indicator whether storageBytes is in a stable state or it is being adjusted as a result of shared storage reallocation. This status can either be UPDATING, meaning the size of the snapshot is being updated, or UP_TO_DATE, meaning the size of the snapshot is up-to-date. + enum StorageBytesStatus { + // A value indicating that the enum field is not set. + UNDEFINED_STORAGE_BYTES_STATUS = 0; + + UPDATING = 494614342; + + UP_TO_DATE = 101306702; + + } + + // [Output Only] The architecture of the attached disk. + // Check the Architecture enum for the list of possible values. + optional string architecture = 302803283; + + // [Output Only] Type of the resource. Always compute#savedDisk for attached disks. + optional string kind = 3292052; + + // Specifies a URL of the disk attached to the source instance. + optional string source_disk = 451753793; + + // [Output Only] Size of the individual disk snapshot used by this machine image. + optional int64 storage_bytes = 424631719; + + // [Output Only] An indicator whether storageBytes is in a stable state or it is being adjusted as a result of shared storage reallocation. This status can either be UPDATING, meaning the size of the snapshot is being updated, or UP_TO_DATE, meaning the size of the snapshot is up-to-date. + // Check the StorageBytesStatus enum for the list of possible values. + optional string storage_bytes_status = 490739082; + +} + +// +message ScalingScheduleStatus { + // [Output Only] The current state of a scaling schedule. + enum State { + // A value indicating that the enum field is not set. + UNDEFINED_STATE = 0; + + // The current autoscaling recommendation is influenced by this scaling schedule. + ACTIVE = 314733318; + + // This scaling schedule has been disabled by the user. + DISABLED = 516696700; + + // This scaling schedule will never become active again. + OBSOLETE = 66532761; + + // The current autoscaling recommendation is not influenced by this scaling schedule. + READY = 77848963; + + } + + // [Output Only] The last time the scaling schedule became active. Note: this is a timestamp when a schedule actually became active, not when it was planned to do so. The timestamp is in RFC3339 text format. + optional string last_start_time = 34545107; + + // [Output Only] The next time the scaling schedule is to become active. Note: this is a timestamp when a schedule is planned to run, but the actual time might be slightly different. The timestamp is in RFC3339 text format. + optional string next_start_time = 97270102; + + // [Output Only] The current state of a scaling schedule. + // Check the State enum for the list of possible values. + optional string state = 109757585; + +} + +// Sets the scheduling options for an Instance. +message Scheduling { + // Specifies the termination action for the instance. + enum InstanceTerminationAction { + // A value indicating that the enum field is not set. + UNDEFINED_INSTANCE_TERMINATION_ACTION = 0; + + // Delete the VM. + DELETE = 402225579; + + // Default value. This value is unused. + INSTANCE_TERMINATION_ACTION_UNSPECIFIED = 92954803; + + // Stop the VM without storing in-memory content. default action. + STOP = 2555906; + + } + + // Defines the maintenance behavior for this instance. For standard instances, the default behavior is MIGRATE. For preemptible instances, the default and only possible behavior is TERMINATE. For more information, see Set VM host maintenance policy. + enum OnHostMaintenance { + // A value indicating that the enum field is not set. + UNDEFINED_ON_HOST_MAINTENANCE = 0; + + // *[Default]* Allows Compute Engine to automatically migrate instances out of the way of maintenance events. + MIGRATE = 165699979; + + // Tells Compute Engine to terminate and (optionally) restart the instance away from the maintenance activity. If you would like your instance to be restarted, set the automaticRestart flag to true. Your instance may be restarted more than once, and it may be restarted outside the window of maintenance events. + TERMINATE = 527617601; + + } + + // Specifies the provisioning model of the instance. + enum ProvisioningModel { + // A value indicating that the enum field is not set. + UNDEFINED_PROVISIONING_MODEL = 0; + + // Heavily discounted, no guaranteed runtime. + SPOT = 2552066; + + // Standard provisioning with user controlled runtime, no discounts. + STANDARD = 484642493; + + } + + // Specifies whether the instance should be automatically restarted if it is terminated by Compute Engine (not terminated by a user). You can only set the automatic restart option for standard instances. Preemptible instances cannot be automatically restarted. By default, this is set to true so an instance is automatically restarted if it is terminated by Compute Engine. + optional bool automatic_restart = 350821371; + + // Specifies the termination action for the instance. + // Check the InstanceTerminationAction enum for the list of possible values. + optional string instance_termination_action = 107380667; + + // An opaque location hint used to place the instance close to other resources. This field is for use by internal tools that use the public API. + optional string location_hint = 350519505; + + // The minimum number of virtual CPUs this instance will consume when running on a sole-tenant node. + optional int32 min_node_cpus = 317231675; + + // A set of node affinity and anti-affinity configurations. Refer to Configuring node affinity for more information. Overrides reservationAffinity. + repeated SchedulingNodeAffinity node_affinities = 461799971; + + // Defines the maintenance behavior for this instance. For standard instances, the default behavior is MIGRATE. For preemptible instances, the default and only possible behavior is TERMINATE. For more information, see Set VM host maintenance policy. + // Check the OnHostMaintenance enum for the list of possible values. + optional string on_host_maintenance = 64616796; + + // Defines whether the instance is preemptible. This can only be set during instance creation or while the instance is stopped and therefore, in a `TERMINATED` state. See Instance Life Cycle for more information on the possible instance states. + optional bool preemptible = 324203169; + + // Specifies the provisioning model of the instance. + // Check the ProvisioningModel enum for the list of possible values. + optional string provisioning_model = 494423; + +} + +// Node Affinity: the configuration of desired nodes onto which this Instance could be scheduled. +message SchedulingNodeAffinity { + // Defines the operation of node selection. Valid operators are IN for affinity and NOT_IN for anti-affinity. + enum Operator { + // A value indicating that the enum field is not set. + UNDEFINED_OPERATOR = 0; + + // Requires Compute Engine to seek for matched nodes. + IN = 2341; + + // Requires Compute Engine to avoid certain nodes. + NOT_IN = 161144369; + + OPERATOR_UNSPECIFIED = 128892924; + + } + + // Corresponds to the label key of Node resource. + optional string key = 106079; + + // Defines the operation of node selection. Valid operators are IN for affinity and NOT_IN for anti-affinity. + // Check the Operator enum for the list of possible values. + optional string operator = 36317348; + + // Corresponds to the label values of Node resource. + repeated string values = 249928994; + +} + +// +message ScratchDisks { + // Size of the scratch disk, defined in GB. + optional int32 disk_gb = 60990141; + +} + +// An instance's screenshot. +message Screenshot { + // [Output Only] The Base64-encoded screenshot data. + optional string contents = 506419994; + + // [Output Only] Type of the resource. Always compute#screenshot for the screenshots. + optional string kind = 3292052; + +} + +// +message SecurityPoliciesAggregatedList { + optional string etag = 3123477; + + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of SecurityPoliciesScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#securityPolicyAggregatedList for lists of Security Policies. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message SecurityPoliciesListPreconfiguredExpressionSetsResponse { + optional SecurityPoliciesWafConfig preconfigured_expression_sets = 536200826; + +} + +// +message SecurityPoliciesScopedList { + // A list of SecurityPolicies contained in this scope. + repeated SecurityPolicy security_policies = 127783791; + + // Informational warning which replaces the list of security policies when the list is empty. + optional Warning warning = 50704284; + +} + +// +message SecurityPoliciesWafConfig { + optional PreconfiguredWafSet waf_rules = 74899924; + +} + +// Represents a Google Cloud Armor security policy resource. Only external backend services that use load balancers can reference a security policy. For more information, see Google Cloud Armor security policy overview. +message SecurityPolicy { + // The type indicates the intended use of the security policy. - CLOUD_ARMOR: Cloud Armor backend security policies can be configured to filter incoming HTTP requests targeting backend services. They filter requests before they hit the origin servers. - CLOUD_ARMOR_EDGE: Cloud Armor edge security policies can be configured to filter incoming HTTP requests targeting backend services (including Cloud CDN-enabled) as well as backend buckets (Cloud Storage). They filter requests before the request is served from Google's cache. - CLOUD_ARMOR_INTERNAL_SERVICE: Cloud Armor internal service policies can be configured to filter HTTP requests targeting services managed by Traffic Director in a service mesh. They filter requests before the request is served from the application. - CLOUD_ARMOR_NETWORK: Cloud Armor network policies can be configured to filter packets targeting network load balancing resources such as backend services, target pools, target instances, and instances with external IPs. They filter requests before the request is served from the application. This field can be set only at resource creation time. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + CLOUD_ARMOR = 260640373; + + CLOUD_ARMOR_EDGE = 250728775; + + CLOUD_ARMOR_NETWORK = 488527428; + + } + + optional SecurityPolicyAdaptiveProtectionConfig adaptive_protection_config = 150240735; + + optional SecurityPolicyAdvancedOptionsConfig advanced_options_config = 449276352; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + optional SecurityPolicyDdosProtectionConfig ddos_protection_config = 50315853; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Specifies a fingerprint for this resource, which is essentially a hash of the metadata's contents and used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update metadata. You must always provide an up-to-date fingerprint hash in order to update or change metadata, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make get() request to the security policy. + optional string fingerprint = 234678500; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output only] Type of the resource. Always compute#securityPolicyfor security policies + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + optional SecurityPolicyRecaptchaOptionsConfig recaptcha_options_config = 519006811; + + // [Output Only] URL of the region where the regional security policy resides. This field is not applicable to global security policies. + optional string region = 138946292; + + // A list of rules that belong to this policy. There must always be a default rule which is a rule with priority 2147483647 and match all condition (for the match condition this means match "*" for srcIpRanges and for the networkMatch condition every field must be either match "*" or not set). If no rules are provided when creating a security policy, a default rule with action "allow" will be added. + repeated SecurityPolicyRule rules = 108873975; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // The type indicates the intended use of the security policy. - CLOUD_ARMOR: Cloud Armor backend security policies can be configured to filter incoming HTTP requests targeting backend services. They filter requests before they hit the origin servers. - CLOUD_ARMOR_EDGE: Cloud Armor edge security policies can be configured to filter incoming HTTP requests targeting backend services (including Cloud CDN-enabled) as well as backend buckets (Cloud Storage). They filter requests before the request is served from Google's cache. - CLOUD_ARMOR_INTERNAL_SERVICE: Cloud Armor internal service policies can be configured to filter HTTP requests targeting services managed by Traffic Director in a service mesh. They filter requests before the request is served from the application. - CLOUD_ARMOR_NETWORK: Cloud Armor network policies can be configured to filter packets targeting network load balancing resources such as backend services, target pools, target instances, and instances with external IPs. They filter requests before the request is served from the application. This field can be set only at resource creation time. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// Configuration options for Cloud Armor Adaptive Protection (CAAP). +message SecurityPolicyAdaptiveProtectionConfig { + // If set to true, enables Cloud Armor Machine Learning. + optional SecurityPolicyAdaptiveProtectionConfigLayer7DdosDefenseConfig layer7_ddos_defense_config = 437316771; + +} + +// Configuration options for L7 DDoS detection. +message SecurityPolicyAdaptiveProtectionConfigLayer7DdosDefenseConfig { + // Rule visibility can be one of the following: STANDARD - opaque rules. (default) PREMIUM - transparent rules. + enum RuleVisibility { + // A value indicating that the enum field is not set. + UNDEFINED_RULE_VISIBILITY = 0; + + PREMIUM = 399530551; + + STANDARD = 484642493; + + } + + // If set to true, enables CAAP for L7 DDoS detection. + optional bool enable = 311764355; + + // Rule visibility can be one of the following: STANDARD - opaque rules. (default) PREMIUM - transparent rules. + // Check the RuleVisibility enum for the list of possible values. + optional string rule_visibility = 453258293; + +} + +// +message SecurityPolicyAdvancedOptionsConfig { + // + enum JsonParsing { + // A value indicating that the enum field is not set. + UNDEFINED_JSON_PARSING = 0; + + DISABLED = 516696700; + + STANDARD = 484642493; + + } + + // + enum LogLevel { + // A value indicating that the enum field is not set. + UNDEFINED_LOG_LEVEL = 0; + + NORMAL = 161067239; + + VERBOSE = 532219234; + + } + + // Custom configuration to apply the JSON parsing. Only applicable when json_parsing is set to STANDARD. + optional SecurityPolicyAdvancedOptionsConfigJsonCustomConfig json_custom_config = 111570105; + + // + // Check the JsonParsing enum for the list of possible values. + optional string json_parsing = 282493529; + + // + // Check the LogLevel enum for the list of possible values. + optional string log_level = 140582601; + +} + +// +message SecurityPolicyAdvancedOptionsConfigJsonCustomConfig { + // A list of custom Content-Type header values to apply the JSON parsing. As per RFC 1341, a Content-Type header value has the following format: Content-Type := type "/" subtype *[";" parameter] When configuring a custom Content-Type header value, only the type/subtype needs to be specified, and the parameters should be excluded. + repeated string content_types = 17428787; + +} + +// +message SecurityPolicyDdosProtectionConfig { + // + enum DdosProtection { + // A value indicating that the enum field is not set. + UNDEFINED_DDOS_PROTECTION = 0; + + ADVANCED = 63789090; + + STANDARD = 484642493; + + } + + // + // Check the DdosProtection enum for the list of possible values. + optional string ddos_protection = 275173268; + +} + +// +message SecurityPolicyList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of SecurityPolicy resources. + repeated SecurityPolicy items = 100526016; + + // [Output Only] Type of resource. Always compute#securityPolicyList for listsof securityPolicies + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message SecurityPolicyRecaptchaOptionsConfig { + // An optional field to supply a reCAPTCHA site key to be used for all the rules using the redirect action with the type of GOOGLE_RECAPTCHA under the security policy. The specified site key needs to be created from the reCAPTCHA API. The user is responsible for the validity of the specified site key. If not specified, a Google-managed site key is used. + optional string redirect_site_key = 447677034; + +} + +// +message SecurityPolicyReference { + optional string security_policy = 171082513; + +} + +// Represents a rule that describes one or more match conditions along with the action to be taken when traffic matches this condition (allow or deny). +message SecurityPolicyRule { + // The Action to perform when the rule is matched. The following are the valid actions: - allow: allow access to target. - deny(STATUS): deny access to target, returns the HTTP response code specified. Valid values for `STATUS` are 403, 404, and 502. - rate_based_ban: limit client traffic to the configured threshold and ban the client if the traffic exceeds the threshold. Configure parameters for this action in RateLimitOptions. Requires rate_limit_options to be set. - redirect: redirect to a different target. This can either be an internal reCAPTCHA redirect, or an external URL-based redirect via a 302 response. Parameters for this action can be configured via redirectOptions. - throttle: limit client traffic to the configured threshold. Configure parameters for this action in rateLimitOptions. Requires rate_limit_options to be set for this. + optional string action = 187661878; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Optional, additional actions that are performed on headers. + optional SecurityPolicyRuleHttpHeaderAction header_action = 328077352; + + // [Output only] Type of the resource. Always compute#securityPolicyRule for security policy rules + optional string kind = 3292052; + + // A match condition that incoming traffic is evaluated against. If it evaluates to true, the corresponding 'action' is enforced. + optional SecurityPolicyRuleMatcher match = 103668165; + + // Preconfigured WAF configuration to be applied for the rule. If the rule does not evaluate preconfigured WAF rules, i.e., if evaluatePreconfiguredWaf() is not used, this field will have no effect. + optional SecurityPolicyRulePreconfiguredWafConfig preconfigured_waf_config = 117805027; + + // If set to true, the specified action is not enforced. + optional bool preview = 218686408; + + // An integer indicating the priority of a rule in the list. The priority must be a positive value between 0 and 2147483647. Rules are evaluated from highest to lowest priority where 0 is the highest priority and 2147483647 is the lowest priority. + optional int32 priority = 445151652; + + // Must be specified if the action is "rate_based_ban" or "throttle". Cannot be specified for any other actions. + optional SecurityPolicyRuleRateLimitOptions rate_limit_options = 67544315; + + // Parameters defining the redirect action. Cannot be specified for any other actions. + optional SecurityPolicyRuleRedirectOptions redirect_options = 163285307; + +} + +// +message SecurityPolicyRuleHttpHeaderAction { + // The list of request headers to add or overwrite if they're already present. + repeated SecurityPolicyRuleHttpHeaderActionHttpHeaderOption request_headers_to_adds = 87987661; + +} + +// +message SecurityPolicyRuleHttpHeaderActionHttpHeaderOption { + // The name of the header to set. + optional string header_name = 110223613; + + // The value to set the named header to. + optional string header_value = 203094335; + +} + +// Represents a match condition that incoming traffic is evaluated against. Exactly one field must be specified. +message SecurityPolicyRuleMatcher { + // Preconfigured versioned expression. If this field is specified, config must also be specified. Available preconfigured expressions along with their requirements are: SRC_IPS_V1 - must specify the corresponding src_ip_range field in config. + enum VersionedExpr { + // A value indicating that the enum field is not set. + UNDEFINED_VERSIONED_EXPR = 0; + + // Matches the source IP address of a request to the IP ranges supplied in config. + SRC_IPS_V1 = 70925961; + + } + + // The configuration options available when specifying versioned_expr. This field must be specified if versioned_expr is specified and cannot be specified if versioned_expr is not specified. + optional SecurityPolicyRuleMatcherConfig config = 255820610; + + // User defined CEVAL expression. A CEVAL expression is used to specify match criteria such as origin.ip, source.region_code and contents in the request header. + optional Expr expr = 3127797; + + // Preconfigured versioned expression. If this field is specified, config must also be specified. Available preconfigured expressions along with their requirements are: SRC_IPS_V1 - must specify the corresponding src_ip_range field in config. + // Check the VersionedExpr enum for the list of possible values. + optional string versioned_expr = 322286013; + +} + +// +message SecurityPolicyRuleMatcherConfig { + // CIDR IP address range. Maximum number of src_ip_ranges allowed is 10. + repeated string src_ip_ranges = 432128083; + +} + +// +message SecurityPolicyRulePreconfiguredWafConfig { + // A list of exclusions to apply during preconfigured WAF evaluation. + repeated SecurityPolicyRulePreconfiguredWafConfigExclusion exclusions = 208665701; + +} + +// +message SecurityPolicyRulePreconfiguredWafConfigExclusion { + // A list of request cookie names whose value will be excluded from inspection during preconfigured WAF evaluation. + repeated SecurityPolicyRulePreconfiguredWafConfigExclusionFieldParams request_cookies_to_exclude = 156757878; + + // A list of request header names whose value will be excluded from inspection during preconfigured WAF evaluation. + repeated SecurityPolicyRulePreconfiguredWafConfigExclusionFieldParams request_headers_to_exclude = 63230495; + + // A list of request query parameter names whose value will be excluded from inspection during preconfigured WAF evaluation. Note that the parameter can be in the query string or in the POST body. + repeated SecurityPolicyRulePreconfiguredWafConfigExclusionFieldParams request_query_params_to_exclude = 340692744; + + // A list of request URIs from the request line to be excluded from inspection during preconfigured WAF evaluation. When specifying this field, the query or fragment part should be excluded. + repeated SecurityPolicyRulePreconfiguredWafConfigExclusionFieldParams request_uris_to_exclude = 90690846; + + // A list of target rule IDs under the WAF rule set to apply the preconfigured WAF exclusion. If omitted, it refers to all the rule IDs under the WAF rule set. + repeated string target_rule_ids = 498430435; + + // Target WAF rule set to apply the preconfigured WAF exclusion. + optional string target_rule_set = 498440077; + +} + +// +message SecurityPolicyRulePreconfiguredWafConfigExclusionFieldParams { + // The match operator for the field. + enum Op { + // A value indicating that the enum field is not set. + UNDEFINED_OP = 0; + + // The operator matches if the field value contains the specified value. + CONTAINS = 215180831; + + // The operator matches if the field value ends with the specified value. + ENDS_WITH = 490402221; + + // The operator matches if the field value equals the specified value. + EQUALS = 442201023; + + // The operator matches if the field value is any value. + EQUALS_ANY = 337226060; + + // The operator matches if the field value starts with the specified value. + STARTS_WITH = 139505652; + + } + + // The match operator for the field. + // Check the Op enum for the list of possible values. + optional string op = 3553; + + // The value of the field. + optional string val = 116513; + +} + +// +message SecurityPolicyRuleRateLimitOptions { + // Determines the key to enforce the rate_limit_threshold on. Possible values are: - ALL: A single rate limit threshold is applied to all the requests matching this rule. This is the default value if "enforceOnKey" is not configured. - IP: The source IP address of the request is the key. Each IP has this limit enforced separately. - HTTP_HEADER: The value of the HTTP header whose name is configured under "enforceOnKeyName". The key value is truncated to the first 128 bytes of the header value. If no such header is present in the request, the key type defaults to ALL. - XFF_IP: The first IP address (i.e. the originating client IP address) specified in the list of IPs under X-Forwarded-For HTTP header. If no such header is present or the value is not a valid IP, the key defaults to the source IP address of the request i.e. key type IP. - HTTP_COOKIE: The value of the HTTP cookie whose name is configured under "enforceOnKeyName". The key value is truncated to the first 128 bytes of the cookie value. If no such cookie is present in the request, the key type defaults to ALL. - HTTP_PATH: The URL path of the HTTP request. The key value is truncated to the first 128 bytes. - SNI: Server name indication in the TLS session of the HTTPS request. The key value is truncated to the first 128 bytes. The key type defaults to ALL on a HTTP session. - REGION_CODE: The country/region from which the request originates. + enum EnforceOnKey { + // A value indicating that the enum field is not set. + UNDEFINED_ENFORCE_ON_KEY = 0; + + ALL = 64897; + + HTTP_COOKIE = 494981627; + + HTTP_HEADER = 91597348; + + HTTP_PATH = 311503228; + + IP = 2343; + + REGION_CODE = 79559768; + + SNI = 82254; + + XFF_IP = 438707118; + + } + + // Can only be specified if the action for the rule is "rate_based_ban". If specified, determines the time (in seconds) the traffic will continue to be banned by the rate limit after the rate falls below the threshold. + optional int32 ban_duration_sec = 42896726; + + // Can only be specified if the action for the rule is "rate_based_ban". If specified, the key will be banned for the configured 'ban_duration_sec' when the number of requests that exceed the 'rate_limit_threshold' also exceed this 'ban_threshold'. + optional SecurityPolicyRuleRateLimitOptionsThreshold ban_threshold = 501208123; + + // Action to take for requests that are under the configured rate limit threshold. Valid option is "allow" only. + optional string conform_action = 517612367; + + // Determines the key to enforce the rate_limit_threshold on. Possible values are: - ALL: A single rate limit threshold is applied to all the requests matching this rule. This is the default value if "enforceOnKey" is not configured. - IP: The source IP address of the request is the key. Each IP has this limit enforced separately. - HTTP_HEADER: The value of the HTTP header whose name is configured under "enforceOnKeyName". The key value is truncated to the first 128 bytes of the header value. If no such header is present in the request, the key type defaults to ALL. - XFF_IP: The first IP address (i.e. the originating client IP address) specified in the list of IPs under X-Forwarded-For HTTP header. If no such header is present or the value is not a valid IP, the key defaults to the source IP address of the request i.e. key type IP. - HTTP_COOKIE: The value of the HTTP cookie whose name is configured under "enforceOnKeyName". The key value is truncated to the first 128 bytes of the cookie value. If no such cookie is present in the request, the key type defaults to ALL. - HTTP_PATH: The URL path of the HTTP request. The key value is truncated to the first 128 bytes. - SNI: Server name indication in the TLS session of the HTTPS request. The key value is truncated to the first 128 bytes. The key type defaults to ALL on a HTTP session. - REGION_CODE: The country/region from which the request originates. + // Check the EnforceOnKey enum for the list of possible values. + optional string enforce_on_key = 416648956; + + // Rate limit key name applicable only for the following key types: HTTP_HEADER -- Name of the HTTP header whose value is taken as the key value. HTTP_COOKIE -- Name of the HTTP cookie whose value is taken as the key value. + optional string enforce_on_key_name = 132555246; + + // Action to take for requests that are above the configured rate limit threshold, to either deny with a specified HTTP response code, or redirect to a different endpoint. Valid options are `deny(STATUS)`, where valid values for `STATUS` are 403, 404, 429, and 502, and `redirect`, where the redirect parameters come from `exceedRedirectOptions` below. + optional string exceed_action = 167159073; + + // Parameters defining the redirect action that is used as the exceed action. Cannot be specified if the exceed action is not redirect. + optional SecurityPolicyRuleRedirectOptions exceed_redirect_options = 473646694; + + // Threshold at which to begin ratelimiting. + optional SecurityPolicyRuleRateLimitOptionsThreshold rate_limit_threshold = 315875208; + +} + +// +message SecurityPolicyRuleRateLimitOptionsThreshold { + // Number of HTTP(S) requests for calculating the threshold. + optional int32 count = 94851343; + + // Interval over which the threshold is computed. + optional int32 interval_sec = 41084375; + +} + +// +message SecurityPolicyRuleRedirectOptions { + // Type of the redirect action. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + EXTERNAL_302 = 395733761; + + GOOGLE_RECAPTCHA = 518803009; + + } + + // Target for the redirect action. This is required if the type is EXTERNAL_302 and cannot be specified for GOOGLE_RECAPTCHA. + optional string target = 192835985; + + // Type of the redirect action. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// The authentication and authorization settings for a BackendService. +message SecuritySettings { + // Optional. A URL referring to a networksecurity.ClientTlsPolicy resource that describes how clients should authenticate with this service's backends. clientTlsPolicy only applies to a global BackendService with the loadBalancingScheme set to INTERNAL_SELF_MANAGED. If left blank, communications are not encrypted. Note: This field currently has no impact. + optional string client_tls_policy = 462325226; + + // Optional. A list of Subject Alternative Names (SANs) that the client verifies during a mutual TLS handshake with an server/endpoint for this BackendService. When the server presents its X.509 certificate to the client, the client inspects the certificate's subjectAltName field. If the field contains one of the specified values, the communication continues. Otherwise, it fails. This additional check enables the client to verify that the server is authorized to run the requested service. Note that the contents of the server certificate's subjectAltName field are configured by the Public Key Infrastructure which provisions server identities. Only applies to a global BackendService with loadBalancingScheme set to INTERNAL_SELF_MANAGED. Only applies when BackendService has an attached clientTlsPolicy with clientCertificate (mTLS mode). Note: This field currently has no impact. + repeated string subject_alt_names = 330029535; + +} + +// A request message for Instances.SendDiagnosticInterrupt. See the method description for details. +message SendDiagnosticInterruptInstanceRequest { + // Name of the instance scoping this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A response message for Instances.SendDiagnosticInterrupt. See the method description for details. +message SendDiagnosticInterruptInstanceResponse { +} + +// An instance serial console output. +message SerialPortOutput { + // [Output Only] The contents of the console output. + optional string contents = 506419994; + + // [Output Only] Type of the resource. Always compute#serialPortOutput for serial port output. + optional string kind = 3292052; + + // [Output Only] The position of the next byte of content, regardless of whether the content exists, following the output returned in the `contents` property. Use this value in the next request as the start parameter. + optional int64 next = 3377907; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // The starting byte position of the output that was returned. This should match the start parameter sent with the request. If the serial console output exceeds the size of the buffer (1 MB), older output is overwritten by newer content. The output start value will indicate the byte position of the output that was returned, which might be different than the `start` value that was specified in the request. + optional int64 start = 109757538; + +} + +// +message ServerBinding { + // + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + // Node may associate with any physical server over its lifetime. + RESTART_NODE_ON_ANY_SERVER = 502950985; + + // Node may associate with minimal physical servers over its lifetime. + RESTART_NODE_ON_MINIMAL_SERVERS = 204166495; + + SERVER_BINDING_TYPE_UNSPECIFIED = 180825512; + + } + + // + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// A service account. +message ServiceAccount { + // Email address of the service account. + optional string email = 96619420; + + // The list of scopes to be made available for this service account. + repeated string scopes = 165973151; + +} + +// Represents a ServiceAttachment resource. A service attachment represents a service that a producer has exposed. It encapsulates the load balancer which fronts the service runs and a list of NAT IP ranges that the producers uses to represent the consumers connecting to the service. next tag = 20 +message ServiceAttachment { + // The connection preference of service attachment. The value can be set to ACCEPT_AUTOMATIC. An ACCEPT_AUTOMATIC service attachment is one that always accepts the connection from consumer forwarding rules. + enum ConnectionPreference { + // A value indicating that the enum field is not set. + UNDEFINED_CONNECTION_PREFERENCE = 0; + + ACCEPT_AUTOMATIC = 75250580; + + ACCEPT_MANUAL = 373061341; + + CONNECTION_PREFERENCE_UNSPECIFIED = 34590772; + + } + + // [Output Only] An array of connections for all the consumers connected to this service attachment. + repeated ServiceAttachmentConnectedEndpoint connected_endpoints = 72223688; + + // The connection preference of service attachment. The value can be set to ACCEPT_AUTOMATIC. An ACCEPT_AUTOMATIC service attachment is one that always accepts the connection from consumer forwarding rules. + // Check the ConnectionPreference enum for the list of possible values. + optional string connection_preference = 285818076; + + // Projects that are allowed to connect to this service attachment. + repeated ServiceAttachmentConsumerProjectLimit consumer_accept_lists = 402725703; + + // Projects that are not allowed to connect to this service attachment. The project can be specified using its id or number. + repeated string consumer_reject_lists = 204033182; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // If specified, the domain name will be used during the integration between the PSC connected endpoints and the Cloud DNS. For example, this is a valid domain name: "p.mycompany.com.". Current max number of domain names supported is 1. + repeated string domain_names = 6450189; + + // If true, enable the proxy protocol which is for supplying client TCP/IP address data in TCP connections that traverse proxies on their way to destination servers. + optional bool enable_proxy_protocol = 363791237; + + // Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a ServiceAttachment. An up-to-date fingerprint must be provided in order to patch/update the ServiceAttachment; otherwise, the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve the ServiceAttachment. + optional string fingerprint = 234678500; + + // [Output Only] The unique identifier for the resource type. The server generates this identifier. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#serviceAttachment for service attachments. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // An array of URLs where each entry is the URL of a subnet provided by the service producer to use for NAT in this service attachment. + repeated string nat_subnets = 374785944; + + // The URL of a forwarding rule with loadBalancingScheme INTERNAL* that is serving the endpoint identified by this service attachment. + optional string producer_forwarding_rule = 247927889; + + // [Output Only] An 128-bit global unique ID of the PSC service attachment. + optional Uint128 psc_service_attachment_id = 527695214; + + // [Output Only] URL of the region where the service attachment resides. This field applies only to the region resource. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // The URL of a service serving the endpoint identified by this service attachment. + optional string target_service = 1293831; + +} + +// Contains a list of ServiceAttachmentsScopedList. +message ServiceAttachmentAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of ServiceAttachmentsScopedList resources. + map items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// [Output Only] A connection connected to this service attachment. +message ServiceAttachmentConnectedEndpoint { + // The status of a connected endpoint to this service attachment. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // The connection has been accepted by the producer. + ACCEPTED = 246714279; + + // The connection has been closed by the producer. + CLOSED = 380163436; + + // The connection has been accepted by the producer, but the producer needs to take further action before the forwarding rule can serve traffic. + NEEDS_ATTENTION = 344491452; + + // The connection is pending acceptance by the producer. + PENDING = 35394935; + + // The consumer is still connected but not using the connection. + REJECTED = 174130302; + + STATUS_UNSPECIFIED = 42133066; + + } + + // The url of a connected endpoint. + optional string endpoint = 130489749; + + // The PSC connection id of the connected endpoint. + optional uint64 psc_connection_id = 292082397; + + // The status of a connected endpoint to this service attachment. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + +} + +// +message ServiceAttachmentConsumerProjectLimit { + // The value of the limit to set. + optional uint32 connection_limit = 131403546; + + // The network URL for the network to set the limit for. + optional string network_url = 207194078; + + // The project id or number for the project to set the limit for. + optional string project_id_or_num = 349783336; + +} + +// +message ServiceAttachmentList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of ServiceAttachment resources. + repeated ServiceAttachment items = 100526016; + + // [Output Only] Type of the resource. Always compute#serviceAttachment for service attachments. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message ServiceAttachmentsScopedList { + // A list of ServiceAttachments contained in this scope. + repeated ServiceAttachment service_attachments = 307136806; + + // Informational warning which replaces the list of service attachments when the list is empty. + optional Warning warning = 50704284; + +} + +// A request message for TargetSslProxies.SetBackendService. See the method description for details. +message SetBackendServiceTargetSslProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetSslProxiesSetBackendServiceRequest target_ssl_proxies_set_backend_service_request_resource = 139080868 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetSslProxy resource whose BackendService resource is to be set. + string target_ssl_proxy = 338795853 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetTcpProxies.SetBackendService. See the method description for details. +message SetBackendServiceTargetTcpProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetTcpProxiesSetBackendServiceRequest target_tcp_proxies_set_backend_service_request_resource = 273721583 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetTcpProxy resource whose BackendService resource is to be set. + string target_tcp_proxy = 503065442 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetPools.SetBackup. See the method description for details. +message SetBackupTargetPoolRequest { + // New failoverRatio value for the target pool. + optional float failover_ratio = 212667006; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetPool resource to set a backup pool for. + string target_pool = 62796298 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TargetReference target_reference_resource = 523721712 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetHttpsProxies.SetCertificateMap. See the method description for details. +message SetCertificateMapTargetHttpsProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetHttpsProxiesSetCertificateMapRequest target_https_proxies_set_certificate_map_request_resource = 467639099 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetHttpsProxy resource whose CertificateMap is to be set. The name must be 1-63 characters long, and comply with RFC1035. + string target_https_proxy = 52336748 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetSslProxies.SetCertificateMap. See the method description for details. +message SetCertificateMapTargetSslProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetSslProxiesSetCertificateMapRequest target_ssl_proxies_set_certificate_map_request_resource = 343984954 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetSslProxy resource whose CertificateMap is to be set. The name must be 1-63 characters long, and comply with RFC1035. + string target_ssl_proxy = 338795853 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Projects.SetCommonInstanceMetadata. See the method description for details. +message SetCommonInstanceMetadataProjectRequest { + // The body resource for this request + Metadata metadata_resource = 291086110 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Projects.SetDefaultNetworkTier. See the method description for details. +message SetDefaultNetworkTierProjectRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The body resource for this request + ProjectsSetDefaultNetworkTierRequest projects_set_default_network_tier_request_resource = 126410762 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Instances.SetDeletionProtection. See the method description for details. +message SetDeletionProtectionInstanceRequest { + // Whether the resource should be protected against deletion. + optional bool deletion_protection = 458014698; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Instances.SetDiskAutoDelete. See the method description for details. +message SetDiskAutoDeleteInstanceRequest { + // Whether to auto-delete the disk when the instance is deleted. + bool auto_delete = 464761403 [(google.api.field_behavior) = REQUIRED]; + + // The device name of the disk to modify. Make a get() request on the instance to view currently attached disks and device names. + string device_name = 67541716 [(google.api.field_behavior) = REQUIRED]; + + // The instance name for this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for BackendBuckets.SetEdgeSecurityPolicy. See the method description for details. +message SetEdgeSecurityPolicyBackendBucketRequest { + // Name of the BackendService resource to which the security policy should be set. The name should conform to RFC1035. + string backend_bucket = 91714037 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + SecurityPolicyReference security_policy_reference_resource = 204135024 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for BackendServices.SetEdgeSecurityPolicy. See the method description for details. +message SetEdgeSecurityPolicyBackendServiceRequest { + // Name of the BackendService resource to which the edge security policy should be set. The name should conform to RFC1035. + string backend_service = 306946058 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + SecurityPolicyReference security_policy_reference_resource = 204135024 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for BackendServices.SetIamPolicy. See the method description for details. +message SetIamPolicyBackendServiceRequest { + // The body resource for this request + GlobalSetPolicyRequest global_set_policy_request_resource = 337048498 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Disks.SetIamPolicy. See the method description for details. +message SetIamPolicyDiskRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + ZoneSetPolicyRequest zone_set_policy_request_resource = 382082107 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for FirewallPolicies.SetIamPolicy. See the method description for details. +message SetIamPolicyFirewallPolicyRequest { + // The body resource for this request + GlobalOrganizationSetPolicyRequest global_organization_set_policy_request_resource = 177408606 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Images.SetIamPolicy. See the method description for details. +message SetIamPolicyImageRequest { + // The body resource for this request + GlobalSetPolicyRequest global_set_policy_request_resource = 337048498 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Instances.SetIamPolicy. See the method description for details. +message SetIamPolicyInstanceRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + ZoneSetPolicyRequest zone_set_policy_request_resource = 382082107 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InstanceTemplates.SetIamPolicy. See the method description for details. +message SetIamPolicyInstanceTemplateRequest { + // The body resource for this request + GlobalSetPolicyRequest global_set_policy_request_resource = 337048498 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Licenses.SetIamPolicy. See the method description for details. +message SetIamPolicyLicenseRequest { + // The body resource for this request + GlobalSetPolicyRequest global_set_policy_request_resource = 337048498 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for MachineImages.SetIamPolicy. See the method description for details. +message SetIamPolicyMachineImageRequest { + // The body resource for this request + GlobalSetPolicyRequest global_set_policy_request_resource = 337048498 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NetworkAttachments.SetIamPolicy. See the method description for details. +message SetIamPolicyNetworkAttachmentRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + RegionSetPolicyRequest region_set_policy_request_resource = 276489091 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NetworkFirewallPolicies.SetIamPolicy. See the method description for details. +message SetIamPolicyNetworkFirewallPolicyRequest { + // The body resource for this request + GlobalSetPolicyRequest global_set_policy_request_resource = 337048498 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NodeGroups.SetIamPolicy. See the method description for details. +message SetIamPolicyNodeGroupRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + ZoneSetPolicyRequest zone_set_policy_request_resource = 382082107 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NodeTemplates.SetIamPolicy. See the method description for details. +message SetIamPolicyNodeTemplateRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + RegionSetPolicyRequest region_set_policy_request_resource = 276489091 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionBackendServices.SetIamPolicy. See the method description for details. +message SetIamPolicyRegionBackendServiceRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + RegionSetPolicyRequest region_set_policy_request_resource = 276489091 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionDisks.SetIamPolicy. See the method description for details. +message SetIamPolicyRegionDiskRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + RegionSetPolicyRequest region_set_policy_request_resource = 276489091 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionNetworkFirewallPolicies.SetIamPolicy. See the method description for details. +message SetIamPolicyRegionNetworkFirewallPolicyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + RegionSetPolicyRequest region_set_policy_request_resource = 276489091 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Reservations.SetIamPolicy. See the method description for details. +message SetIamPolicyReservationRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + ZoneSetPolicyRequest zone_set_policy_request_resource = 382082107 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ResourcePolicies.SetIamPolicy. See the method description for details. +message SetIamPolicyResourcePolicyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + RegionSetPolicyRequest region_set_policy_request_resource = 276489091 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ServiceAttachments.SetIamPolicy. See the method description for details. +message SetIamPolicyServiceAttachmentRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + RegionSetPolicyRequest region_set_policy_request_resource = 276489091 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Snapshots.SetIamPolicy. See the method description for details. +message SetIamPolicySnapshotRequest { + // The body resource for this request + GlobalSetPolicyRequest global_set_policy_request_resource = 337048498 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Subnetworks.SetIamPolicy. See the method description for details. +message SetIamPolicySubnetworkRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + RegionSetPolicyRequest region_set_policy_request_resource = 276489091 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InstanceGroupManagers.SetInstanceTemplate. See the method description for details. +message SetInstanceTemplateInstanceGroupManagerRequest { + // The name of the managed instance group. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstanceGroupManagersSetInstanceTemplateRequest instance_group_managers_set_instance_template_request_resource = 9809093 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where the managed instance group is located. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for RegionInstanceGroupManagers.SetInstanceTemplate. See the method description for details. +message SetInstanceTemplateRegionInstanceGroupManagerRequest { + // The name of the managed instance group. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionInstanceGroupManagersSetTemplateRequest region_instance_group_managers_set_template_request_resource = 187310412 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Addresses.SetLabels. See the method description for details. +message SetLabelsAddressRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionSetLabelsRequest region_set_labels_request_resource = 259357782 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Disks.SetLabels. See the method description for details. +message SetLabelsDiskRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + + // The body resource for this request + ZoneSetLabelsRequest zone_set_labels_request_resource = 364950798 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ExternalVpnGateways.SetLabels. See the method description for details. +message SetLabelsExternalVpnGatewayRequest { + // The body resource for this request + GlobalSetLabelsRequest global_set_labels_request_resource = 319917189 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ForwardingRules.SetLabels. See the method description for details. +message SetLabelsForwardingRuleRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionSetLabelsRequest region_set_labels_request_resource = 259357782 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for GlobalAddresses.SetLabels. See the method description for details. +message SetLabelsGlobalAddressRequest { + // The body resource for this request + GlobalSetLabelsRequest global_set_labels_request_resource = 319917189 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for GlobalForwardingRules.SetLabels. See the method description for details. +message SetLabelsGlobalForwardingRuleRequest { + // The body resource for this request + GlobalSetLabelsRequest global_set_labels_request_resource = 319917189 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Images.SetLabels. See the method description for details. +message SetLabelsImageRequest { + // The body resource for this request + GlobalSetLabelsRequest global_set_labels_request_resource = 319917189 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Instances.SetLabels. See the method description for details. +message SetLabelsInstanceRequest { + // Name of the instance scoping this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstancesSetLabelsRequest instances_set_labels_request_resource = 207749344 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for InterconnectAttachments.SetLabels. See the method description for details. +message SetLabelsInterconnectAttachmentRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionSetLabelsRequest region_set_labels_request_resource = 259357782 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Interconnects.SetLabels. See the method description for details. +message SetLabelsInterconnectRequest { + // The body resource for this request + GlobalSetLabelsRequest global_set_labels_request_resource = 319917189 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionDisks.SetLabels. See the method description for details. +message SetLabelsRegionDiskRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionSetLabelsRequest region_set_labels_request_resource = 259357782 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for SecurityPolicies.SetLabels. See the method description for details. +message SetLabelsSecurityPolicyRequest { + // The body resource for this request + GlobalSetLabelsRequest global_set_labels_request_resource = 319917189 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Snapshots.SetLabels. See the method description for details. +message SetLabelsSnapshotRequest { + // The body resource for this request + GlobalSetLabelsRequest global_set_labels_request_resource = 319917189 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetVpnGateways.SetLabels. See the method description for details. +message SetLabelsTargetVpnGatewayRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionSetLabelsRequest region_set_labels_request_resource = 259357782 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for VpnGateways.SetLabels. See the method description for details. +message SetLabelsVpnGatewayRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionSetLabelsRequest region_set_labels_request_resource = 259357782 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for VpnTunnels.SetLabels. See the method description for details. +message SetLabelsVpnTunnelRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionSetLabelsRequest region_set_labels_request_resource = 259357782 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Instances.SetMachineResources. See the method description for details. +message SetMachineResourcesInstanceRequest { + // Name of the instance scoping this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstancesSetMachineResourcesRequest instances_set_machine_resources_request_resource = 196286318 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Instances.SetMachineType. See the method description for details. +message SetMachineTypeInstanceRequest { + // Name of the instance scoping this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstancesSetMachineTypeRequest instances_set_machine_type_request_resource = 254157709 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Instances.SetMetadata. See the method description for details. +message SetMetadataInstanceRequest { + // Name of the instance scoping this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + Metadata metadata_resource = 291086110 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Instances.SetMinCpuPlatform. See the method description for details. +message SetMinCpuPlatformInstanceRequest { + // Name of the instance scoping this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstancesSetMinCpuPlatformRequest instances_set_min_cpu_platform_request_resource = 148459368 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Instances.SetName. See the method description for details. +message SetNameInstanceRequest { + // The instance name for this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstancesSetNameRequest instances_set_name_request_resource = 272080980 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for InstanceGroups.SetNamedPorts. See the method description for details. +message SetNamedPortsInstanceGroupRequest { + // The name of the instance group where the named ports are updated. + string instance_group = 81095253 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstanceGroupsSetNamedPortsRequest instance_groups_set_named_ports_request_resource = 385151535 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where the instance group is located. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for RegionInstanceGroups.SetNamedPorts. See the method description for details. +message SetNamedPortsRegionInstanceGroupRequest { + // The name of the regional instance group where the named ports are updated. + string instance_group = 81095253 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionInstanceGroupsSetNamedPortsRequest region_instance_groups_set_named_ports_request_resource = 1574938 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for NodeGroups.SetNodeTemplate. See the method description for details. +message SetNodeTemplateNodeGroupRequest { + // Name of the NodeGroup resource to update. + string node_group = 469958146 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + NodeGroupsSetNodeTemplateRequest node_groups_set_node_template_request_resource = 117382321 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Subnetworks.SetPrivateIpGoogleAccess. See the method description for details. +message SetPrivateIpGoogleAccessSubnetworkRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the Subnetwork resource. + string subnetwork = 307827694 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + SubnetworksSetPrivateIpGoogleAccessRequest subnetworks_set_private_ip_google_access_request_resource = 268920696 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetSslProxies.SetProxyHeader. See the method description for details. +message SetProxyHeaderTargetSslProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetSslProxiesSetProxyHeaderRequest target_ssl_proxies_set_proxy_header_request_resource = 205284526 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetSslProxy resource whose ProxyHeader is to be set. + string target_ssl_proxy = 338795853 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetTcpProxies.SetProxyHeader. See the method description for details. +message SetProxyHeaderTargetTcpProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetTcpProxiesSetProxyHeaderRequest target_tcp_proxies_set_proxy_header_request_resource = 219958339 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetTcpProxy resource whose ProxyHeader is to be set. + string target_tcp_proxy = 503065442 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetHttpsProxies.SetQuicOverride. See the method description for details. +message SetQuicOverrideTargetHttpsProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetHttpsProxiesSetQuicOverrideRequest target_https_proxies_set_quic_override_request_resource = 72940258 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetHttpsProxy resource to set the QUIC override policy for. The name should conform to RFC1035. + string target_https_proxy = 52336748 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Instances.SetScheduling. See the method description for details. +message SetSchedulingInstanceRequest { + // Instance name for this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + Scheduling scheduling_resource = 463181401 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for BackendServices.SetSecurityPolicy. See the method description for details. +message SetSecurityPolicyBackendServiceRequest { + // Name of the BackendService resource to which the security policy should be set. The name should conform to RFC1035. + string backend_service = 306946058 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + SecurityPolicyReference security_policy_reference_resource = 204135024 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Instances.SetServiceAccount. See the method description for details. +message SetServiceAccountInstanceRequest { + // Name of the instance resource to start. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstancesSetServiceAccountRequest instances_set_service_account_request_resource = 275550008 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Instances.SetShieldedInstanceIntegrityPolicy. See the method description for details. +message SetShieldedInstanceIntegrityPolicyInstanceRequest { + // Name or id of the instance scoping this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + ShieldedInstanceIntegrityPolicy shielded_instance_integrity_policy_resource = 409169462 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for RegionTargetHttpsProxies.SetSslCertificates. See the method description for details. +message SetSslCertificatesRegionTargetHttpsProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionTargetHttpsProxiesSetSslCertificatesRequest region_target_https_proxies_set_ssl_certificates_request_resource = 390693383 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetHttpsProxy resource to set an SslCertificates resource for. + string target_https_proxy = 52336748 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetHttpsProxies.SetSslCertificates. See the method description for details. +message SetSslCertificatesTargetHttpsProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetHttpsProxiesSetSslCertificatesRequest target_https_proxies_set_ssl_certificates_request_resource = 223122908 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetHttpsProxy resource to set an SslCertificates resource for. + string target_https_proxy = 52336748 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetSslProxies.SetSslCertificates. See the method description for details. +message SetSslCertificatesTargetSslProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetSslProxiesSetSslCertificatesRequest target_ssl_proxies_set_ssl_certificates_request_resource = 147940797 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetSslProxy resource whose SslCertificate resource is to be set. + string target_ssl_proxy = 338795853 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetHttpsProxies.SetSslPolicy. See the method description for details. +message SetSslPolicyTargetHttpsProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + SslPolicyReference ssl_policy_reference_resource = 235403836 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetHttpsProxy resource whose SSL policy is to be set. The name must be 1-63 characters long, and comply with RFC1035. + string target_https_proxy = 52336748 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetSslProxies.SetSslPolicy. See the method description for details. +message SetSslPolicyTargetSslProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + SslPolicyReference ssl_policy_reference_resource = 235403836 [(google.api.field_behavior) = REQUIRED]; + + // Name of the TargetSslProxy resource whose SSL policy is to be set. The name must be 1-63 characters long, and comply with RFC1035. + string target_ssl_proxy = 338795853 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Instances.SetTags. See the method description for details. +message SetTagsInstanceRequest { + // Name of the instance scoping this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + Tags tags_resource = 331435380 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for ForwardingRules.SetTarget. See the method description for details. +message SetTargetForwardingRuleRequest { + // Name of the ForwardingRule resource in which target is to be set. + string forwarding_rule = 269964030 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetReference target_reference_resource = 523721712 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for GlobalForwardingRules.SetTarget. See the method description for details. +message SetTargetGlobalForwardingRuleRequest { + // Name of the ForwardingRule resource in which target is to be set. + string forwarding_rule = 269964030 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + TargetReference target_reference_resource = 523721712 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InstanceGroupManagers.SetTargetPools. See the method description for details. +message SetTargetPoolsInstanceGroupManagerRequest { + // The name of the managed instance group. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstanceGroupManagersSetTargetPoolsRequest instance_group_managers_set_target_pools_request_resource = 281150216 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where the managed instance group is located. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for RegionInstanceGroupManagers.SetTargetPools. See the method description for details. +message SetTargetPoolsRegionInstanceGroupManagerRequest { + // Name of the managed instance group. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionInstanceGroupManagersSetTargetPoolsRequest region_instance_group_managers_set_target_pools_request_resource = 78734717 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionTargetHttpProxies.SetUrlMap. See the method description for details. +message SetUrlMapRegionTargetHttpProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetHttpProxy to set a URL map for. + string target_http_proxy = 206872421 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + UrlMapReference url_map_reference_resource = 398701333 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionTargetHttpsProxies.SetUrlMap. See the method description for details. +message SetUrlMapRegionTargetHttpsProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetHttpsProxy to set a URL map for. + string target_https_proxy = 52336748 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + UrlMapReference url_map_reference_resource = 398701333 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetHttpProxies.SetUrlMap. See the method description for details. +message SetUrlMapTargetHttpProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetHttpProxy to set a URL map for. + string target_http_proxy = 206872421 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + UrlMapReference url_map_reference_resource = 398701333 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for TargetHttpsProxies.SetUrlMap. See the method description for details. +message SetUrlMapTargetHttpsProxyRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the TargetHttpsProxy resource whose URL map is to be set. + string target_https_proxy = 52336748 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + UrlMapReference url_map_reference_resource = 398701333 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Projects.SetUsageExportBucket. See the method description for details. +message SetUsageExportBucketProjectRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + UsageExportLocation usage_export_location_resource = 20260459 [(google.api.field_behavior) = REQUIRED]; + +} + +// The share setting for reservations and sole tenancy node groups. +message ShareSettings { + // Type of sharing for this shared-reservation + enum ShareType { + // A value indicating that the enum field is not set. + UNDEFINED_SHARE_TYPE = 0; + + // Default value. + LOCAL = 72607563; + + // Shared-reservation is open to entire Organization + ORGANIZATION = 274978099; + + // Default value. This value is unused. + SHARE_TYPE_UNSPECIFIED = 494771730; + + // Shared-reservation is open to specific projects + SPECIFIC_PROJECTS = 347838695; + + } + + // A map of project id and project config. This is only valid when share_type's value is SPECIFIC_PROJECTS. + map project_map = 134212406; + + // Type of sharing for this shared-reservation + // Check the ShareType enum for the list of possible values. + optional string share_type = 359533466; + +} + +// Config for each project in the share settings. +message ShareSettingsProjectConfig { + // The project ID, should be same as the key of this project config in the parent map. + optional string project_id = 177513473; + +} + +// A set of Shielded Instance options. +message ShieldedInstanceConfig { + // Defines whether the instance has integrity monitoring enabled. Enabled by default. + optional bool enable_integrity_monitoring = 409071030; + + // Defines whether the instance has Secure Boot enabled. Disabled by default. + optional bool enable_secure_boot = 123568638; + + // Defines whether the instance has the vTPM enabled. Enabled by default. + optional bool enable_vtpm = 181858935; + +} + +// A Shielded Instance Identity. +message ShieldedInstanceIdentity { + // An Endorsement Key (EK) made by the RSA 2048 algorithm issued to the Shielded Instance's vTPM. + optional ShieldedInstanceIdentityEntry encryption_key = 488268707; + + // [Output Only] Type of the resource. Always compute#shieldedInstanceIdentity for shielded Instance identity entry. + optional string kind = 3292052; + + // An Attestation Key (AK) made by the RSA 2048 algorithm issued to the Shielded Instance's vTPM. + optional ShieldedInstanceIdentityEntry signing_key = 320948261; + +} + +// A Shielded Instance Identity Entry. +message ShieldedInstanceIdentityEntry { + // A PEM-encoded X.509 certificate. This field can be empty. + optional string ek_cert = 450178589; + + // A PEM-encoded public key. + optional string ek_pub = 308947940; + +} + +// The policy describes the baseline against which Instance boot integrity is measured. +message ShieldedInstanceIntegrityPolicy { + // Updates the integrity policy baseline using the measurements from the VM instance's most recent boot. + optional bool update_auto_learn_policy = 245490215; + +} + +// Represents a customer-supplied Signing Key used by Cloud CDN Signed URLs +message SignedUrlKey { + // Name of the key. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string key_name = 500938859; + + // 128-bit key value used for signing the URL. The key value must be a valid RFC 4648 Section 5 base64url encoded string. + optional string key_value = 504106897; + +} + +// A request message for Instances.SimulateMaintenanceEvent. See the method description for details. +message SimulateMaintenanceEventInstanceRequest { + // Name of the instance scoping this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for NodeGroups.SimulateMaintenanceEvent. See the method description for details. +message SimulateMaintenanceEventNodeGroupRequest { + // Name of the NodeGroup resource whose nodes will go under maintenance simulation. + string node_group = 469958146 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + NodeGroupsSimulateMaintenanceEventRequest node_groups_simulate_maintenance_event_request_resource = 351468764 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// Represents a Persistent Disk Snapshot resource. You can use snapshots to back up data on a regular interval. For more information, read Creating persistent disk snapshots. +message Snapshot { + // [Output Only] The architecture of the snapshot. Valid values are ARM64 or X86_64. + enum Architecture { + // A value indicating that the enum field is not set. + UNDEFINED_ARCHITECTURE = 0; + + // Default value indicating Architecture is not set. + ARCHITECTURE_UNSPECIFIED = 394750507; + + // Machines with architecture ARM64 + ARM64 = 62547450; + + // Machines with architecture X86_64 + X86_64 = 425300551; + + } + + // Indicates the type of the snapshot. + enum SnapshotType { + // A value indicating that the enum field is not set. + UNDEFINED_SNAPSHOT_TYPE = 0; + + ARCHIVE = 506752162; + + STANDARD = 484642493; + + } + + // [Output Only] The status of the snapshot. This can be CREATING, DELETING, FAILED, READY, or UPLOADING. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // Snapshot creation is in progress. + CREATING = 455564985; + + // Snapshot is currently being deleted. + DELETING = 528602024; + + // Snapshot creation failed. + FAILED = 455706685; + + // Snapshot has been created successfully. + READY = 77848963; + + // Snapshot is being uploaded. + UPLOADING = 267603489; + + } + + // [Output Only] An indicator whether storageBytes is in a stable state or it is being adjusted as a result of shared storage reallocation. This status can either be UPDATING, meaning the size of the snapshot is being updated, or UP_TO_DATE, meaning the size of the snapshot is up-to-date. + enum StorageBytesStatus { + // A value indicating that the enum field is not set. + UNDEFINED_STORAGE_BYTES_STATUS = 0; + + UPDATING = 494614342; + + UP_TO_DATE = 101306702; + + } + + // [Output Only] The architecture of the snapshot. Valid values are ARM64 or X86_64. + // Check the Architecture enum for the list of possible values. + optional string architecture = 302803283; + + // [Output Only] Set to true if snapshots are automatically created by applying resource policy on the target disk. + optional bool auto_created = 463922264; + + // Creates the new snapshot in the snapshot chain labeled with the specified name. The chain name must be 1-63 characters long and comply with RFC1035. This is an uncommon option only for advanced service owners who needs to create separate snapshot chains, for example, for chargeback tracking. When you describe your snapshot resource, this field is visible only if it has a non-empty value. + optional string chain_name = 68644169; + + // [Output Only] Size in bytes of the snapshot at creation time. + optional int64 creation_size_bytes = 125400077; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] Size of the source disk, specified in GB. + optional int64 disk_size_gb = 316263735; + + // [Output Only] Number of bytes downloaded to restore a snapshot to a disk. + optional int64 download_bytes = 435054068; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#snapshot for Snapshot resources. + optional string kind = 3292052; + + // A fingerprint for the labels being applied to this snapshot, which is essentially a hash of the labels set used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update labels. You must always provide an up-to-date fingerprint hash in order to update or change labels, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve a snapshot. + optional string label_fingerprint = 178124825; + + // Labels to apply to this snapshot. These can be later modified by the setLabels method. Label values may be empty. + map labels = 500195327; + + // [Output Only] Integer license codes indicating which licenses are attached to this snapshot. + repeated int64 license_codes = 45482664; + + // [Output Only] A list of public visible licenses that apply to this snapshot. This can be because the original image had licenses attached (such as a Windows image). + repeated string licenses = 337642578; + + // An opaque location hint used to place the snapshot close to other resources. This field is for use by internal tools that use the public API. + optional string location_hint = 350519505; + + // Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // [Output Only] Reserved for future use. + optional bool satisfies_pzs = 480964267; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // Encrypts the snapshot using a customer-supplied encryption key. After you encrypt a snapshot using a customer-supplied key, you must provide the same key if you use the snapshot later. For example, you must provide the encryption key when you create a disk from the encrypted snapshot in a future request. Customer-supplied encryption keys do not protect access to metadata of the snapshot. If you do not provide an encryption key when creating the snapshot, then the snapshot will be encrypted using an automatically generated key and you do not need to provide a key to use the snapshot later. + optional CustomerEncryptionKey snapshot_encryption_key = 43334526; + + // Indicates the type of the snapshot. + // Check the SnapshotType enum for the list of possible values. + optional string snapshot_type = 124349653; + + // The source disk used to create this snapshot. + optional string source_disk = 451753793; + + // The customer-supplied encryption key of the source disk. Required if the source disk is protected by a customer-supplied encryption key. + optional CustomerEncryptionKey source_disk_encryption_key = 531501153; + + // [Output Only] The ID value of the disk used to create this snapshot. This value may be used to determine whether the snapshot was taken from the current or a previous instance of a given disk name. + optional string source_disk_id = 454190809; + + // [Output Only] URL of the resource policy which created this scheduled snapshot. + optional string source_snapshot_schedule_policy = 235756291; + + // [Output Only] ID of the resource policy which created this scheduled snapshot. + optional string source_snapshot_schedule_policy_id = 70489047; + + // [Output Only] The status of the snapshot. This can be CREATING, DELETING, FAILED, READY, or UPLOADING. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // [Output Only] A size of the storage used by the snapshot. As snapshots share storage, this number is expected to change with snapshot creation/deletion. + optional int64 storage_bytes = 424631719; + + // [Output Only] An indicator whether storageBytes is in a stable state or it is being adjusted as a result of shared storage reallocation. This status can either be UPDATING, meaning the size of the snapshot is being updated, or UP_TO_DATE, meaning the size of the snapshot is up-to-date. + // Check the StorageBytesStatus enum for the list of possible values. + optional string storage_bytes_status = 490739082; + + // Cloud Storage bucket storage location of the snapshot (regional or multi-regional). + repeated string storage_locations = 328005274; + +} + +// Contains a list of Snapshot resources. +message SnapshotList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Snapshot resources. + repeated Snapshot items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message SourceDiskEncryptionKey { + // The customer-supplied encryption key of the source disk. Required if the source disk is protected by a customer-supplied encryption key. + optional CustomerEncryptionKey disk_encryption_key = 271660677; + + // URL of the disk attached to the source instance. This can be a full or valid partial URL. For example, the following are valid values: - https://www.googleapis.com/compute/v1/projects/project/zones/zone /disks/disk - projects/project/zones/zone/disks/disk - zones/zone/disks/disk + optional string source_disk = 451753793; + +} + +// A specification of the parameters to use when creating the instance template from a source instance. +message SourceInstanceParams { + // Attached disks configuration. If not provided, defaults are applied: For boot disk and any other R/W disks, the source images for each disk will be used. For read-only disks, they will be attached in read-only mode. Local SSD disks will be created as blank volumes. + repeated DiskInstantiationConfig disk_configs = 235580623; + +} + +// DEPRECATED: Please use compute#instanceProperties instead. New properties will not be added to this field. +message SourceInstanceProperties { + // KeyRevocationActionType of the instance. Supported options are "STOP" and "NONE". The default value is "NONE" if it is not specified. + enum KeyRevocationActionType { + // A value indicating that the enum field is not set. + UNDEFINED_KEY_REVOCATION_ACTION_TYPE = 0; + + // Default value. This value is unused. + KEY_REVOCATION_ACTION_TYPE_UNSPECIFIED = 467110106; + + // Indicates user chose no operation. + NONE = 2402104; + + // Indicates user chose to opt for VM shutdown on key revocation. + STOP = 2555906; + + } + + // Enables instances created based on this machine image to send packets with source IP addresses other than their own and receive packets with destination IP addresses other than their own. If these instances will be used as an IP gateway or it will be set as the next-hop in a Route resource, specify true. If unsure, leave this set to false. See the Enable IP forwarding documentation for more information. + optional bool can_ip_forward = 467731324; + + // Whether the instance created from this machine image should be protected against deletion. + optional bool deletion_protection = 458014698; + + // An optional text description for the instances that are created from this machine image. + optional string description = 422937596; + + // An array of disks that are associated with the instances that are created from this machine image. + repeated SavedAttachedDisk disks = 95594102; + + // A list of guest accelerator cards' type and count to use for instances created from this machine image. + repeated AcceleratorConfig guest_accelerators = 463595119; + + // KeyRevocationActionType of the instance. Supported options are "STOP" and "NONE". The default value is "NONE" if it is not specified. + // Check the KeyRevocationActionType enum for the list of possible values. + optional string key_revocation_action_type = 235941474; + + // Labels to apply to instances that are created from this machine image. + map labels = 500195327; + + // The machine type to use for instances that are created from this machine image. + optional string machine_type = 227711026; + + // The metadata key/value pairs to assign to instances that are created from this machine image. These pairs can consist of custom metadata or predefined keys. See Project and instance metadata for more information. + optional Metadata metadata = 86866735; + + // Minimum cpu/platform to be used by instances created from this machine image. The instance may be scheduled on the specified or newer cpu/platform. Applicable values are the friendly names of CPU platforms, such as minCpuPlatform: "Intel Haswell" or minCpuPlatform: "Intel Sandy Bridge". For more information, read Specifying a Minimum CPU Platform. + optional string min_cpu_platform = 242912759; + + // An array of network access configurations for this interface. + repeated NetworkInterface network_interfaces = 52735243; + + // Specifies the scheduling options for the instances that are created from this machine image. + optional Scheduling scheduling = 386688404; + + // A list of service accounts with specified scopes. Access tokens for these service accounts are available to the instances that are created from this machine image. Use metadata queries to obtain the access tokens for these instances. + repeated ServiceAccount service_accounts = 277537328; + + // A list of tags to apply to the instances that are created from this machine image. The tags identify valid sources or targets for network firewalls. The setTags method can modify this list of tags. Each tag within the list must comply with RFC1035. + optional Tags tags = 3552281; + +} + +// Represents an SSL Certificate resource. Google Compute Engine has two SSL Certificate resources: * [Global](/compute/docs/reference/rest/v1/sslCertificates) * [Regional](/compute/docs/reference/rest/v1/regionSslCertificates) The sslCertificates are used by: - external HTTPS load balancers - SSL proxy load balancers The regionSslCertificates are used by internal HTTPS load balancers. Optionally, certificate file contents that you upload can contain a set of up to five PEM-encoded certificates. The API call creates an object (sslCertificate) that holds this data. You can use SSL keys and certificates to secure connections to a load balancer. For more information, read Creating and using SSL certificates, SSL certificates quotas and limits, and Troubleshooting SSL certificates. +message SslCertificate { + // (Optional) Specifies the type of SSL certificate, either "SELF_MANAGED" or "MANAGED". If not specified, the certificate is self-managed and the fields certificate and private_key are used. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + // Google-managed SSLCertificate. + MANAGED = 479501183; + + // Certificate uploaded by user. + SELF_MANAGED = 434437516; + + TYPE_UNSPECIFIED = 437714322; + + } + + // A value read into memory from a certificate file. The certificate file must be in PEM format. The certificate chain must be no greater than 5 certs long. The chain must include at least one intermediate cert. + optional string certificate = 341787031; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] Expire time of the certificate. RFC3339 + optional string expire_time = 440691181; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#sslCertificate for SSL certificates. + optional string kind = 3292052; + + // Configuration and status of a managed SSL certificate. + optional SslCertificateManagedSslCertificate managed = 298389407; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // A value read into memory from a write-only private key file. The private key file must be in PEM format. For security, only insert requests include this field. + optional string private_key = 361331107; + + // [Output Only] URL of the region where the regional SSL Certificate resides. This field is not applicable to global SSL Certificate. + optional string region = 138946292; + + // [Output only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // Configuration and status of a self-managed SSL certificate. + optional SslCertificateSelfManagedSslCertificate self_managed = 329284012; + + // [Output Only] Domains associated with the certificate via Subject Alternative Name. + repeated string subject_alternative_names = 528807907; + + // (Optional) Specifies the type of SSL certificate, either "SELF_MANAGED" or "MANAGED". If not specified, the certificate is self-managed and the fields certificate and private_key are used. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// +message SslCertificateAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of SslCertificatesScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#sslCertificateAggregatedList for lists of SSL Certificates. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of SslCertificate resources. +message SslCertificateList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of SslCertificate resources. + repeated SslCertificate items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Configuration and status of a managed SSL certificate. +message SslCertificateManagedSslCertificate { + // [Output only] Status of the managed certificate resource. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // The certificate management is working, and a certificate has been provisioned. + ACTIVE = 314733318; + + MANAGED_CERTIFICATE_STATUS_UNSPECIFIED = 474800850; + + // The certificate management is working. GCP will attempt to provision the first certificate. + PROVISIONING = 290896621; + + // Certificate provisioning failed due to an issue with the DNS or load balancing configuration. For details of which domain failed, consult domain_status field. + PROVISIONING_FAILED = 76813775; + + // Certificate provisioning failed due to an issue with the DNS or load balancing configuration. It won't be retried. To try again delete and create a new managed SslCertificate resource. For details of which domain failed, consult domain_status field. + PROVISIONING_FAILED_PERMANENTLY = 275036203; + + // Renewal of the certificate has failed due to an issue with the DNS or load balancing configuration. The existing cert is still serving; however, it will expire shortly. To provision a renewed certificate, delete and create a new managed SslCertificate resource. For details on which domain failed, consult domain_status field. + RENEWAL_FAILED = 434659076; + + } + + // [Output only] Detailed statuses of the domains specified for managed certificate resource. + map domain_status = 360305613; + + // The domains for which a managed SSL certificate will be generated. Each Google-managed SSL certificate supports up to the [maximum number of domains per Google-managed SSL certificate](/load-balancing/docs/quotas#ssl_certificates). + repeated string domains = 226935855; + + // [Output only] Status of the managed certificate resource. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + +} + +// Configuration and status of a self-managed SSL certificate. +message SslCertificateSelfManagedSslCertificate { + // A local certificate file. The certificate must be in PEM format. The certificate chain must be no greater than 5 certs long. The chain must include at least one intermediate cert. + optional string certificate = 341787031; + + // A write-only private key in PEM format. Only insert requests will include this field. + optional string private_key = 361331107; + +} + +// +message SslCertificatesScopedList { + // List of SslCertificates contained in this scope. + repeated SslCertificate ssl_certificates = 366006543; + + // Informational warning which replaces the list of backend services when the list is empty. + optional Warning warning = 50704284; + +} + +// +message SslPoliciesAggregatedList { + optional string etag = 3123477; + + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of SslPoliciesScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#sslPolicyAggregatedList for lists of SSL Policies. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message SslPoliciesList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of SslPolicy resources. + repeated SslPolicy items = 100526016; + + // [Output Only] Type of the resource. Always compute#sslPoliciesList for lists of sslPolicies. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message SslPoliciesListAvailableFeaturesResponse { + repeated string features = 246211645; + +} + +// +message SslPoliciesScopedList { + // A list of SslPolicies contained in this scope. + repeated SslPolicy ssl_policies = 209941027; + + // Informational warning which replaces the list of SSL policies when the list is empty. + optional Warning warning = 50704284; + +} + +// Represents an SSL Policy resource. Use SSL policies to control the SSL features, such as versions and cipher suites, offered by an HTTPS or SSL Proxy load balancer. For more information, read SSL Policy Concepts. +message SslPolicy { + // The minimum version of SSL protocol that can be used by the clients to establish a connection with the load balancer. This can be one of TLS_1_0, TLS_1_1, TLS_1_2. + enum MinTlsVersion { + // A value indicating that the enum field is not set. + UNDEFINED_MIN_TLS_VERSION = 0; + + // TLS 1.0 + TLS_1_0 = 33116734; + + // TLS 1.1 + TLS_1_1 = 33116735; + + // TLS 1.2 + TLS_1_2 = 33116736; + + } + + // Profile specifies the set of SSL features that can be used by the load balancer when negotiating SSL with clients. This can be one of COMPATIBLE, MODERN, RESTRICTED, or CUSTOM. If using CUSTOM, the set of SSL features to enable must be specified in the customFeatures field. + enum Profile { + // A value indicating that the enum field is not set. + UNDEFINED_PROFILE = 0; + + // Compatible profile. Allows the broadset set of clients, even those which support only out-of-date SSL features to negotiate with the load balancer. + COMPATIBLE = 179357396; + + // Custom profile. Allow only the set of allowed SSL features specified in the customFeatures field. + CUSTOM = 388595569; + + // Modern profile. Supports a wide set of SSL features, allowing modern clients to negotiate SSL with the load balancer. + MODERN = 132013855; + + // Restricted profile. Supports a reduced set of SSL features, intended to meet stricter compliance requirements. + RESTRICTED = 261551195; + + } + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // A list of features enabled when the selected profile is CUSTOM. The method returns the set of features that can be specified in this list. This field must be empty if the profile is not CUSTOM. + repeated string custom_features = 34789707; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] The list of features enabled in the SSL policy. + repeated string enabled_features = 469017467; + + // Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a SslPolicy. An up-to-date fingerprint must be provided in order to update the SslPolicy, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve an SslPolicy. + optional string fingerprint = 234678500; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output only] Type of the resource. Always compute#sslPolicyfor SSL policies. + optional string kind = 3292052; + + // The minimum version of SSL protocol that can be used by the clients to establish a connection with the load balancer. This can be one of TLS_1_0, TLS_1_1, TLS_1_2. + // Check the MinTlsVersion enum for the list of possible values. + optional string min_tls_version = 8155943; + + // Name of the resource. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // Profile specifies the set of SSL features that can be used by the load balancer when negotiating SSL with clients. This can be one of COMPATIBLE, MODERN, RESTRICTED, or CUSTOM. If using CUSTOM, the set of SSL features to enable must be specified in the customFeatures field. + // Check the Profile enum for the list of possible values. + optional string profile = 227445161; + + // [Output Only] URL of the region where the regional SSL policy resides. This field is not applicable to global SSL policies. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] If potential misconfigurations are detected for this SSL policy, this field will be populated with warning messages. + repeated Warnings warnings = 498091095; + +} + +// +message SslPolicyReference { + // URL of the SSL policy resource. Set this to empty string to clear any existing SSL policy associated with the target proxy resource. + optional string ssl_policy = 295190213; + +} + +// A request message for Instances.Start. See the method description for details. +message StartInstanceRequest { + // Name of the instance resource to start. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Instances.StartWithEncryptionKey. See the method description for details. +message StartWithEncryptionKeyInstanceRequest { + // Name of the instance resource to start. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstancesStartWithEncryptionKeyRequest instances_start_with_encryption_key_request_resource = 441712511 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// +message StatefulPolicy { + optional StatefulPolicyPreservedState preserved_state = 2634026; + +} + +// Configuration of preserved resources. +message StatefulPolicyPreservedState { + // Disks created on the instances that will be preserved on instance delete, update, etc. This map is keyed with the device names of the disks. + map disks = 95594102; + +} + +// +message StatefulPolicyPreservedStateDiskDevice { + // These stateful disks will never be deleted during autohealing, update or VM instance recreate operations. This flag is used to configure if the disk should be deleted after it is no longer used by the group, e.g. when the given instance or the whole group is deleted. Note: disks attached in READ_ONLY mode cannot be auto-deleted. + enum AutoDelete { + // A value indicating that the enum field is not set. + UNDEFINED_AUTO_DELETE = 0; + + NEVER = 74175084; + + ON_PERMANENT_INSTANCE_DELETION = 95727719; + + } + + // These stateful disks will never be deleted during autohealing, update or VM instance recreate operations. This flag is used to configure if the disk should be deleted after it is no longer used by the group, e.g. when the given instance or the whole group is deleted. Note: disks attached in READ_ONLY mode cannot be auto-deleted. + // Check the AutoDelete enum for the list of possible values. + optional string auto_delete = 464761403; + +} + +// A request message for Instances.Stop. See the method description for details. +message StopInstanceRequest { + // If true, discard the contents of any attached localSSD partitions. Default value is false. + optional bool discard_local_ssd = 319517903; + + // Name of the instance resource to stop. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// Represents a Subnetwork resource. A subnetwork (also known as a subnet) is a logical partition of a Virtual Private Cloud network with one primary IP range and zero or more secondary IP ranges. For more information, read Virtual Private Cloud (VPC) Network. +message Subnetwork { + // The access type of IPv6 address this subnet holds. It's immutable and can only be specified during creation or the first time the subnet is updated into IPV4_IPV6 dual stack. + enum Ipv6AccessType { + // A value indicating that the enum field is not set. + UNDEFINED_IPV6_ACCESS_TYPE = 0; + + // VMs on this subnet will be assigned IPv6 addresses that are accessible via the Internet, as well as the VPC network. + EXTERNAL = 35607499; + + // VMs on this subnet will be assigned IPv6 addresses that are only accessible over the VPC network. + INTERNAL = 279295677; + + UNSPECIFIED_IPV6_ACCESS_TYPE = 313080613; + + } + + // This field is for internal use. This field can be both set at resource creation time and updated using patch. + enum PrivateIpv6GoogleAccess { + // A value indicating that the enum field is not set. + UNDEFINED_PRIVATE_IPV6_GOOGLE_ACCESS = 0; + + // Disable private IPv6 access to/from Google services. + DISABLE_GOOGLE_ACCESS = 450958579; + + // Bidirectional private IPv6 access to/from Google services. + ENABLE_BIDIRECTIONAL_ACCESS_TO_GOOGLE = 427975994; + + // Outbound private IPv6 access from VMs in this subnet to Google services. + ENABLE_OUTBOUND_VM_ACCESS_TO_GOOGLE = 288210263; + + } + + // The purpose of the resource. This field can be either PRIVATE_RFC_1918 or INTERNAL_HTTPS_LOAD_BALANCER. A subnetwork with purpose set to INTERNAL_HTTPS_LOAD_BALANCER is a user-created subnetwork that is reserved for Internal HTTP(S) Load Balancing. If unspecified, the purpose defaults to PRIVATE_RFC_1918. The enableFlowLogs field isn't supported with the purpose field set to INTERNAL_HTTPS_LOAD_BALANCER. + enum Purpose { + // A value indicating that the enum field is not set. + UNDEFINED_PURPOSE = 0; + + // Subnet reserved for Internal HTTP(S) Load Balancing. + INTERNAL_HTTPS_LOAD_BALANCER = 248748889; + + // Regular user created or automatically created subnet. + PRIVATE = 403485027; + + // Regular user created or automatically created subnet. + PRIVATE_RFC_1918 = 254902107; + + // Subnetworks created for Private Service Connect in the producer network. + PRIVATE_SERVICE_CONNECT = 48134724; + + // Subnetwork used for Regional Internal/External HTTP(S) Load Balancing. + REGIONAL_MANAGED_PROXY = 153049966; + + } + + // The role of subnetwork. Currently, this field is only used when purpose = INTERNAL_HTTPS_LOAD_BALANCER. The value can be set to ACTIVE or BACKUP. An ACTIVE subnetwork is one that is currently being used for Internal HTTP(S) Load Balancing. A BACKUP subnetwork is one that is ready to be promoted to ACTIVE or is currently draining. This field can be updated with a patch request. + enum Role { + // A value indicating that the enum field is not set. + UNDEFINED_ROLE = 0; + + // The ACTIVE subnet that is currently used. + ACTIVE = 314733318; + + // The BACKUP subnet that could be promoted to ACTIVE. + BACKUP = 341010882; + + } + + // The stack type for the subnet. If set to IPV4_ONLY, new VMs in the subnet are assigned IPv4 addresses only. If set to IPV4_IPV6, new VMs in the subnet can be assigned both IPv4 and IPv6 addresses. If not specified, IPV4_ONLY is used. This field can be both set at resource creation time and updated using patch. + enum StackType { + // A value indicating that the enum field is not set. + UNDEFINED_STACK_TYPE = 0; + + // New VMs in this subnet can have both IPv4 and IPv6 addresses. + IPV4_IPV6 = 22197249; + + // New VMs in this subnet will only be assigned IPv4 addresses. + IPV4_ONLY = 22373798; + + UNSPECIFIED_STACK_TYPE = 298084569; + + } + + // [Output Only] The state of the subnetwork, which can be one of the following values: READY: Subnetwork is created and ready to use DRAINING: only applicable to subnetworks that have the purpose set to INTERNAL_HTTPS_LOAD_BALANCER and indicates that connections to the load balancer are being drained. A subnetwork that is draining cannot be used or modified until it reaches a status of READY + enum State { + // A value indicating that the enum field is not set. + UNDEFINED_STATE = 0; + + // Subnetwork is being drained. + DRAINING = 480455402; + + // Subnetwork is ready for use. + READY = 77848963; + + } + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. This field can be set only at resource creation time. + optional string description = 422937596; + + // Whether to enable flow logging for this subnetwork. If this field is not explicitly set, it will not appear in get listings. If not set the default behavior is determined by the org policy, if there is no org policy specified, then it will default to disabled. This field isn't supported with the purpose field set to INTERNAL_HTTPS_LOAD_BALANCER. + optional bool enable_flow_logs = 151544420; + + // The external IPv6 address range that is owned by this subnetwork. + optional string external_ipv6_prefix = 139299190; + + // Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a Subnetwork. An up-to-date fingerprint must be provided in order to update the Subnetwork, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve a Subnetwork. + optional string fingerprint = 234678500; + + // [Output Only] The gateway address for default routes to reach destination addresses outside this subnetwork. + optional string gateway_address = 459867385; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] The internal IPv6 address range that is assigned to this subnetwork. + optional string internal_ipv6_prefix = 506270056; + + // The range of internal addresses that are owned by this subnetwork. Provide this property when you create the subnetwork. For example, 10.0.0.0/8 or 100.64.0.0/10. Ranges must be unique and non-overlapping within a network. Only IPv4 is supported. This field is set at resource creation time. The range can be any range listed in the Valid ranges list. The range can be expanded after creation using expandIpCidrRange. + optional string ip_cidr_range = 98117322; + + // The access type of IPv6 address this subnet holds. It's immutable and can only be specified during creation or the first time the subnet is updated into IPV4_IPV6 dual stack. + // Check the Ipv6AccessType enum for the list of possible values. + optional string ipv6_access_type = 504658653; + + // [Output Only] This field is for internal use. + optional string ipv6_cidr_range = 273141258; + + // [Output Only] Type of the resource. Always compute#subnetwork for Subnetwork resources. + optional string kind = 3292052; + + // This field denotes the VPC flow logging options for this subnetwork. If logging is enabled, logs are exported to Cloud Logging. + optional SubnetworkLogConfig log_config = 351299741; + + // The name of the resource, provided by the client when initially creating the resource. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // The URL of the network to which this subnetwork belongs, provided by the client when initially creating the subnetwork. This field can be set only at resource creation time. + optional string network = 232872494; + + // Whether the VMs in this subnet can access Google services without assigned external IP addresses. This field can be both set at resource creation time and updated using setPrivateIpGoogleAccess. + optional bool private_ip_google_access = 421491790; + + // This field is for internal use. This field can be both set at resource creation time and updated using patch. + // Check the PrivateIpv6GoogleAccess enum for the list of possible values. + optional string private_ipv6_google_access = 48277006; + + // The purpose of the resource. This field can be either PRIVATE_RFC_1918 or INTERNAL_HTTPS_LOAD_BALANCER. A subnetwork with purpose set to INTERNAL_HTTPS_LOAD_BALANCER is a user-created subnetwork that is reserved for Internal HTTP(S) Load Balancing. If unspecified, the purpose defaults to PRIVATE_RFC_1918. The enableFlowLogs field isn't supported with the purpose field set to INTERNAL_HTTPS_LOAD_BALANCER. + // Check the Purpose enum for the list of possible values. + optional string purpose = 316407070; + + // URL of the region where the Subnetwork resides. This field can be set only at resource creation time. + optional string region = 138946292; + + // The role of subnetwork. Currently, this field is only used when purpose = INTERNAL_HTTPS_LOAD_BALANCER. The value can be set to ACTIVE or BACKUP. An ACTIVE subnetwork is one that is currently being used for Internal HTTP(S) Load Balancing. A BACKUP subnetwork is one that is ready to be promoted to ACTIVE or is currently draining. This field can be updated with a patch request. + // Check the Role enum for the list of possible values. + optional string role = 3506294; + + // An array of configurations for secondary IP ranges for VM instances contained in this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange of the subnetwork. The alias IPs may belong to either primary or secondary ranges. This field can be updated with a patch request. + repeated SubnetworkSecondaryRange secondary_ip_ranges = 136658915; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // The stack type for the subnet. If set to IPV4_ONLY, new VMs in the subnet are assigned IPv4 addresses only. If set to IPV4_IPV6, new VMs in the subnet can be assigned both IPv4 and IPv6 addresses. If not specified, IPV4_ONLY is used. This field can be both set at resource creation time and updated using patch. + // Check the StackType enum for the list of possible values. + optional string stack_type = 425908881; + + // [Output Only] The state of the subnetwork, which can be one of the following values: READY: Subnetwork is created and ready to use DRAINING: only applicable to subnetworks that have the purpose set to INTERNAL_HTTPS_LOAD_BALANCER and indicates that connections to the load balancer are being drained. A subnetwork that is draining cannot be used or modified until it reaches a status of READY + // Check the State enum for the list of possible values. + optional string state = 109757585; + +} + +// +message SubnetworkAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of SubnetworksScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#subnetworkAggregatedList for aggregated lists of subnetworks. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of Subnetwork resources. +message SubnetworkList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Subnetwork resources. + repeated Subnetwork items = 100526016; + + // [Output Only] Type of resource. Always compute#subnetworkList for lists of subnetworks. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// The available logging options for this subnetwork. +message SubnetworkLogConfig { + // Can only be specified if VPC flow logging for this subnetwork is enabled. Toggles the aggregation interval for collecting flow logs. Increasing the interval time will reduce the amount of generated flow logs for long lasting connections. Default is an interval of 5 seconds per connection. + enum AggregationInterval { + // A value indicating that the enum field is not set. + UNDEFINED_AGGREGATION_INTERVAL = 0; + + INTERVAL_10_MIN = 487155916; + + INTERVAL_15_MIN = 491773521; + + INTERVAL_1_MIN = 69052714; + + INTERVAL_30_SEC = 7548937; + + INTERVAL_5_MIN = 72746798; + + INTERVAL_5_SEC = 72752429; + + } + + // Can only be specified if VPC flow logs for this subnetwork is enabled. Configures whether all, none or a subset of metadata fields should be added to the reported VPC flow logs. Default is EXCLUDE_ALL_METADATA. + enum Metadata { + // A value indicating that the enum field is not set. + UNDEFINED_METADATA = 0; + + CUSTOM_METADATA = 62450749; + + EXCLUDE_ALL_METADATA = 334519954; + + INCLUDE_ALL_METADATA = 164619908; + + } + + // Can only be specified if VPC flow logging for this subnetwork is enabled. Toggles the aggregation interval for collecting flow logs. Increasing the interval time will reduce the amount of generated flow logs for long lasting connections. Default is an interval of 5 seconds per connection. + // Check the AggregationInterval enum for the list of possible values. + optional string aggregation_interval = 174919042; + + // Whether to enable flow logging for this subnetwork. If this field is not explicitly set, it will not appear in get listings. If not set the default behavior is determined by the org policy, if there is no org policy specified, then it will default to disabled. + optional bool enable = 311764355; + + // Can only be specified if VPC flow logs for this subnetwork is enabled. The filter expression is used to define which VPC flow logs should be exported to Cloud Logging. + optional string filter_expr = 183374428; + + // Can only be specified if VPC flow logging for this subnetwork is enabled. The value of the field must be in [0, 1]. Set the sampling rate of VPC flow logs within the subnetwork where 1.0 means all collected logs are reported and 0.0 means no logs are reported. Default is 0.5 unless otherwise specified by the org policy, which means half of all collected logs are reported. + optional float flow_sampling = 530150360; + + // Can only be specified if VPC flow logs for this subnetwork is enabled. Configures whether all, none or a subset of metadata fields should be added to the reported VPC flow logs. Default is EXCLUDE_ALL_METADATA. + // Check the Metadata enum for the list of possible values. + optional string metadata = 86866735; + + // Can only be specified if VPC flow logs for this subnetwork is enabled and "metadata" was set to CUSTOM_METADATA. + repeated string metadata_fields = 378461641; + +} + +// Represents a secondary IP range of a subnetwork. +message SubnetworkSecondaryRange { + // The range of IP addresses belonging to this subnetwork secondary range. Provide this property when you create the subnetwork. Ranges must be unique and non-overlapping with all primary and secondary IP ranges within a network. Only IPv4 is supported. The range can be any range listed in the Valid ranges list. + optional string ip_cidr_range = 98117322; + + // The name associated with this subnetwork secondary range, used when adding an alias IP range to a VM instance. The name must be 1-63 characters long, and comply with RFC1035. The name must be unique within the subnetwork. + optional string range_name = 332216397; + +} + +// +message SubnetworksExpandIpCidrRangeRequest { + // The IP (in CIDR format or netmask) of internal addresses that are legal on this Subnetwork. This range should be disjoint from other subnetworks within this network. This range can only be larger than (i.e. a superset of) the range previously defined before the update. + optional string ip_cidr_range = 98117322; + +} + +// +message SubnetworksScopedList { + // A list of subnetworks contained in this scope. + repeated Subnetwork subnetworks = 415853125; + + // An informational warning that appears when the list of addresses is empty. + optional Warning warning = 50704284; + +} + +// +message SubnetworksSetPrivateIpGoogleAccessRequest { + optional bool private_ip_google_access = 421491790; + +} + +// Subsetting configuration for this BackendService. Currently this is applicable only for Internal TCP/UDP load balancing, Internal HTTP(S) load balancing and Traffic Director. +message Subsetting { + // + enum Policy { + // A value indicating that the enum field is not set. + UNDEFINED_POLICY = 0; + + // Subsetting based on consistent hashing. For Traffic Director, the number of backends per backend group (the subset size) is based on the `subset_size` parameter. For Internal HTTP(S) load balancing, the number of backends per backend group (the subset size) is dynamically adjusted in two cases: - As the number of proxy instances participating in Internal HTTP(S) load balancing increases, the subset size decreases. - When the total number of backends in a network exceeds the capacity of a single proxy instance, subset sizes are reduced automatically for each service that has backend subsetting enabled. + CONSISTENT_HASH_SUBSETTING = 108989492; + + // No Subsetting. Clients may open connections and send traffic to all backends of this backend service. This can lead to performance issues if there is substantial imbalance in the count of clients and backends. + NONE = 2402104; + + } + + // + // Check the Policy enum for the list of possible values. + optional string policy = 91071794; + +} + +// A request message for Instances.Suspend. See the method description for details. +message SuspendInstanceRequest { + // If true, discard the contents of any attached localSSD partitions. Default value is false. + optional bool discard_local_ssd = 319517903; + + // Name of the instance resource to suspend. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Networks.SwitchToCustomMode. See the method description for details. +message SwitchToCustomModeNetworkRequest { + // Name of the network to be updated. + string network = 232872494 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// +message TCPHealthCheck { + // Specifies how a port is selected for health checking. Can be one of the following values: USE_FIXED_PORT: Specifies a port number explicitly using the port field in the health check. Supported by backend services for pass-through load balancers and backend services for proxy load balancers. Not supported by target pools. The health check supports all backends supported by the backend service provided the backend can be health checked. For example, GCE_VM_IP network endpoint groups, GCE_VM_IP_PORT network endpoint groups, and instance group backends. USE_NAMED_PORT: Not supported. USE_SERVING_PORT: Provides an indirect method of specifying the health check port by referring to the backend service. Only supported by backend services for proxy load balancers. Not supported by target pools. Not supported by backend services for pass-through load balancers. Supports all backends that can be health checked; for example, GCE_VM_IP_PORT network endpoint groups and instance group backends. For GCE_VM_IP_PORT network endpoint group backends, the health check uses the port number specified for each endpoint in the network endpoint group. For instance group backends, the health check uses the port number determined by looking up the backend service's named port in the instance group's list of named ports. + enum PortSpecification { + // A value indicating that the enum field is not set. + UNDEFINED_PORT_SPECIFICATION = 0; + + // The port number in the health check's port is used for health checking. Applies to network endpoint group and instance group backends. + USE_FIXED_PORT = 190235748; + + // Not supported. + USE_NAMED_PORT = 349300671; + + // For network endpoint group backends, the health check uses the port number specified on each endpoint in the network endpoint group. For instance group backends, the health check uses the port number specified for the backend service's named port defined in the instance group's named ports. + USE_SERVING_PORT = 362637516; + + } + + // Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. + enum ProxyHeader { + // A value indicating that the enum field is not set. + UNDEFINED_PROXY_HEADER = 0; + + NONE = 2402104; + + PROXY_V1 = 334352940; + + } + + // The TCP port number to which the health check prober sends packets. The default value is 80. Valid values are 1 through 65535. + optional int32 port = 3446913; + + // Not supported. + optional string port_name = 41534345; + + // Specifies how a port is selected for health checking. Can be one of the following values: USE_FIXED_PORT: Specifies a port number explicitly using the port field in the health check. Supported by backend services for pass-through load balancers and backend services for proxy load balancers. Not supported by target pools. The health check supports all backends supported by the backend service provided the backend can be health checked. For example, GCE_VM_IP network endpoint groups, GCE_VM_IP_PORT network endpoint groups, and instance group backends. USE_NAMED_PORT: Not supported. USE_SERVING_PORT: Provides an indirect method of specifying the health check port by referring to the backend service. Only supported by backend services for proxy load balancers. Not supported by target pools. Not supported by backend services for pass-through load balancers. Supports all backends that can be health checked; for example, GCE_VM_IP_PORT network endpoint groups and instance group backends. For GCE_VM_IP_PORT network endpoint group backends, the health check uses the port number specified for each endpoint in the network endpoint group. For instance group backends, the health check uses the port number determined by looking up the backend service's named port in the instance group's list of named ports. + // Check the PortSpecification enum for the list of possible values. + optional string port_specification = 51590597; + + // Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. + // Check the ProxyHeader enum for the list of possible values. + optional string proxy_header = 160374142; + + // Instructs the health check prober to send this exact ASCII string, up to 1024 bytes in length, after establishing the TCP connection. + optional string request = 21951119; + + // Creates a content-based TCP health check. In addition to establishing a TCP connection, you can configure the health check to pass only when the backend sends this exact response ASCII string, up to 1024 bytes in length. For details, see: https://cloud.google.com/load-balancing/docs/health-check-concepts#criteria-protocol-ssl-tcp + optional string response = 196547649; + +} + +// A set of instance tags. +message Tags { + // Specifies a fingerprint for this request, which is essentially a hash of the tags' contents and used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update tags. You must always provide an up-to-date fingerprint hash in order to update or change tags. To see the latest fingerprint, make get() request to the instance. + optional string fingerprint = 234678500; + + // An array of tags. Each tag must be 1-63 characters long, and comply with RFC1035. + repeated string items = 100526016; + +} + +// Represents a Target gRPC Proxy resource. A target gRPC proxy is a component of load balancers intended for load balancing gRPC traffic. Only global forwarding rules with load balancing scheme INTERNAL_SELF_MANAGED can reference a target gRPC proxy. The target gRPC Proxy references a URL map that specifies how traffic is routed to gRPC backend services. +message TargetGrpcProxy { + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a TargetGrpcProxy. An up-to-date fingerprint must be provided in order to patch/update the TargetGrpcProxy; otherwise, the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve the TargetGrpcProxy. + optional string fingerprint = 234678500; + + // [Output Only] The unique identifier for the resource type. The server generates this identifier. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#targetGrpcProxy for target grpc proxies. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] Server-defined URL with id for the resource. + optional string self_link_with_id = 44520962; + + // URL to the UrlMap resource that defines the mapping from URL to the BackendService. The protocol field in the BackendService must be set to GRPC. + optional string url_map = 367020684; + + // If true, indicates that the BackendServices referenced by the urlMap may be accessed by gRPC applications without using a sidecar proxy. This will enable configuration checks on urlMap and its referenced BackendServices to not allow unsupported features. A gRPC application must use "xds:///" scheme in the target URI of the service it is connecting to. If false, indicates that the BackendServices referenced by the urlMap will be accessed by gRPC applications via a sidecar proxy. In this case, a gRPC application must not use "xds:///" scheme in the target URI of the service it is connecting to + optional bool validate_for_proxyless = 101822888; + +} + +// +message TargetGrpcProxyList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of TargetGrpcProxy resources. + repeated TargetGrpcProxy items = 100526016; + + // [Output Only] Type of the resource. Always compute#targetGrpcProxy for target grpc proxies. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message TargetHttpProxiesScopedList { + // A list of TargetHttpProxies contained in this scope. + repeated TargetHttpProxy target_http_proxies = 162147011; + + // Informational warning which replaces the list of backend services when the list is empty. + optional Warning warning = 50704284; + +} + +// Represents a Target HTTP Proxy resource. Google Compute Engine has two Target HTTP Proxy resources: * [Global](/compute/docs/reference/rest/v1/targetHttpProxies) * [Regional](/compute/docs/reference/rest/v1/regionTargetHttpProxies) A target HTTP proxy is a component of GCP HTTP load balancers. * targetHttpProxies are used by external HTTP load balancers and Traffic Director. * regionTargetHttpProxies are used by internal HTTP load balancers. Forwarding rules reference a target HTTP proxy, and the target proxy then references a URL map. For more information, read Using Target Proxies and Forwarding rule concepts. +message TargetHttpProxy { + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a TargetHttpProxy. An up-to-date fingerprint must be provided in order to patch/update the TargetHttpProxy; otherwise, the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve the TargetHttpProxy. + optional string fingerprint = 234678500; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of resource. Always compute#targetHttpProxy for target HTTP proxies. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // This field only applies when the forwarding rule that references this target proxy has a loadBalancingScheme set to INTERNAL_SELF_MANAGED. When this field is set to true, Envoy proxies set up inbound traffic interception and bind to the IP address and port specified in the forwarding rule. This is generally useful when using Traffic Director to configure Envoy as a gateway or middle proxy (in other words, not a sidecar proxy). The Envoy proxy listens for inbound requests and handles requests when it receives them. The default is false. + optional bool proxy_bind = 286025582; + + // [Output Only] URL of the region where the regional Target HTTP Proxy resides. This field is not applicable to global Target HTTP Proxies. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // URL to the UrlMap resource that defines the mapping from URL to the BackendService. + optional string url_map = 367020684; + +} + +// +message TargetHttpProxyAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of TargetHttpProxiesScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#targetHttpProxyAggregatedList for lists of Target HTTP Proxies. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + +} + +// A list of TargetHttpProxy resources. +message TargetHttpProxyList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of TargetHttpProxy resources. + repeated TargetHttpProxy items = 100526016; + + // Type of resource. Always compute#targetHttpProxyList for lists of target HTTP proxies. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message TargetHttpsProxiesScopedList { + // A list of TargetHttpsProxies contained in this scope. + repeated TargetHttpsProxy target_https_proxies = 366607882; + + // Informational warning which replaces the list of backend services when the list is empty. + optional Warning warning = 50704284; + +} + +// +message TargetHttpsProxiesSetCertificateMapRequest { + // URL of the Certificate Map to associate with this TargetHttpsProxy. + optional string certificate_map = 156463796; + +} + +// +message TargetHttpsProxiesSetQuicOverrideRequest { + // QUIC policy for the TargetHttpsProxy resource. + enum QuicOverride { + // A value indicating that the enum field is not set. + UNDEFINED_QUIC_OVERRIDE = 0; + + // The load balancer will not attempt to negotiate QUIC with clients. + DISABLE = 241807048; + + // The load balancer will attempt to negotiate QUIC with clients. + ENABLE = 438835587; + + // No overrides to the default QUIC policy. This option is implicit if no QUIC override has been specified in the request. + NONE = 2402104; + + } + + // QUIC policy for the TargetHttpsProxy resource. + // Check the QuicOverride enum for the list of possible values. + optional string quic_override = 456577197; + +} + +// +message TargetHttpsProxiesSetSslCertificatesRequest { + // New set of SslCertificate resources to associate with this TargetHttpsProxy resource. At least one SSL certificate must be specified. Currently, you may specify up to 15 SSL certificates. + repeated string ssl_certificates = 366006543; + +} + +// Represents a Target HTTPS Proxy resource. Google Compute Engine has two Target HTTPS Proxy resources: * [Global](/compute/docs/reference/rest/v1/targetHttpsProxies) * [Regional](/compute/docs/reference/rest/v1/regionTargetHttpsProxies) A target HTTPS proxy is a component of GCP HTTPS load balancers. * targetHttpsProxies are used by external HTTPS load balancers. * regionTargetHttpsProxies are used by internal HTTPS load balancers. Forwarding rules reference a target HTTPS proxy, and the target proxy then references a URL map. For more information, read Using Target Proxies and Forwarding rule concepts. +message TargetHttpsProxy { + // Specifies the QUIC override policy for this TargetHttpsProxy resource. This setting determines whether the load balancer attempts to negotiate QUIC with clients. You can specify NONE, ENABLE, or DISABLE. - When quic-override is set to NONE, Google manages whether QUIC is used. - When quic-override is set to ENABLE, the load balancer uses QUIC when possible. - When quic-override is set to DISABLE, the load balancer doesn't use QUIC. - If the quic-override flag is not specified, NONE is implied. + enum QuicOverride { + // A value indicating that the enum field is not set. + UNDEFINED_QUIC_OVERRIDE = 0; + + // The load balancer will not attempt to negotiate QUIC with clients. + DISABLE = 241807048; + + // The load balancer will attempt to negotiate QUIC with clients. + ENABLE = 438835587; + + // No overrides to the default QUIC policy. This option is implicit if no QUIC override has been specified in the request. + NONE = 2402104; + + } + + // Optional. A URL referring to a networksecurity.AuthorizationPolicy resource that describes how the proxy should authorize inbound traffic. If left blank, access will not be restricted by an authorization policy. Refer to the AuthorizationPolicy resource for additional details. authorizationPolicy only applies to a global TargetHttpsProxy attached to globalForwardingRules with the loadBalancingScheme set to INTERNAL_SELF_MANAGED. Note: This field currently has no impact. + optional string authorization_policy = 33945528; + + // URL of a certificate map that identifies a certificate map associated with the given target proxy. This field can only be set for global target proxies. If set, sslCertificates will be ignored. + optional string certificate_map = 156463796; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a TargetHttpsProxy. An up-to-date fingerprint must be provided in order to patch the TargetHttpsProxy; otherwise, the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve the TargetHttpsProxy. + optional string fingerprint = 234678500; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of resource. Always compute#targetHttpsProxy for target HTTPS proxies. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // This field only applies when the forwarding rule that references this target proxy has a loadBalancingScheme set to INTERNAL_SELF_MANAGED. When this field is set to true, Envoy proxies set up inbound traffic interception and bind to the IP address and port specified in the forwarding rule. This is generally useful when using Traffic Director to configure Envoy as a gateway or middle proxy (in other words, not a sidecar proxy). The Envoy proxy listens for inbound requests and handles requests when it receives them. The default is false. + optional bool proxy_bind = 286025582; + + // Specifies the QUIC override policy for this TargetHttpsProxy resource. This setting determines whether the load balancer attempts to negotiate QUIC with clients. You can specify NONE, ENABLE, or DISABLE. - When quic-override is set to NONE, Google manages whether QUIC is used. - When quic-override is set to ENABLE, the load balancer uses QUIC when possible. - When quic-override is set to DISABLE, the load balancer doesn't use QUIC. - If the quic-override flag is not specified, NONE is implied. + // Check the QuicOverride enum for the list of possible values. + optional string quic_override = 456577197; + + // [Output Only] URL of the region where the regional TargetHttpsProxy resides. This field is not applicable to global TargetHttpsProxies. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // Optional. A URL referring to a networksecurity.ServerTlsPolicy resource that describes how the proxy should authenticate inbound traffic. serverTlsPolicy only applies to a global TargetHttpsProxy attached to globalForwardingRules with the loadBalancingScheme set to INTERNAL_SELF_MANAGED. If left blank, communications are not encrypted. Note: This field currently has no impact. + optional string server_tls_policy = 295825266; + + // URLs to SslCertificate resources that are used to authenticate connections between users and the load balancer. At least one SSL certificate must be specified. Currently, you may specify up to 15 SSL certificates. sslCertificates do not apply when the load balancing scheme is set to INTERNAL_SELF_MANAGED. + repeated string ssl_certificates = 366006543; + + // URL of SslPolicy resource that will be associated with the TargetHttpsProxy resource. If not set, the TargetHttpsProxy resource has no SSL policy configured. + optional string ssl_policy = 295190213; + + // A fully-qualified or valid partial URL to the UrlMap resource that defines the mapping from URL to the BackendService. For example, the following are all valid URLs for specifying a URL map: - https://www.googleapis.compute/v1/projects/project/global/urlMaps/ url-map - projects/project/global/urlMaps/url-map - global/urlMaps/url-map + optional string url_map = 367020684; + +} + +// +message TargetHttpsProxyAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of TargetHttpsProxiesScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#targetHttpsProxyAggregatedList for lists of Target HTTP Proxies. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of TargetHttpsProxy resources. +message TargetHttpsProxyList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of TargetHttpsProxy resources. + repeated TargetHttpsProxy items = 100526016; + + // Type of resource. Always compute#targetHttpsProxyList for lists of target HTTPS proxies. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Represents a Target Instance resource. You can use a target instance to handle traffic for one or more forwarding rules, which is ideal for forwarding protocol traffic that is managed by a single source. For example, ESP, AH, TCP, or UDP. For more information, read Target instances. +message TargetInstance { + // Must have a value of NO_NAT. Protocol forwarding delivers packets while preserving the destination IP address of the forwarding rule referencing the target instance. + enum NatPolicy { + // A value indicating that the enum field is not set. + UNDEFINED_NAT_POLICY = 0; + + // No NAT performed. + NO_NAT = 161455491; + + } + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // A URL to the virtual machine instance that handles traffic for this target instance. When creating a target instance, you can provide the fully-qualified URL or a valid partial URL to the desired virtual machine. For example, the following are all valid URLs: - https://www.googleapis.com/compute/v1/projects/project/zones/zone /instances/instance - projects/project/zones/zone/instances/instance - zones/zone/instances/instance + optional string instance = 18257045; + + // [Output Only] The type of the resource. Always compute#targetInstance for target instances. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // Must have a value of NO_NAT. Protocol forwarding delivers packets while preserving the destination IP address of the forwarding rule referencing the target instance. + // Check the NatPolicy enum for the list of possible values. + optional string nat_policy = 509780496; + + // The URL of the network this target instance uses to forward traffic. If not specified, the traffic will be forwarded to the network that the default network interface belongs to. + optional string network = 232872494; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] URL of the zone where the target instance resides. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string zone = 3744684; + +} + +// +message TargetInstanceAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of TargetInstance resources. + map items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of TargetInstance resources. +message TargetInstanceList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of TargetInstance resources. + repeated TargetInstance items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message TargetInstancesScopedList { + // A list of target instances contained in this scope. + repeated TargetInstance target_instances = 392915280; + + // Informational warning which replaces the list of addresses when the list is empty. + optional Warning warning = 50704284; + +} + +// Represents a Target Pool resource. Target pools are used for network TCP/UDP load balancing. A target pool references member instances, an associated legacy HttpHealthCheck resource, and, optionally, a backup target pool. For more information, read Using target pools. +message TargetPool { + // Session affinity option, must be one of the following values: NONE: Connections from the same client IP may go to any instance in the pool. CLIENT_IP: Connections from the same client IP will go to the same instance in the pool while that instance remains healthy. CLIENT_IP_PROTO: Connections from the same client IP with the same IP protocol will go to the same instance in the pool while that instance remains healthy. + enum SessionAffinity { + // A value indicating that the enum field is not set. + UNDEFINED_SESSION_AFFINITY = 0; + + // 2-tuple hash on packet's source and destination IP addresses. Connections from the same source IP address to the same destination IP address will be served by the same backend VM while that VM remains healthy. + CLIENT_IP = 345665051; + + // 1-tuple hash only on packet's source IP address. Connections from the same source IP address will be served by the same backend VM while that VM remains healthy. This option can only be used for Internal TCP/UDP Load Balancing. + CLIENT_IP_NO_DESTINATION = 106122516; + + // 5-tuple hash on packet's source and destination IP addresses, IP protocol, and source and destination ports. Connections for the same IP protocol from the same source IP address and port to the same destination IP address and port will be served by the same backend VM while that VM remains healthy. This option cannot be used for HTTP(S) load balancing. + CLIENT_IP_PORT_PROTO = 221722926; + + // 3-tuple hash on packet's source and destination IP addresses, and IP protocol. Connections for the same IP protocol from the same source IP address to the same destination IP address will be served by the same backend VM while that VM remains healthy. This option cannot be used for HTTP(S) load balancing. + CLIENT_IP_PROTO = 25322148; + + // Hash based on a cookie generated by the L7 loadbalancer. Only valid for HTTP(S) load balancing. + GENERATED_COOKIE = 370321204; + + // The hash is based on a user specified header field. + HEADER_FIELD = 200737960; + + // The hash is based on a user provided cookie. + HTTP_COOKIE = 494981627; + + // No session affinity. Connections from the same client IP may go to any instance in the pool. + NONE = 2402104; + + } + + // The server-defined URL for the resource. This field is applicable only when the containing target pool is serving a forwarding rule as the primary pool, and its failoverRatio field is properly set to a value between [0, 1]. backupPool and failoverRatio together define the fallback behavior of the primary target pool: if the ratio of the healthy instances in the primary pool is at or below failoverRatio, traffic arriving at the load-balanced IP will be directed to the backup pool. In case where failoverRatio and backupPool are not set, or all the instances in the backup pool are unhealthy, the traffic will be directed back to the primary pool in the "force" mode, where traffic will be spread to the healthy instances with the best effort, or to all instances when no instance is healthy. + optional string backup_pool = 45884537; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // This field is applicable only when the containing target pool is serving a forwarding rule as the primary pool (i.e., not as a backup pool to some other target pool). The value of the field must be in [0, 1]. If set, backupPool must also be set. They together define the fallback behavior of the primary target pool: if the ratio of the healthy instances in the primary pool is at or below this number, traffic arriving at the load-balanced IP will be directed to the backup pool. In case where failoverRatio is not set or all the instances in the backup pool are unhealthy, the traffic will be directed back to the primary pool in the "force" mode, where traffic will be spread to the healthy instances with the best effort, or to all instances when no instance is healthy. + optional float failover_ratio = 212667006; + + // The URL of the HttpHealthCheck resource. A member instance in this pool is considered healthy if and only if the health checks pass. Only legacy HttpHealthChecks are supported. Only one health check may be specified. + repeated string health_checks = 448370606; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // A list of resource URLs to the virtual machine instances serving this pool. They must live in zones contained in the same region as this pool. + repeated string instances = 29097598; + + // [Output Only] Type of the resource. Always compute#targetPool for target pools. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // [Output Only] URL of the region where the target pool resides. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // Session affinity option, must be one of the following values: NONE: Connections from the same client IP may go to any instance in the pool. CLIENT_IP: Connections from the same client IP will go to the same instance in the pool while that instance remains healthy. CLIENT_IP_PROTO: Connections from the same client IP with the same IP protocol will go to the same instance in the pool while that instance remains healthy. + // Check the SessionAffinity enum for the list of possible values. + optional string session_affinity = 463888561; + +} + +// +message TargetPoolAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of TargetPool resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#targetPoolAggregatedList for aggregated lists of target pools. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message TargetPoolInstanceHealth { + repeated HealthStatus health_status = 380545845; + + // [Output Only] Type of resource. Always compute#targetPoolInstanceHealth when checking the health of an instance. + optional string kind = 3292052; + +} + +// Contains a list of TargetPool resources. +message TargetPoolList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of TargetPool resources. + repeated TargetPool items = 100526016; + + // [Output Only] Type of resource. Always compute#targetPoolList for lists of target pools. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message TargetPoolsAddHealthCheckRequest { + // The HttpHealthCheck to add to the target pool. + repeated HealthCheckReference health_checks = 448370606; + +} + +// +message TargetPoolsAddInstanceRequest { + // A full or partial URL to an instance to add to this target pool. This can be a full or partial URL. For example, the following are valid URLs: - https://www.googleapis.com/compute/v1/projects/project-id/zones/zone /instances/instance-name - projects/project-id/zones/zone/instances/instance-name - zones/zone/instances/instance-name + repeated InstanceReference instances = 29097598; + +} + +// +message TargetPoolsRemoveHealthCheckRequest { + // Health check URL to be removed. This can be a full or valid partial URL. For example, the following are valid URLs: - https://www.googleapis.com/compute/beta/projects/project /global/httpHealthChecks/health-check - projects/project/global/httpHealthChecks/health-check - global/httpHealthChecks/health-check + repeated HealthCheckReference health_checks = 448370606; + +} + +// +message TargetPoolsRemoveInstanceRequest { + // URLs of the instances to be removed from target pool. + repeated InstanceReference instances = 29097598; + +} + +// +message TargetPoolsScopedList { + // A list of target pools contained in this scope. + repeated TargetPool target_pools = 336072617; + + // Informational warning which replaces the list of addresses when the list is empty. + optional Warning warning = 50704284; + +} + +// +message TargetReference { + optional string target = 192835985; + +} + +// +message TargetSslProxiesSetBackendServiceRequest { + // The URL of the new BackendService resource for the targetSslProxy. + optional string service = 373540533; + +} + +// +message TargetSslProxiesSetCertificateMapRequest { + // URL of the Certificate Map to associate with this TargetSslProxy. + optional string certificate_map = 156463796; + +} + +// +message TargetSslProxiesSetProxyHeaderRequest { + // The new type of proxy header to append before sending data to the backend. NONE or PROXY_V1 are allowed. + enum ProxyHeader { + // A value indicating that the enum field is not set. + UNDEFINED_PROXY_HEADER = 0; + + NONE = 2402104; + + PROXY_V1 = 334352940; + + } + + // The new type of proxy header to append before sending data to the backend. NONE or PROXY_V1 are allowed. + // Check the ProxyHeader enum for the list of possible values. + optional string proxy_header = 160374142; + +} + +// +message TargetSslProxiesSetSslCertificatesRequest { + // New set of URLs to SslCertificate resources to associate with this TargetSslProxy. At least one SSL certificate must be specified. Currently, you may specify up to 15 SSL certificates. + repeated string ssl_certificates = 366006543; + +} + +// Represents a Target SSL Proxy resource. A target SSL proxy is a component of a SSL Proxy load balancer. Global forwarding rules reference a target SSL proxy, and the target proxy then references an external backend service. For more information, read Using Target Proxies. +message TargetSslProxy { + // Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. + enum ProxyHeader { + // A value indicating that the enum field is not set. + UNDEFINED_PROXY_HEADER = 0; + + NONE = 2402104; + + PROXY_V1 = 334352940; + + } + + // URL of a certificate map that identifies a certificate map associated with the given target proxy. This field can only be set for global target proxies. If set, sslCertificates will be ignored. + optional string certificate_map = 156463796; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#targetSslProxy for target SSL proxies. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. + // Check the ProxyHeader enum for the list of possible values. + optional string proxy_header = 160374142; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // URL to the BackendService resource. + optional string service = 373540533; + + // URLs to SslCertificate resources that are used to authenticate connections to Backends. At least one SSL certificate must be specified. Currently, you may specify up to 15 SSL certificates. sslCertificates do not apply when the load balancing scheme is set to INTERNAL_SELF_MANAGED. + repeated string ssl_certificates = 366006543; + + // URL of SslPolicy resource that will be associated with the TargetSslProxy resource. If not set, the TargetSslProxy resource will not have any SSL policy configured. + optional string ssl_policy = 295190213; + +} + +// Contains a list of TargetSslProxy resources. +message TargetSslProxyList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of TargetSslProxy resources. + repeated TargetSslProxy items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message TargetTcpProxiesScopedList { + // A list of TargetTcpProxies contained in this scope. + repeated TargetTcpProxy target_tcp_proxies = 262056832; + + // Informational warning which replaces the list of backend services when the list is empty. + optional Warning warning = 50704284; + +} + +// +message TargetTcpProxiesSetBackendServiceRequest { + // The URL of the new BackendService resource for the targetTcpProxy. + optional string service = 373540533; + +} + +// +message TargetTcpProxiesSetProxyHeaderRequest { + // The new type of proxy header to append before sending data to the backend. NONE or PROXY_V1 are allowed. + enum ProxyHeader { + // A value indicating that the enum field is not set. + UNDEFINED_PROXY_HEADER = 0; + + NONE = 2402104; + + PROXY_V1 = 334352940; + + } + + // The new type of proxy header to append before sending data to the backend. NONE or PROXY_V1 are allowed. + // Check the ProxyHeader enum for the list of possible values. + optional string proxy_header = 160374142; + +} + +// Represents a Target TCP Proxy resource. A target TCP proxy is a component of a TCP Proxy load balancer. Global forwarding rules reference target TCP proxy, and the target proxy then references an external backend service. For more information, read TCP Proxy Load Balancing overview. +message TargetTcpProxy { + // Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. + enum ProxyHeader { + // A value indicating that the enum field is not set. + UNDEFINED_PROXY_HEADER = 0; + + NONE = 2402104; + + PROXY_V1 = 334352940; + + } + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#targetTcpProxy for target TCP proxies. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // This field only applies when the forwarding rule that references this target proxy has a loadBalancingScheme set to INTERNAL_SELF_MANAGED. When this field is set to true, Envoy proxies set up inbound traffic interception and bind to the IP address and port specified in the forwarding rule. This is generally useful when using Traffic Director to configure Envoy as a gateway or middle proxy (in other words, not a sidecar proxy). The Envoy proxy listens for inbound requests and handles requests when it receives them. The default is false. + optional bool proxy_bind = 286025582; + + // Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. + // Check the ProxyHeader enum for the list of possible values. + optional string proxy_header = 160374142; + + // [Output Only] URL of the region where the regional TCP proxy resides. This field is not applicable to global TCP proxy. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // URL to the BackendService resource. + optional string service = 373540533; + +} + +// +message TargetTcpProxyAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of TargetTcpProxiesScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#targetTcpProxyAggregatedList for lists of Target TCP Proxies. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of TargetTcpProxy resources. +message TargetTcpProxyList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of TargetTcpProxy resources. + repeated TargetTcpProxy items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Represents a Target VPN Gateway resource. The target VPN gateway resource represents a Classic Cloud VPN gateway. For more information, read the the Cloud VPN Overview. +message TargetVpnGateway { + // [Output Only] The status of the VPN gateway, which can be one of the following: CREATING, READY, FAILED, or DELETING. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + CREATING = 455564985; + + DELETING = 528602024; + + FAILED = 455706685; + + READY = 77848963; + + } + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] A list of URLs to the ForwardingRule resources. ForwardingRules are created using compute.forwardingRules.insert and associated with a VPN gateway. + repeated string forwarding_rules = 315821365; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of resource. Always compute#targetVpnGateway for target VPN gateways. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // URL of the network to which this VPN gateway is attached. Provided by the client when the VPN gateway is created. + optional string network = 232872494; + + // [Output Only] URL of the region where the target VPN gateway resides. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] The status of the VPN gateway, which can be one of the following: CREATING, READY, FAILED, or DELETING. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // [Output Only] A list of URLs to VpnTunnel resources. VpnTunnels are created using the compute.vpntunnels.insert method and associated with a VPN gateway. + repeated string tunnels = 104561931; + +} + +// +message TargetVpnGatewayAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of TargetVpnGateway resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#targetVpnGateway for target VPN gateways. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of TargetVpnGateway resources. +message TargetVpnGatewayList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of TargetVpnGateway resources. + repeated TargetVpnGateway items = 100526016; + + // [Output Only] Type of resource. Always compute#targetVpnGateway for target VPN gateways. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message TargetVpnGatewaysScopedList { + // [Output Only] A list of target VPN gateways contained in this scope. + repeated TargetVpnGateway target_vpn_gateways = 401770888; + + // [Output Only] Informational warning which replaces the list of addresses when the list is empty. + optional Warning warning = 50704284; + +} + +// +message TestFailure { + // The actual output URL evaluated by a load balancer containing the scheme, host, path and query parameters. + optional string actual_output_url = 287075458; + + // Actual HTTP status code for rule with `urlRedirect` calculated by load balancer + optional int32 actual_redirect_response_code = 42926553; + + // BackendService or BackendBucket returned by load balancer. + optional string actual_service = 440379652; + + // The expected output URL evaluated by a load balancer containing the scheme, host, path and query parameters. + optional string expected_output_url = 433967384; + + // Expected HTTP status code for rule with `urlRedirect` calculated by load balancer + optional int32 expected_redirect_response_code = 18888047; + + // Expected BackendService or BackendBucket resource the given URL should be mapped to. + optional string expected_service = 133987374; + + // HTTP headers of the request. + repeated UrlMapTestHeader headers = 258436998; + + // Host portion of the URL. + optional string host = 3208616; + + // Path portion including query parameters in the URL. + optional string path = 3433509; + +} + +// A request message for Disks.TestIamPermissions. See the method description for details. +message TestIamPermissionsDiskRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ExternalVpnGateways.TestIamPermissions. See the method description for details. +message TestIamPermissionsExternalVpnGatewayRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for FirewallPolicies.TestIamPermissions. See the method description for details. +message TestIamPermissionsFirewallPolicyRequest { + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Images.TestIamPermissions. See the method description for details. +message TestIamPermissionsImageRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Instances.TestIamPermissions. See the method description for details. +message TestIamPermissionsInstanceRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for InstanceTemplates.TestIamPermissions. See the method description for details. +message TestIamPermissionsInstanceTemplateRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for LicenseCodes.TestIamPermissions. See the method description for details. +message TestIamPermissionsLicenseCodeRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Licenses.TestIamPermissions. See the method description for details. +message TestIamPermissionsLicenseRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for MachineImages.TestIamPermissions. See the method description for details. +message TestIamPermissionsMachineImageRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NetworkAttachments.TestIamPermissions. See the method description for details. +message TestIamPermissionsNetworkAttachmentRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NetworkEndpointGroups.TestIamPermissions. See the method description for details. +message TestIamPermissionsNetworkEndpointGroupRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NetworkFirewallPolicies.TestIamPermissions. See the method description for details. +message TestIamPermissionsNetworkFirewallPolicyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NodeGroups.TestIamPermissions. See the method description for details. +message TestIamPermissionsNodeGroupRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for NodeTemplates.TestIamPermissions. See the method description for details. +message TestIamPermissionsNodeTemplateRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for PacketMirrorings.TestIamPermissions. See the method description for details. +message TestIamPermissionsPacketMirroringRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionDisks.TestIamPermissions. See the method description for details. +message TestIamPermissionsRegionDiskRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionNetworkFirewallPolicies.TestIamPermissions. See the method description for details. +message TestIamPermissionsRegionNetworkFirewallPolicyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Reservations.TestIamPermissions. See the method description for details. +message TestIamPermissionsReservationRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ResourcePolicies.TestIamPermissions. See the method description for details. +message TestIamPermissionsResourcePolicyRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ServiceAttachments.TestIamPermissions. See the method description for details. +message TestIamPermissionsServiceAttachmentRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Snapshots.TestIamPermissions. See the method description for details. +message TestIamPermissionsSnapshotRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Subnetworks.TestIamPermissions. See the method description for details. +message TestIamPermissionsSubnetworkRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for VpnGateways.TestIamPermissions. See the method description for details. +message TestIamPermissionsVpnGatewayRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // The name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // Name or id of the resource for this request. + string resource = 195806222 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + TestPermissionsRequest test_permissions_request_resource = 439214758 [(google.api.field_behavior) = REQUIRED]; + +} + +// +message TestPermissionsRequest { + // The set of permissions to check for the 'resource'. Permissions with wildcards (such as '*' or 'storage.*') are not allowed. + repeated string permissions = 59962500; + +} + +// +message TestPermissionsResponse { + // A subset of `TestPermissionsRequest.permissions` that the caller is allowed. + repeated string permissions = 59962500; + +} + +// +message Uint128 { + optional uint64 high = 3202466; + + optional uint64 low = 107348; + +} + +// A request message for Instances.UpdateAccessConfig. See the method description for details. +message UpdateAccessConfigInstanceRequest { + // The body resource for this request + AccessConfig access_config_resource = 387825552 [(google.api.field_behavior) = REQUIRED]; + + // The instance name for this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The name of the network interface where the access config is attached. + string network_interface = 365387880 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Autoscalers.Update. See the method description for details. +message UpdateAutoscalerRequest { + // Name of the autoscaler to update. + optional string autoscaler = 517258967; + + // The body resource for this request + Autoscaler autoscaler_resource = 207616118 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for BackendBuckets.Update. See the method description for details. +message UpdateBackendBucketRequest { + // Name of the BackendBucket resource to update. + string backend_bucket = 91714037 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + BackendBucket backend_bucket_resource = 380757784 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for BackendServices.Update. See the method description for details. +message UpdateBackendServiceRequest { + // Name of the BackendService resource to update. + string backend_service = 306946058 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + BackendService backend_service_resource = 347586723 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Disks.Update. See the method description for details. +message UpdateDiskRequest { + // The disk name for this request. + string disk = 3083677 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + Disk disk_resource = 25880688 [(google.api.field_behavior) = REQUIRED]; + + optional string paths = 106438894; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // update_mask indicates fields to be updated as part of this request. + optional string update_mask = 500079778; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Instances.UpdateDisplayDevice. See the method description for details. +message UpdateDisplayDeviceInstanceRequest { + // The body resource for this request + DisplayDevice display_device_resource = 289686106 [(google.api.field_behavior) = REQUIRED]; + + // Name of the instance scoping this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Firewalls.Update. See the method description for details. +message UpdateFirewallRequest { + // Name of the firewall rule to update. + string firewall = 511016192 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + Firewall firewall_resource = 41425005 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for HealthChecks.Update. See the method description for details. +message UpdateHealthCheckRequest { + // Name of the HealthCheck resource to update. + string health_check = 308876645 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + HealthCheck health_check_resource = 201925032 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Instances.Update. See the method description for details. +message UpdateInstanceRequest { + // Specifies the action to take when updating an instance even if the updated properties do not require it. If not specified, then Compute Engine acts based on the minimum action that the updated properties require. + // Additional supported values which may be not listed in the enum directly due to technical reasons: + // INVALID + // NO_EFFECT + // REFRESH + // RESTART + enum MinimalAction { + // A value indicating that the enum field is not set. + UNDEFINED_MINIMAL_ACTION = 0; + + } + + // Specifies the most disruptive action that can be taken on the instance as part of the update. Compute Engine returns an error if the instance properties require a more disruptive action as part of the instance update. Valid options from lowest to highest are NO_EFFECT, REFRESH, and RESTART. + // Additional supported values which may be not listed in the enum directly due to technical reasons: + // INVALID + // NO_EFFECT + // REFRESH + // RESTART + enum MostDisruptiveAllowedAction { + // A value indicating that the enum field is not set. + UNDEFINED_MOST_DISRUPTIVE_ALLOWED_ACTION = 0; + + } + + // Name of the instance resource to update. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + Instance instance_resource = 215988344 [(google.api.field_behavior) = REQUIRED]; + + // Specifies the action to take when updating an instance even if the updated properties do not require it. If not specified, then Compute Engine acts based on the minimum action that the updated properties require. + // Check the MinimalAction enum for the list of possible values. + optional string minimal_action = 270567060; + + // Specifies the most disruptive action that can be taken on the instance as part of the update. Compute Engine returns an error if the instance properties require a more disruptive action as part of the instance update. Valid options from lowest to highest are NO_EFFECT, REFRESH, and RESTART. + // Check the MostDisruptiveAllowedAction enum for the list of possible values. + optional string most_disruptive_allowed_action = 66103053; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Instances.UpdateNetworkInterface. See the method description for details. +message UpdateNetworkInterfaceInstanceRequest { + // The instance name for this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // The name of the network interface to update. + string network_interface = 365387880 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + NetworkInterface network_interface_resource = 325814789 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Networks.UpdatePeering. See the method description for details. +message UpdatePeeringNetworkRequest { + // Name of the network resource which the updated peering is belonging to. + string network = 232872494 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + NetworksUpdatePeeringRequest networks_update_peering_request_resource = 224433497 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for InstanceGroupManagers.UpdatePerInstanceConfigs. See the method description for details. +message UpdatePerInstanceConfigsInstanceGroupManagerRequest { + // The name of the managed instance group. It should conform to RFC1035. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + InstanceGroupManagersUpdatePerInstanceConfigsReq instance_group_managers_update_per_instance_configs_req_resource = 141402302 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The name of the zone where the managed instance group is located. It should conform to RFC1035. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for RegionInstanceGroupManagers.UpdatePerInstanceConfigs. See the method description for details. +message UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest { + // The name of the managed instance group. It should conform to RFC1035. + string instance_group_manager = 249363395 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request, should conform to RFC1035. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // The body resource for this request + RegionInstanceGroupManagerUpdateInstanceConfigReq region_instance_group_manager_update_instance_config_req_resource = 89036583 [(google.api.field_behavior) = REQUIRED]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionAutoscalers.Update. See the method description for details. +message UpdateRegionAutoscalerRequest { + // Name of the autoscaler to update. + optional string autoscaler = 517258967; + + // The body resource for this request + Autoscaler autoscaler_resource = 207616118 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionBackendServices.Update. See the method description for details. +message UpdateRegionBackendServiceRequest { + // Name of the BackendService resource to update. + string backend_service = 306946058 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + BackendService backend_service_resource = 347586723 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionCommitments.Update. See the method description for details. +message UpdateRegionCommitmentRequest { + // Name of the commitment for which auto renew is being updated. + string commitment = 482134805 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + Commitment commitment_resource = 244240888 [(google.api.field_behavior) = REQUIRED]; + + optional string paths = 106438894; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // update_mask indicates fields to be updated as part of this request. + optional string update_mask = 500079778; + +} + +// A request message for RegionDisks.Update. See the method description for details. +message UpdateRegionDiskRequest { + // The disk name for this request. + string disk = 3083677 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + Disk disk_resource = 25880688 [(google.api.field_behavior) = REQUIRED]; + + optional string paths = 106438894; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // The name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // update_mask indicates fields to be updated as part of this request. + optional string update_mask = 500079778; + +} + +// A request message for RegionHealthChecks.Update. See the method description for details. +message UpdateRegionHealthCheckRequest { + // Name of the HealthCheck resource to update. + string health_check = 308876645 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + HealthCheck health_check_resource = 201925032 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for RegionUrlMaps.Update. See the method description for details. +message UpdateRegionUrlMapRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region scoping this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // begin_interface: MixerMutationRequestBuilder Request ID to support idempotency. + optional string request_id = 37109963; + + // Name of the UrlMap resource to update. + string url_map = 367020684 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + UrlMap url_map_resource = 168675425 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Reservations.Update. See the method description for details. +message UpdateReservationRequest { + optional string paths = 106438894; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the reservation to update. + string reservation = 47530956 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + Reservation reservation_resource = 285030177 [(google.api.field_behavior) = REQUIRED]; + + // Update_mask indicates fields to be updated as part of this request. + optional string update_mask = 500079778; + + // Name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for Routers.Update. See the method description for details. +message UpdateRouterRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the Router resource to update. + string router = 148608841 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + Router router_resource = 155222084 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Instances.UpdateShieldedInstanceConfig. See the method description for details. +message UpdateShieldedInstanceConfigInstanceRequest { + // Name or id of the instance scoping this request. + string instance = 18257045 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // The body resource for this request + ShieldedInstanceConfig shielded_instance_config_resource = 272059224 [(google.api.field_behavior) = REQUIRED]; + + // The name of the zone for this request. + string zone = 3744684 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "zone" + ]; + +} + +// A request message for UrlMaps.Update. See the method description for details. +message UpdateUrlMapRequest { + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + + // Name of the UrlMap resource to update. + string url_map = 367020684 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + UrlMap url_map_resource = 168675425 [(google.api.field_behavior) = REQUIRED]; + +} + +// Represents a URL Map resource. Compute Engine has two URL Map resources: * [Global](/compute/docs/reference/rest/v1/urlMaps) * [Regional](/compute/docs/reference/rest/v1/regionUrlMaps) A URL map resource is a component of certain types of cloud load balancers and Traffic Director: * urlMaps are used by external HTTP(S) load balancers and Traffic Director. * regionUrlMaps are used by internal HTTP(S) load balancers. For a list of supported URL map features by the load balancer type, see the Load balancing features: Routing and traffic management table. For a list of supported URL map features for Traffic Director, see the Traffic Director features: Routing and traffic management table. This resource defines mappings from hostnames and URL paths to either a backend service or a backend bucket. To use the global urlMaps resource, the backend service must have a loadBalancingScheme of either EXTERNAL or INTERNAL_SELF_MANAGED. To use the regionUrlMaps resource, the backend service must have a loadBalancingScheme of INTERNAL_MANAGED. For more information, read URL Map Concepts. +message UrlMap { + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // defaultRouteAction takes effect when none of the hostRules match. The load balancer performs advanced routing actions, such as URL rewrites and header transformations, before forwarding the request to the selected backend. If defaultRouteAction specifies any weightedBackendServices, defaultService must not be set. Conversely if defaultService is set, defaultRouteAction cannot contain any weightedBackendServices. Only one of defaultRouteAction or defaultUrlRedirect must be set. URL maps for Classic external HTTP(S) load balancers only support the urlRewrite action within defaultRouteAction. defaultRouteAction has no effect when the URL map is bound to a target gRPC proxy that has the validateForProxyless field set to true. + optional HttpRouteAction default_route_action = 378919466; + + // The full or partial URL of the defaultService resource to which traffic is directed if none of the hostRules match. If defaultRouteAction is also specified, advanced routing actions, such as URL rewrites, take effect before sending the request to the backend. However, if defaultService is specified, defaultRouteAction cannot contain any weightedBackendServices. Conversely, if routeAction specifies any weightedBackendServices, service must not be specified. Only one of defaultService, defaultUrlRedirect , or defaultRouteAction.weightedBackendService must be set. defaultService has no effect when the URL map is bound to a target gRPC proxy that has the validateForProxyless field set to true. + optional string default_service = 370242231; + + // When none of the specified hostRules match, the request is redirected to a URL specified by defaultUrlRedirect. If defaultUrlRedirect is specified, defaultService or defaultRouteAction must not be set. Not supported when the URL map is bound to a target gRPC proxy. + optional HttpRedirectAction default_url_redirect = 359503338; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field is ignored when inserting a UrlMap. An up-to-date fingerprint must be provided in order to update the UrlMap, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve a UrlMap. + optional string fingerprint = 234678500; + + // Specifies changes to request and response headers that need to take effect for the selected backendService. The headerAction specified here take effect after headerAction specified under pathMatcher. headerAction is not supported for load balancers that have their loadBalancingScheme set to EXTERNAL. Not supported when the URL map is bound to a target gRPC proxy that has validateForProxyless field set to true. + optional HttpHeaderAction header_action = 328077352; + + // The list of host rules to use against the URL. + repeated HostRule host_rules = 311804832; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#urlMaps for url maps. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // The list of named PathMatchers to use against the URL. + repeated PathMatcher path_matchers = 271664219; + + // [Output Only] URL of the region where the regional URL map resides. This field is not applicable to global URL maps. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // The list of expected URL mapping tests. Request to update the UrlMap succeeds only if all test cases pass. You can specify a maximum of 100 tests per UrlMap. Not supported when the URL map is bound to a target gRPC proxy that has validateForProxyless field set to true. + repeated UrlMapTest tests = 110251553; + +} + +// Contains a list of UrlMap resources. +message UrlMapList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of UrlMap resources. + repeated UrlMap items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message UrlMapReference { + optional string url_map = 367020684; + +} + +// Message for the expected URL mappings. +message UrlMapTest { + // Description of this test case. + optional string description = 422937596; + + // The expected output URL evaluated by the load balancer containing the scheme, host, path and query parameters. For rules that forward requests to backends, the test passes only when expectedOutputUrl matches the request forwarded by the load balancer to backends. For rules with urlRewrite, the test verifies that the forwarded request matches hostRewrite and pathPrefixRewrite in the urlRewrite action. When service is specified, expectedOutputUrl`s scheme is ignored. For rules with urlRedirect, the test passes only if expectedOutputUrl matches the URL in the load balancer's redirect response. If urlRedirect specifies https_redirect, the test passes only if the scheme in expectedOutputUrl is also set to HTTPS. If urlRedirect specifies strip_query, the test passes only if expectedOutputUrl does not contain any query parameters. expectedOutputUrl is optional when service is specified. + optional string expected_output_url = 433967384; + + // For rules with urlRedirect, the test passes only if expectedRedirectResponseCode matches the HTTP status code in load balancer's redirect response. expectedRedirectResponseCode cannot be set when service is set. + optional int32 expected_redirect_response_code = 18888047; + + // HTTP headers for this request. If headers contains a host header, then host must also match the header value. + repeated UrlMapTestHeader headers = 258436998; + + // Host portion of the URL. If headers contains a host header, then host must also match the header value. + optional string host = 3208616; + + // Path portion of the URL. + optional string path = 3433509; + + // Expected BackendService or BackendBucket resource the given URL should be mapped to. The service field cannot be set if expectedRedirectResponseCode is set. + optional string service = 373540533; + +} + +// HTTP headers used in UrlMapTests. +message UrlMapTestHeader { + // Header name. + optional string name = 3373707; + + // Header value. + optional string value = 111972721; + +} + +// Message representing the validation result for a UrlMap. +message UrlMapValidationResult { + repeated string load_errors = 310147300; + + // Whether the given UrlMap can be successfully loaded. If false, 'loadErrors' indicates the reasons. + optional bool load_succeeded = 128326216; + + repeated TestFailure test_failures = 505934134; + + // If successfully loaded, this field indicates whether the test passed. If false, 'testFailures's indicate the reason of failure. + optional bool test_passed = 192708797; + +} + +// +message UrlMapsAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of UrlMapsScopedList resources. + map items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message UrlMapsScopedList { + // A list of UrlMaps contained in this scope. + repeated UrlMap url_maps = 103352167; + + // Informational warning which replaces the list of backend services when the list is empty. + optional Warning warning = 50704284; + +} + +// +message UrlMapsValidateRequest { + // + enum LoadBalancingSchemes { + // A value indicating that the enum field is not set. + UNDEFINED_LOAD_BALANCING_SCHEMES = 0; + + // Signifies that this will be used for Classic L7 External Load Balancing. + EXTERNAL = 35607499; + + // Signifies that this will be used for Envoy-based L7 External Load Balancing. + EXTERNAL_MANAGED = 512006923; + + // If unspecified, the validation will try to infer the scheme from the backend service resources this Url map references. If the inferrence is not possible, EXTERNAL will be used as the default type. + LOAD_BALANCING_SCHEME_UNSPECIFIED = 526507452; + + } + + // Specifies the load balancer type(s) this validation request is for. Use EXTERNAL_MANAGED for HTTP/HTTPS External Global Load Balancer with Advanced Traffic Management. Use EXTERNAL for Classic HTTP/HTTPS External Global Load Balancer. Other load balancer types are not supported. For more information, refer to Choosing a load balancer. If unspecified, the load balancing scheme will be inferred from the backend service resources this URL map references. If that can not be inferred (for example, this URL map only references backend buckets, or this Url map is for rewrites and redirects only and doesn't reference any backends), EXTERNAL will be used as the default type. If specified, the scheme(s) must not conflict with the load balancing scheme of the backend service resources this Url map references. + // Check the LoadBalancingSchemes enum for the list of possible values. + repeated string load_balancing_schemes = 6308527; + + // Content of the UrlMap to be validated. + optional UrlMap resource = 195806222; + +} + +// +message UrlMapsValidateResponse { + optional UrlMapValidationResult result = 139315229; + +} + +// The spec for modifying the path before sending the request to the matched backend service. +message UrlRewrite { + // Before forwarding the request to the selected service, the request's host header is replaced with contents of hostRewrite. The value must be from 1 to 255 characters. + optional string host_rewrite = 159819253; + + // Before forwarding the request to the selected backend service, the matching portion of the request's path is replaced by pathPrefixRewrite. The value must be from 1 to 1024 characters. + optional string path_prefix_rewrite = 41186361; + +} + +// Subnetwork which the current user has compute.subnetworks.use permission on. +message UsableSubnetwork { + // The access type of IPv6 address this subnet holds. It's immutable and can only be specified during creation or the first time the subnet is updated into IPV4_IPV6 dual stack. + enum Ipv6AccessType { + // A value indicating that the enum field is not set. + UNDEFINED_IPV6_ACCESS_TYPE = 0; + + // VMs on this subnet will be assigned IPv6 addresses that are accessible via the Internet, as well as the VPC network. + EXTERNAL = 35607499; + + // VMs on this subnet will be assigned IPv6 addresses that are only accessible over the VPC network. + INTERNAL = 279295677; + + } + + // The purpose of the resource. This field can be either PRIVATE_RFC_1918 or INTERNAL_HTTPS_LOAD_BALANCER. A subnetwork with purpose set to INTERNAL_HTTPS_LOAD_BALANCER is a user-created subnetwork that is reserved for Internal HTTP(S) Load Balancing. If unspecified, the purpose defaults to PRIVATE_RFC_1918. The enableFlowLogs field isn't supported with the purpose field set to INTERNAL_HTTPS_LOAD_BALANCER. + enum Purpose { + // A value indicating that the enum field is not set. + UNDEFINED_PURPOSE = 0; + + // Subnet reserved for Internal HTTP(S) Load Balancing. + INTERNAL_HTTPS_LOAD_BALANCER = 248748889; + + // Regular user created or automatically created subnet. + PRIVATE = 403485027; + + // Regular user created or automatically created subnet. + PRIVATE_RFC_1918 = 254902107; + + // Subnetworks created for Private Service Connect in the producer network. + PRIVATE_SERVICE_CONNECT = 48134724; + + // Subnetwork used for Regional Internal/External HTTP(S) Load Balancing. + REGIONAL_MANAGED_PROXY = 153049966; + + } + + // The role of subnetwork. Currently, this field is only used when purpose = INTERNAL_HTTPS_LOAD_BALANCER. The value can be set to ACTIVE or BACKUP. An ACTIVE subnetwork is one that is currently being used for Internal HTTP(S) Load Balancing. A BACKUP subnetwork is one that is ready to be promoted to ACTIVE or is currently draining. This field can be updated with a patch request. + enum Role { + // A value indicating that the enum field is not set. + UNDEFINED_ROLE = 0; + + // The ACTIVE subnet that is currently used. + ACTIVE = 314733318; + + // The BACKUP subnet that could be promoted to ACTIVE. + BACKUP = 341010882; + + } + + // The stack type for the subnet. If set to IPV4_ONLY, new VMs in the subnet are assigned IPv4 addresses only. If set to IPV4_IPV6, new VMs in the subnet can be assigned both IPv4 and IPv6 addresses. If not specified, IPV4_ONLY is used. This field can be both set at resource creation time and updated using patch. + enum StackType { + // A value indicating that the enum field is not set. + UNDEFINED_STACK_TYPE = 0; + + // New VMs in this subnet can have both IPv4 and IPv6 addresses. + IPV4_IPV6 = 22197249; + + // New VMs in this subnet will only be assigned IPv4 addresses. + IPV4_ONLY = 22373798; + + } + + // [Output Only] The external IPv6 address range that is assigned to this subnetwork. + optional string external_ipv6_prefix = 139299190; + + // [Output Only] The internal IPv6 address range that is assigned to this subnetwork. + optional string internal_ipv6_prefix = 506270056; + + // The range of internal addresses that are owned by this subnetwork. + optional string ip_cidr_range = 98117322; + + // The access type of IPv6 address this subnet holds. It's immutable and can only be specified during creation or the first time the subnet is updated into IPV4_IPV6 dual stack. + // Check the Ipv6AccessType enum for the list of possible values. + optional string ipv6_access_type = 504658653; + + // Network URL. + optional string network = 232872494; + + // The purpose of the resource. This field can be either PRIVATE_RFC_1918 or INTERNAL_HTTPS_LOAD_BALANCER. A subnetwork with purpose set to INTERNAL_HTTPS_LOAD_BALANCER is a user-created subnetwork that is reserved for Internal HTTP(S) Load Balancing. If unspecified, the purpose defaults to PRIVATE_RFC_1918. The enableFlowLogs field isn't supported with the purpose field set to INTERNAL_HTTPS_LOAD_BALANCER. + // Check the Purpose enum for the list of possible values. + optional string purpose = 316407070; + + // The role of subnetwork. Currently, this field is only used when purpose = INTERNAL_HTTPS_LOAD_BALANCER. The value can be set to ACTIVE or BACKUP. An ACTIVE subnetwork is one that is currently being used for Internal HTTP(S) Load Balancing. A BACKUP subnetwork is one that is ready to be promoted to ACTIVE or is currently draining. This field can be updated with a patch request. + // Check the Role enum for the list of possible values. + optional string role = 3506294; + + // Secondary IP ranges. + repeated UsableSubnetworkSecondaryRange secondary_ip_ranges = 136658915; + + // The stack type for the subnet. If set to IPV4_ONLY, new VMs in the subnet are assigned IPv4 addresses only. If set to IPV4_IPV6, new VMs in the subnet can be assigned both IPv4 and IPv6 addresses. If not specified, IPV4_ONLY is used. This field can be both set at resource creation time and updated using patch. + // Check the StackType enum for the list of possible values. + optional string stack_type = 425908881; + + // Subnetwork URL. + optional string subnetwork = 307827694; + +} + +// Secondary IP range of a usable subnetwork. +message UsableSubnetworkSecondaryRange { + // The range of IP addresses belonging to this subnetwork secondary range. + optional string ip_cidr_range = 98117322; + + // The name associated with this subnetwork secondary range, used when adding an alias IP range to a VM instance. The name must be 1-63 characters long, and comply with RFC1035. The name must be unique within the subnetwork. + optional string range_name = 332216397; + +} + +// +message UsableSubnetworksAggregatedList { + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional string id = 3355; + + // [Output] A list of usable subnetwork URLs. + repeated UsableSubnetwork items = 100526016; + + // [Output Only] Type of resource. Always compute#usableSubnetworksAggregatedList for aggregated lists of usable subnetworks. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. In special cases listUsable may return 0 subnetworks and nextPageToken which still should be used to get the next page of results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// The location in Cloud Storage and naming method of the daily usage report. Contains bucket_name and report_name prefix. +message UsageExportLocation { + // The name of an existing bucket in Cloud Storage where the usage report object is stored. The Google Service Account is granted write access to this bucket. This can either be the bucket name by itself, such as example-bucket, or the bucket name with gs:// or https://storage.googleapis.com/ in front of it, such as gs://example-bucket. + optional string bucket_name = 283610048; + + // An optional prefix for the name of the usage report object stored in bucketName. If not supplied, defaults to usage_gce. The report is stored as a CSV file named report_name_prefix_gce_YYYYMMDD.csv where YYYYMMDD is the day of the usage according to Pacific Time. If you supply a prefix, it should conform to Cloud Storage object naming conventions. + optional string report_name_prefix = 320198715; + +} + +// A request message for RegionUrlMaps.Validate. See the method description for details. +message ValidateRegionUrlMapRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region scoping this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + RegionUrlMapsValidateRequest region_url_maps_validate_request_resource = 56632858 [(google.api.field_behavior) = REQUIRED]; + + // Name of the UrlMap resource to be validated as. + string url_map = 367020684 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for UrlMaps.Validate. See the method description for details. +message ValidateUrlMapRequest { + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the UrlMap resource to be validated as. + string url_map = 367020684 [(google.api.field_behavior) = REQUIRED]; + + // The body resource for this request + UrlMapsValidateRequest url_maps_validate_request_resource = 395913455 [(google.api.field_behavior) = REQUIRED]; + +} + +// Contain information of Nat mapping for a VM endpoint (i.e., NIC). +message VmEndpointNatMappings { + // Name of the VM instance which the endpoint belongs to + optional string instance_name = 227947509; + + repeated VmEndpointNatMappingsInterfaceNatMappings interface_nat_mappings = 256196617; + +} + +// Contain information of Nat mapping for an interface of this endpoint. +message VmEndpointNatMappingsInterfaceNatMappings { + // List of all drain IP:port-range mappings assigned to this interface. These ranges are inclusive, that is, both the first and the last ports can be used for NAT. Example: ["2.2.2.2:12345-12355", "1.1.1.1:2234-2234"]. + repeated string drain_nat_ip_port_ranges = 395440577; + + // A list of all IP:port-range mappings assigned to this interface. These ranges are inclusive, that is, both the first and the last ports can be used for NAT. Example: ["2.2.2.2:12345-12355", "1.1.1.1:2234-2234"]. + repeated string nat_ip_port_ranges = 531830810; + + // Total number of drain ports across all NAT IPs allocated to this interface. It equals to the aggregated port number in the field drain_nat_ip_port_ranges. + optional int32 num_total_drain_nat_ports = 335532793; + + // Total number of ports across all NAT IPs allocated to this interface. It equals to the aggregated port number in the field nat_ip_port_ranges. + optional int32 num_total_nat_ports = 299904384; + + // Information about mappings provided by rules in this NAT. + repeated VmEndpointNatMappingsInterfaceNatMappingsNatRuleMappings rule_mappings = 486192968; + + // Alias IP range for this interface endpoint. It will be a private (RFC 1918) IP range. Examples: "10.33.4.55/32", or "192.168.5.0/24". + optional string source_alias_ip_range = 440340952; + + // Primary IP of the VM for this NIC. + optional string source_virtual_ip = 149836159; + +} + +// Contains information of NAT Mappings provided by a NAT Rule. +message VmEndpointNatMappingsInterfaceNatMappingsNatRuleMappings { + // List of all drain IP:port-range mappings assigned to this interface by this rule. These ranges are inclusive, that is, both the first and the last ports can be used for NAT. Example: ["2.2.2.2:12345-12355", "1.1.1.1:2234-2234"]. + repeated string drain_nat_ip_port_ranges = 395440577; + + // A list of all IP:port-range mappings assigned to this interface by this rule. These ranges are inclusive, that is, both the first and the last ports can be used for NAT. Example: ["2.2.2.2:12345-12355", "1.1.1.1:2234-2234"]. + repeated string nat_ip_port_ranges = 531830810; + + // Total number of drain ports across all NAT IPs allocated to this interface by this rule. It equals the aggregated port number in the field drain_nat_ip_port_ranges. + optional int32 num_total_drain_nat_ports = 335532793; + + // Total number of ports across all NAT IPs allocated to this interface by this rule. It equals the aggregated port number in the field nat_ip_port_ranges. + optional int32 num_total_nat_ports = 299904384; + + // Rule number of the NAT Rule. + optional int32 rule_number = 535211500; + +} + +// Contains a list of VmEndpointNatMappings. +message VmEndpointNatMappingsList { + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional string id = 3355; + + // [Output Only] Type of resource. Always compute#vmEndpointNatMappingsList for lists of Nat mappings of VM endpoints. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] A list of Nat mapping information of VM endpoints. + repeated VmEndpointNatMappings result = 139315229; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Represents a HA VPN gateway. HA VPN is a high-availability (HA) Cloud VPN solution that lets you securely connect your on-premises network to your Google Cloud Virtual Private Cloud network through an IPsec VPN connection in a single region. For more information about Cloud HA VPN solutions, see Cloud VPN topologies . +message VpnGateway { + // The stack type for this VPN gateway to identify the IP protocols that are enabled. Possible values are: IPV4_ONLY, IPV4_IPV6. If not specified, IPV4_ONLY will be used. + enum StackType { + // A value indicating that the enum field is not set. + UNDEFINED_STACK_TYPE = 0; + + // Enable VPN gateway with both IPv4 and IPv6 protocols. + IPV4_IPV6 = 22197249; + + // Enable VPN gateway with only IPv4 protocol. + IPV4_ONLY = 22373798; + + } + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of resource. Always compute#vpnGateway for VPN gateways. + optional string kind = 3292052; + + // A fingerprint for the labels being applied to this VpnGateway, which is essentially a hash of the labels set used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update labels. You must always provide an up-to-date fingerprint hash in order to update or change labels, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve a VpnGateway. + optional string label_fingerprint = 178124825; + + // Labels for this resource. These can only be added or modified by the setLabels method. Each label key/value pair must comply with RFC1035. Label values may be empty. + map labels = 500195327; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // URL of the network to which this VPN gateway is attached. Provided by the client when the VPN gateway is created. + optional string network = 232872494; + + // [Output Only] URL of the region where the VPN gateway resides. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // The stack type for this VPN gateway to identify the IP protocols that are enabled. Possible values are: IPV4_ONLY, IPV4_IPV6. If not specified, IPV4_ONLY will be used. + // Check the StackType enum for the list of possible values. + optional string stack_type = 425908881; + + // The list of VPN interfaces associated with this VPN gateway. + repeated VpnGatewayVpnGatewayInterface vpn_interfaces = 91842181; + +} + +// +message VpnGatewayAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of VpnGateway resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#vpnGateway for VPN gateways. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of VpnGateway resources. +message VpnGatewayList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of VpnGateway resources. + repeated VpnGateway items = 100526016; + + // [Output Only] Type of resource. Always compute#vpnGateway for VPN gateways. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message VpnGatewayStatus { + // List of VPN connection for this VpnGateway. + repeated VpnGatewayStatusVpnConnection vpn_connections = 439334538; + +} + +// Describes the high availability requirement state for the VPN connection between this Cloud VPN gateway and a peer gateway. +message VpnGatewayStatusHighAvailabilityRequirementState { + // Indicates the high availability requirement state for the VPN connection. Valid values are CONNECTION_REDUNDANCY_MET, CONNECTION_REDUNDANCY_NOT_MET. + enum State { + // A value indicating that the enum field is not set. + UNDEFINED_STATE = 0; + + // VPN tunnels are configured with adequate redundancy from Cloud VPN gateway to the peer VPN gateway. For both GCP-to-non-GCP and GCP-to-GCP connections, the adequate redundancy is a pre-requirement for users to get 99.99% availability on GCP side; please note that for any connection, end-to-end 99.99% availability is subject to proper configuration on the peer VPN gateway. + CONNECTION_REDUNDANCY_MET = 505242907; + + // VPN tunnels are not configured with adequate redundancy from the Cloud VPN gateway to the peer gateway + CONNECTION_REDUNDANCY_NOT_MET = 511863311; + + } + + // Indicates the reason why the VPN connection does not meet the high availability redundancy criteria/requirement. Valid values is INCOMPLETE_TUNNELS_COVERAGE. + enum UnsatisfiedReason { + // A value indicating that the enum field is not set. + UNDEFINED_UNSATISFIED_REASON = 0; + + INCOMPLETE_TUNNELS_COVERAGE = 55917437; + + } + + // Indicates the high availability requirement state for the VPN connection. Valid values are CONNECTION_REDUNDANCY_MET, CONNECTION_REDUNDANCY_NOT_MET. + // Check the State enum for the list of possible values. + optional string state = 109757585; + + // Indicates the reason why the VPN connection does not meet the high availability redundancy criteria/requirement. Valid values is INCOMPLETE_TUNNELS_COVERAGE. + // Check the UnsatisfiedReason enum for the list of possible values. + optional string unsatisfied_reason = 55016330; + +} + +// Contains some information about a VPN tunnel. +message VpnGatewayStatusTunnel { + // The VPN gateway interface this VPN tunnel is associated with. + optional uint32 local_gateway_interface = 158764330; + + // The peer gateway interface this VPN tunnel is connected to, the peer gateway could either be an external VPN gateway or GCP VPN gateway. + optional uint32 peer_gateway_interface = 214380385; + + // URL reference to the VPN tunnel. + optional string tunnel_url = 78975256; + +} + +// A VPN connection contains all VPN tunnels connected from this VpnGateway to the same peer gateway. The peer gateway could either be a external VPN gateway or GCP VPN gateway. +message VpnGatewayStatusVpnConnection { + // URL reference to the peer external VPN gateways to which the VPN tunnels in this VPN connection are connected. This field is mutually exclusive with peer_gcp_gateway. + optional string peer_external_gateway = 384956173; + + // URL reference to the peer side VPN gateways to which the VPN tunnels in this VPN connection are connected. This field is mutually exclusive with peer_gcp_gateway. + optional string peer_gcp_gateway = 281867452; + + // HighAvailabilityRequirementState for the VPN connection. + optional VpnGatewayStatusHighAvailabilityRequirementState state = 109757585; + + // List of VPN tunnels that are in this VPN connection. + repeated VpnGatewayStatusTunnel tunnels = 104561931; + +} + +// A VPN gateway interface. +message VpnGatewayVpnGatewayInterface { + // [Output Only] Numeric identifier for this VPN interface associated with the VPN gateway. + optional uint32 id = 3355; + + // URL of the VLAN attachment (interconnectAttachment) resource for this VPN gateway interface. When the value of this field is present, the VPN gateway is used for HA VPN over Cloud Interconnect; all egress or ingress traffic for this VPN gateway interface goes through the specified VLAN attachment resource. + optional string interconnect_attachment = 308135284; + + // [Output Only] IP address for this VPN interface associated with the VPN gateway. The IP address could be either a regional external IP address or a regional internal IP address. The two IP addresses for a VPN gateway must be all regional external or regional internal IP addresses. There cannot be a mix of regional external IP addresses and regional internal IP addresses. For HA VPN over Cloud Interconnect, the IP addresses for both interfaces could either be regional internal IP addresses or regional external IP addresses. For regular (non HA VPN over Cloud Interconnect) HA VPN tunnels, the IP address must be a regional external IP address. + optional string ip_address = 406272220; + +} + +// +message VpnGatewaysGetStatusResponse { + optional VpnGatewayStatus result = 139315229; + +} + +// +message VpnGatewaysScopedList { + // [Output Only] A list of VPN gateways contained in this scope. + repeated VpnGateway vpn_gateways = 259177882; + + // [Output Only] Informational warning which replaces the list of addresses when the list is empty. + optional Warning warning = 50704284; + +} + +// Represents a Cloud VPN Tunnel resource. For more information about VPN, read the the Cloud VPN Overview. +message VpnTunnel { + // [Output Only] The status of the VPN tunnel, which can be one of the following: - PROVISIONING: Resource is being allocated for the VPN tunnel. - WAITING_FOR_FULL_CONFIG: Waiting to receive all VPN-related configs from the user. Network, TargetVpnGateway, VpnTunnel, ForwardingRule, and Route resources are needed to setup the VPN tunnel. - FIRST_HANDSHAKE: Successful first handshake with the peer VPN. - ESTABLISHED: Secure session is successfully established with the peer VPN. - NETWORK_ERROR: Deprecated, replaced by NO_INCOMING_PACKETS - AUTHORIZATION_ERROR: Auth error (for example, bad shared secret). - NEGOTIATION_FAILURE: Handshake failed. - DEPROVISIONING: Resources are being deallocated for the VPN tunnel. - FAILED: Tunnel creation has failed and the tunnel is not ready to be used. - NO_INCOMING_PACKETS: No incoming packets from peer. - REJECTED: Tunnel configuration was rejected, can be result of being denied access. - ALLOCATING_RESOURCES: Cloud VPN is in the process of allocating all required resources. - STOPPED: Tunnel is stopped due to its Forwarding Rules being deleted for Classic VPN tunnels or the project is in frozen state. - PEER_IDENTITY_MISMATCH: Peer identity does not match peer IP, probably behind NAT. - TS_NARROWING_NOT_ALLOWED: Traffic selector narrowing not allowed for an HA-VPN tunnel. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + // Cloud VPN is in the process of allocating all required resources (specifically, a borg task). + ALLOCATING_RESOURCES = 320922816; + + // Auth error (e.g. bad shared secret). + AUTHORIZATION_ERROR = 23580290; + + // Resources is being deallocated for the VPN tunnel. + DEPROVISIONING = 428935662; + + // Secure session is successfully established with peer VPN. + ESTABLISHED = 88852344; + + // Tunnel creation has failed and the tunnel is not ready to be used. + FAILED = 455706685; + + // Successful first handshake with peer VPN. + FIRST_HANDSHAKE = 191393000; + + // Handshake failed. + NEGOTIATION_FAILURE = 360325868; + + // Deprecated, replaced by NO_INCOMING_PACKETS + NETWORK_ERROR = 193912951; + + // No incoming packets from peer + NO_INCOMING_PACKETS = 119983216; + + // Resource is being allocated for the VPN tunnel. + PROVISIONING = 290896621; + + // Tunnel configuration was rejected, can be result of being denylisted. + REJECTED = 174130302; + + // Tunnel is stopped due to its Forwarding Rules being deleted. + STOPPED = 444276141; + + // Waiting to receive all VPN-related configs from user. Network, TargetVpnGateway, VpnTunnel, ForwardingRule and Route resources are needed to setup VPN tunnel. + WAITING_FOR_FULL_CONFIG = 41640522; + + } + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this property when you create the resource. + optional string description = 422937596; + + // [Output Only] Detailed status message for the VPN tunnel. + optional string detailed_status = 333501025; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // IKE protocol version to use when establishing the VPN tunnel with the peer VPN gateway. Acceptable IKE versions are 1 or 2. The default version is 2. + optional int32 ike_version = 218376220; + + // [Output Only] Type of resource. Always compute#vpnTunnel for VPN tunnels. + optional string kind = 3292052; + + // Local traffic selector to use when establishing the VPN tunnel with the peer VPN gateway. The value should be a CIDR formatted string, for example: 192.168.0.0/16. The ranges must be disjoint. Only IPv4 is supported. + repeated string local_traffic_selector = 317314613; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + optional string name = 3373707; + + // URL of the peer side external VPN gateway to which this VPN tunnel is connected. Provided by the client when the VPN tunnel is created. This field is exclusive with the field peerGcpGateway. + optional string peer_external_gateway = 384956173; + + // The interface ID of the external VPN gateway to which this VPN tunnel is connected. Provided by the client when the VPN tunnel is created. Possible values are: `0`, `1`, `2`, `3`. The number of IDs in use depends on the external VPN gateway redundancy type. + optional int32 peer_external_gateway_interface = 452768391; + + // URL of the peer side HA GCP VPN gateway to which this VPN tunnel is connected. Provided by the client when the VPN tunnel is created. This field can be used when creating highly available VPN from VPC network to VPC network, the field is exclusive with the field peerExternalGateway. If provided, the VPN tunnel will automatically use the same vpnGatewayInterface ID in the peer GCP VPN gateway. + optional string peer_gcp_gateway = 281867452; + + // IP address of the peer VPN gateway. Only IPv4 is supported. + optional string peer_ip = 383249700; + + // [Output Only] URL of the region where the VPN tunnel resides. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + optional string region = 138946292; + + // Remote traffic selectors to use when establishing the VPN tunnel with the peer VPN gateway. The value should be a CIDR formatted string, for example: 192.168.0.0/16. The ranges should be disjoint. Only IPv4 is supported. + repeated string remote_traffic_selector = 358887098; + + // URL of the router resource to be used for dynamic routing. + optional string router = 148608841; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // Shared secret used to set the secure session between the Cloud VPN gateway and the peer VPN gateway. + optional string shared_secret = 381932490; + + // Hash of the shared secret. + optional string shared_secret_hash = 398881891; + + // [Output Only] The status of the VPN tunnel, which can be one of the following: - PROVISIONING: Resource is being allocated for the VPN tunnel. - WAITING_FOR_FULL_CONFIG: Waiting to receive all VPN-related configs from the user. Network, TargetVpnGateway, VpnTunnel, ForwardingRule, and Route resources are needed to setup the VPN tunnel. - FIRST_HANDSHAKE: Successful first handshake with the peer VPN. - ESTABLISHED: Secure session is successfully established with the peer VPN. - NETWORK_ERROR: Deprecated, replaced by NO_INCOMING_PACKETS - AUTHORIZATION_ERROR: Auth error (for example, bad shared secret). - NEGOTIATION_FAILURE: Handshake failed. - DEPROVISIONING: Resources are being deallocated for the VPN tunnel. - FAILED: Tunnel creation has failed and the tunnel is not ready to be used. - NO_INCOMING_PACKETS: No incoming packets from peer. - REJECTED: Tunnel configuration was rejected, can be result of being denied access. - ALLOCATING_RESOURCES: Cloud VPN is in the process of allocating all required resources. - STOPPED: Tunnel is stopped due to its Forwarding Rules being deleted for Classic VPN tunnels or the project is in frozen state. - PEER_IDENTITY_MISMATCH: Peer identity does not match peer IP, probably behind NAT. - TS_NARROWING_NOT_ALLOWED: Traffic selector narrowing not allowed for an HA-VPN tunnel. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // URL of the Target VPN gateway with which this VPN tunnel is associated. Provided by the client when the VPN tunnel is created. + optional string target_vpn_gateway = 532512843; + + // URL of the VPN gateway with which this VPN tunnel is associated. Provided by the client when the VPN tunnel is created. This must be used (instead of target_vpn_gateway) if a High Availability VPN gateway resource is created. + optional string vpn_gateway = 406684153; + + // The interface ID of the VPN gateway with which this VPN tunnel is associated. Possible values are: `0`, `1`. + optional int32 vpn_gateway_interface = 95979123; + +} + +// +message VpnTunnelAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of VpnTunnelsScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#vpnTunnel for VPN tunnels. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Unreachable resources. + repeated string unreachables = 243372063; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of VpnTunnel resources. +message VpnTunnelList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of VpnTunnel resources. + repeated VpnTunnel items = 100526016; + + // [Output Only] Type of resource. Always compute#vpnTunnel for VPN tunnels. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message VpnTunnelsScopedList { + // A list of VPN tunnels contained in this scope. + repeated VpnTunnel vpn_tunnels = 163494080; + + // Informational warning which replaces the list of addresses when the list is empty. + optional Warning warning = 50704284; + +} + +// +message WafExpressionSet { + // A list of alternate IDs. The format should be: - E.g. XSS-stable Generic suffix like "stable" is particularly useful if a policy likes to avail newer set of expressions without having to change the policy. A given alias name can't be used for more than one entity set. + repeated string aliases = 159207166; + + // List of available expressions. + repeated WafExpressionSetExpression expressions = 175554779; + + // Google specified expression set ID. The format should be: - E.g. XSS-20170329 required + optional string id = 3355; + +} + +// +message WafExpressionSetExpression { + // Expression ID should uniquely identify the origin of the expression. E.g. owasp-crs-v020901-id973337 identifies Owasp core rule set version 2.9.1 rule id 973337. The ID could be used to determine the individual attack definition that has been detected. It could also be used to exclude it from the policy in case of false positive. required + optional string id = 3355; + + // The sensitivity value associated with the WAF rule ID. This corresponds to the ModSecurity paranoia level, ranging from 1 to 4. 0 is reserved for opt-in only rules. + optional int32 sensitivity = 27532959; + +} + +// A request message for GlobalOperations.Wait. See the method description for details. +message WaitGlobalOperationRequest { + // Name of the Operations resource to return. + string operation = 52090215 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for RegionOperations.Wait. See the method description for details. +message WaitRegionOperationRequest { + // Name of the Operations resource to return. + string operation = 52090215 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for ZoneOperations.Wait. See the method description for details. +message WaitZoneOperationRequest { + // Name of the Operations resource to return. + string operation = 52090215 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the zone for this request. + string zone = 3744684 [(google.api.field_behavior) = REQUIRED]; + +} + +// [Output Only] Informational warning message. +message Warning { + // [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. + enum Code { + // A value indicating that the enum field is not set. + UNDEFINED_CODE = 0; + + // Warning about failed cleanup of transient changes made by a failed operation. + CLEANUP_FAILED = 150308440; + + // A link to a deprecated resource was created. + DEPRECATED_RESOURCE_USED = 391835586; + + // When deploying and at least one of the resources has a type marked as deprecated + DEPRECATED_TYPE_USED = 346526230; + + // The user created a boot disk that is larger than image size. + DISK_SIZE_LARGER_THAN_IMAGE_SIZE = 369442967; + + // When deploying and at least one of the resources has a type marked as experimental + EXPERIMENTAL_TYPE_USED = 451954443; + + // Warning that is present in an external api call + EXTERNAL_API_WARNING = 175546307; + + // Warning that value of a field has been overridden. Deprecated unused field. + FIELD_VALUE_OVERRIDEN = 329669423; + + // The operation involved use of an injected kernel, which is deprecated. + INJECTED_KERNELS_DEPRECATED = 417377419; + + // A WEIGHTED_MAGLEV backend service is associated with a health check that is not of type HTTP/HTTPS/HTTP2. + INVALID_HEALTH_CHECK_FOR_DYNAMIC_WIEGHTED_LB = 401542606; + + // When deploying a deployment with a exceedingly large number of resources + LARGE_DEPLOYMENT_WARNING = 481440678; + + // A resource depends on a missing type + MISSING_TYPE_DEPENDENCY = 344505463; + + // The route's nextHopIp address is not assigned to an instance on the network. + NEXT_HOP_ADDRESS_NOT_ASSIGNED = 324964999; + + // The route's next hop instance cannot ip forward. + NEXT_HOP_CANNOT_IP_FORWARD = 383382887; + + // The route's nextHopInstance URL refers to an instance that does not have an ipv6 interface on the same network as the route. + NEXT_HOP_INSTANCE_HAS_NO_IPV6_INTERFACE = 146748434; + + // The route's nextHopInstance URL refers to an instance that does not exist. + NEXT_HOP_INSTANCE_NOT_FOUND = 464250446; + + // The route's nextHopInstance URL refers to an instance that is not on the same network as the route. + NEXT_HOP_INSTANCE_NOT_ON_NETWORK = 243758146; + + // The route's next hop instance does not have a status of RUNNING. + NEXT_HOP_NOT_RUNNING = 417081265; + + // Error which is not critical. We decided to continue the process despite the mentioned error. + NOT_CRITICAL_ERROR = 105763924; + + // No results are present on a particular list page. + NO_RESULTS_ON_PAGE = 30036744; + + // Success is reported, but some results may be missing due to errors + PARTIAL_SUCCESS = 39966469; + + // The user attempted to use a resource that requires a TOS they have not accepted. + REQUIRED_TOS_AGREEMENT = 3745539; + + // Warning that a resource is in use. + RESOURCE_IN_USE_BY_OTHER_RESOURCE_WARNING = 496728641; + + // One or more of the resources set to auto-delete could not be deleted because they were in use. + RESOURCE_NOT_DELETED = 168598460; + + // When a resource schema validation is ignored. + SCHEMA_VALIDATION_IGNORED = 275245642; + + // Instance template used in instance group manager is valid as such, but its application does not make a lot of sense, because it allows only single instance in instance group. + SINGLE_INSTANCE_PROPERTY_TEMPLATE = 268305617; + + // When undeclared properties in the schema are present + UNDECLARED_PROPERTIES = 390513439; + + // A given scope cannot be reached. + UNREACHABLE = 13328052; + + } + + // [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. + // Check the Code enum for the list of possible values. + optional string code = 3059181; + + // [Output Only] Metadata about this warning in key: value format. For example: "data": [ { "key": "scope", "value": "zones/us-east1-d" } + repeated Data data = 3076010; + + // [Output Only] A human-readable description of the warning code. + optional string message = 418054151; + +} + +// +message Warnings { + // [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. + enum Code { + // A value indicating that the enum field is not set. + UNDEFINED_CODE = 0; + + // Warning about failed cleanup of transient changes made by a failed operation. + CLEANUP_FAILED = 150308440; + + // A link to a deprecated resource was created. + DEPRECATED_RESOURCE_USED = 391835586; + + // When deploying and at least one of the resources has a type marked as deprecated + DEPRECATED_TYPE_USED = 346526230; + + // The user created a boot disk that is larger than image size. + DISK_SIZE_LARGER_THAN_IMAGE_SIZE = 369442967; + + // When deploying and at least one of the resources has a type marked as experimental + EXPERIMENTAL_TYPE_USED = 451954443; + + // Warning that is present in an external api call + EXTERNAL_API_WARNING = 175546307; + + // Warning that value of a field has been overridden. Deprecated unused field. + FIELD_VALUE_OVERRIDEN = 329669423; + + // The operation involved use of an injected kernel, which is deprecated. + INJECTED_KERNELS_DEPRECATED = 417377419; + + // A WEIGHTED_MAGLEV backend service is associated with a health check that is not of type HTTP/HTTPS/HTTP2. + INVALID_HEALTH_CHECK_FOR_DYNAMIC_WIEGHTED_LB = 401542606; + + // When deploying a deployment with a exceedingly large number of resources + LARGE_DEPLOYMENT_WARNING = 481440678; + + // A resource depends on a missing type + MISSING_TYPE_DEPENDENCY = 344505463; + + // The route's nextHopIp address is not assigned to an instance on the network. + NEXT_HOP_ADDRESS_NOT_ASSIGNED = 324964999; + + // The route's next hop instance cannot ip forward. + NEXT_HOP_CANNOT_IP_FORWARD = 383382887; + + // The route's nextHopInstance URL refers to an instance that does not have an ipv6 interface on the same network as the route. + NEXT_HOP_INSTANCE_HAS_NO_IPV6_INTERFACE = 146748434; + + // The route's nextHopInstance URL refers to an instance that does not exist. + NEXT_HOP_INSTANCE_NOT_FOUND = 464250446; + + // The route's nextHopInstance URL refers to an instance that is not on the same network as the route. + NEXT_HOP_INSTANCE_NOT_ON_NETWORK = 243758146; + + // The route's next hop instance does not have a status of RUNNING. + NEXT_HOP_NOT_RUNNING = 417081265; + + // Error which is not critical. We decided to continue the process despite the mentioned error. + NOT_CRITICAL_ERROR = 105763924; + + // No results are present on a particular list page. + NO_RESULTS_ON_PAGE = 30036744; + + // Success is reported, but some results may be missing due to errors + PARTIAL_SUCCESS = 39966469; + + // The user attempted to use a resource that requires a TOS they have not accepted. + REQUIRED_TOS_AGREEMENT = 3745539; + + // Warning that a resource is in use. + RESOURCE_IN_USE_BY_OTHER_RESOURCE_WARNING = 496728641; + + // One or more of the resources set to auto-delete could not be deleted because they were in use. + RESOURCE_NOT_DELETED = 168598460; + + // When a resource schema validation is ignored. + SCHEMA_VALIDATION_IGNORED = 275245642; + + // Instance template used in instance group manager is valid as such, but its application does not make a lot of sense, because it allows only single instance in instance group. + SINGLE_INSTANCE_PROPERTY_TEMPLATE = 268305617; + + // When undeclared properties in the schema are present + UNDECLARED_PROPERTIES = 390513439; + + // A given scope cannot be reached. + UNREACHABLE = 13328052; + + } + + // [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. + // Check the Code enum for the list of possible values. + optional string code = 3059181; + + // [Output Only] Metadata about this warning in key: value format. For example: "data": [ { "key": "scope", "value": "zones/us-east1-d" } + repeated Data data = 3076010; + + // [Output Only] A human-readable description of the warning code. + optional string message = 418054151; + +} + +// In contrast to a single BackendService in HttpRouteAction to which all matching traffic is directed to, WeightedBackendService allows traffic to be split across multiple backend services. The volume of traffic for each backend service is proportional to the weight specified in each WeightedBackendService +message WeightedBackendService { + // The full or partial URL to the default BackendService resource. Before forwarding the request to backendService, the load balancer applies any relevant headerActions specified as part of this backendServiceWeight. + optional string backend_service = 306946058; + + // Specifies changes to request and response headers that need to take effect for the selected backendService. headerAction specified here take effect before headerAction in the enclosing HttpRouteRule, PathMatcher and UrlMap. headerAction is not supported for load balancers that have their loadBalancingScheme set to EXTERNAL. Not supported when the URL map is bound to a target gRPC proxy that has validateForProxyless field set to true. + optional HttpHeaderAction header_action = 328077352; + + // Specifies the fraction of traffic sent to a backend service, computed as weight / (sum of all weightedBackendService weights in routeAction) . The selection of a backend service is determined only for new traffic. Once a user's request has been directed to a backend service, subsequent requests are sent to the same backend service as determined by the backend service's session affinity policy. The value must be from 0 to 1000. + optional uint32 weight = 282149496; + +} + +// +message XpnHostList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // [Output Only] A list of shared VPC host project URLs. + repeated Project items = 100526016; + + // [Output Only] Type of resource. Always compute#xpnHostList for lists of shared VPC hosts. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Service resource (a.k.a service project) ID. +message XpnResourceId { + // The type of the service resource. + enum Type { + // A value indicating that the enum field is not set. + UNDEFINED_TYPE = 0; + + PROJECT = 408671993; + + XPN_RESOURCE_TYPE_UNSPECIFIED = 151607034; + + } + + // The ID of the service resource. In the case of projects, this field supports project id (e.g., my-project-123) and project number (e.g. 12345678). + optional string id = 3355; + + // The type of the service resource. + // Check the Type enum for the list of possible values. + optional string type = 3575610; + +} + +// Represents a Zone resource. A zone is a deployment area. These deployment areas are subsets of a region. For example the zone us-east1-a is located in the us-east1 region. For more information, read Regions and Zones. +message Zone { + // [Output Only] Status of the zone, either UP or DOWN. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + DOWN = 2104482; + + UP = 2715; + + } + + // [Output Only] Available cpu/platform selections for the zone. + repeated string available_cpu_platforms = 175536531; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // [Output Only] The deprecation status associated with this zone. + optional DeprecationStatus deprecated = 515138995; + + // [Output Only] Textual description of the resource. + optional string description = 422937596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] Type of the resource. Always compute#zone for zones. + optional string kind = 3292052; + + // [Output Only] Name of the resource. + optional string name = 3373707; + + // [Output Only] Full URL reference to the region which hosts the zone. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] Status of the zone, either UP or DOWN. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // [Output Only] Reserved for future use. + optional bool supports_pzs = 83983214; + +} + +// Contains a list of zone resources. +message ZoneList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Zone resources. + repeated Zone items = 100526016; + + // Type of resource. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message ZoneSetLabelsRequest { + // The fingerprint of the previous set of labels for this resource, used to detect conflicts. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update labels. You must always provide an up-to-date fingerprint hash in order to update or change labels. Make a get() request to the resource to get the latest fingerprint. + optional string label_fingerprint = 178124825; + + // The labels to set for this resource. + map labels = 500195327; + +} + +// +message ZoneSetPolicyRequest { + // Flatten Policy to create a backwacd compatible wire-format. Deprecated. Use 'policy' to specify bindings. + repeated Binding bindings = 403251854; + + // Flatten Policy to create a backward compatible wire-format. Deprecated. Use 'policy' to specify the etag. + optional string etag = 3123477; + + // REQUIRED: The complete policy to be applied to the 'resource'. The size of the policy is limited to a few 10s of KB. An empty policy is in general a valid policy but certain services (like Projects) might reject them. + optional Policy policy = 91071794; + +} + +// +// Services +// +// The AcceleratorTypes API. +service AcceleratorTypes { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute.readonly," + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of accelerator types. + rpc AggregatedList(AggregatedListAcceleratorTypesRequest) returns (AcceleratorTypeAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/acceleratorTypes" + }; + option (google.api.method_signature) = "project"; + } + + // Returns the specified accelerator type. + rpc Get(GetAcceleratorTypeRequest) returns (AcceleratorType) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/acceleratorTypes/{accelerator_type}" + }; + option (google.api.method_signature) = "project,zone,accelerator_type"; + } + + // Retrieves a list of accelerator types that are available to the specified project. + rpc List(ListAcceleratorTypesRequest) returns (AcceleratorTypeList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/acceleratorTypes" + }; + option (google.api.method_signature) = "project,zone"; + } + +} + +// The Addresses API. +service Addresses { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of addresses. + rpc AggregatedList(AggregatedListAddressesRequest) returns (AddressAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/addresses" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified address resource. + rpc Delete(DeleteAddressRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/addresses/{address}" + }; + option (google.api.method_signature) = "project,region,address"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified address resource. + rpc Get(GetAddressRequest) returns (Address) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/addresses/{address}" + }; + option (google.api.method_signature) = "project,region,address"; + } + + // Creates an address resource in the specified project by using the data included in the request. + rpc Insert(InsertAddressRequest) returns (Operation) { + option (google.api.http) = { + body: "address_resource" + post: "/compute/v1/projects/{project}/regions/{region}/addresses" + }; + option (google.api.method_signature) = "project,region,address_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves a list of addresses contained within the specified region. + rpc List(ListAddressesRequest) returns (AddressList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/addresses" + }; + option (google.api.method_signature) = "project,region"; + } + + // Sets the labels on an Address. To learn more about labels, read the Labeling Resources documentation. + rpc SetLabels(SetLabelsAddressRequest) returns (Operation) { + option (google.api.http) = { + body: "region_set_labels_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/addresses/{resource}/setLabels" + }; + option (google.api.method_signature) = "project,region,resource,region_set_labels_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The Autoscalers API. +service Autoscalers { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of autoscalers. + rpc AggregatedList(AggregatedListAutoscalersRequest) returns (AutoscalerAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/autoscalers" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified autoscaler. + rpc Delete(DeleteAutoscalerRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/zones/{zone}/autoscalers/{autoscaler}" + }; + option (google.api.method_signature) = "project,zone,autoscaler"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Returns the specified autoscaler resource. + rpc Get(GetAutoscalerRequest) returns (Autoscaler) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/autoscalers/{autoscaler}" + }; + option (google.api.method_signature) = "project,zone,autoscaler"; + } + + // Creates an autoscaler in the specified project using the data included in the request. + rpc Insert(InsertAutoscalerRequest) returns (Operation) { + option (google.api.http) = { + body: "autoscaler_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/autoscalers" + }; + option (google.api.method_signature) = "project,zone,autoscaler_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Retrieves a list of autoscalers contained within the specified zone. + rpc List(ListAutoscalersRequest) returns (AutoscalerList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/autoscalers" + }; + option (google.api.method_signature) = "project,zone"; + } + + // Updates an autoscaler in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + rpc Patch(PatchAutoscalerRequest) returns (Operation) { + option (google.api.http) = { + body: "autoscaler_resource" + patch: "/compute/v1/projects/{project}/zones/{zone}/autoscalers" + }; + option (google.api.method_signature) = "project,zone,autoscaler_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Updates an autoscaler in the specified project using the data included in the request. + rpc Update(UpdateAutoscalerRequest) returns (Operation) { + option (google.api.http) = { + body: "autoscaler_resource" + put: "/compute/v1/projects/{project}/zones/{zone}/autoscalers" + }; + option (google.api.method_signature) = "project,zone,autoscaler_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + +} + +// The BackendBuckets API. +service BackendBuckets { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Adds a key for validating requests with signed URLs for this backend bucket. + rpc AddSignedUrlKey(AddSignedUrlKeyBackendBucketRequest) returns (Operation) { + option (google.api.http) = { + body: "signed_url_key_resource" + post: "/compute/v1/projects/{project}/global/backendBuckets/{backend_bucket}/addSignedUrlKey" + }; + option (google.api.method_signature) = "project,backend_bucket,signed_url_key_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Deletes the specified BackendBucket resource. + rpc Delete(DeleteBackendBucketRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/backendBuckets/{backend_bucket}" + }; + option (google.api.method_signature) = "project,backend_bucket"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Deletes a key for validating requests with signed URLs for this backend bucket. + rpc DeleteSignedUrlKey(DeleteSignedUrlKeyBackendBucketRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/global/backendBuckets/{backend_bucket}/deleteSignedUrlKey" + }; + option (google.api.method_signature) = "project,backend_bucket,key_name"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified BackendBucket resource. + rpc Get(GetBackendBucketRequest) returns (BackendBucket) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/backendBuckets/{backend_bucket}" + }; + option (google.api.method_signature) = "project,backend_bucket"; + } + + // Creates a BackendBucket resource in the specified project using the data included in the request. + rpc Insert(InsertBackendBucketRequest) returns (Operation) { + option (google.api.http) = { + body: "backend_bucket_resource" + post: "/compute/v1/projects/{project}/global/backendBuckets" + }; + option (google.api.method_signature) = "project,backend_bucket_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of BackendBucket resources available to the specified project. + rpc List(ListBackendBucketsRequest) returns (BackendBucketList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/backendBuckets" + }; + option (google.api.method_signature) = "project"; + } + + // Updates the specified BackendBucket resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + rpc Patch(PatchBackendBucketRequest) returns (Operation) { + option (google.api.http) = { + body: "backend_bucket_resource" + patch: "/compute/v1/projects/{project}/global/backendBuckets/{backend_bucket}" + }; + option (google.api.method_signature) = "project,backend_bucket,backend_bucket_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Sets the edge security policy for the specified backend bucket. + rpc SetEdgeSecurityPolicy(SetEdgeSecurityPolicyBackendBucketRequest) returns (Operation) { + option (google.api.http) = { + body: "security_policy_reference_resource" + post: "/compute/v1/projects/{project}/global/backendBuckets/{backend_bucket}/setEdgeSecurityPolicy" + }; + option (google.api.method_signature) = "project,backend_bucket,security_policy_reference_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Updates the specified BackendBucket resource with the data included in the request. + rpc Update(UpdateBackendBucketRequest) returns (Operation) { + option (google.api.http) = { + body: "backend_bucket_resource" + put: "/compute/v1/projects/{project}/global/backendBuckets/{backend_bucket}" + }; + option (google.api.method_signature) = "project,backend_bucket,backend_bucket_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The BackendServices API. +service BackendServices { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Adds a key for validating requests with signed URLs for this backend service. + rpc AddSignedUrlKey(AddSignedUrlKeyBackendServiceRequest) returns (Operation) { + option (google.api.http) = { + body: "signed_url_key_resource" + post: "/compute/v1/projects/{project}/global/backendServices/{backend_service}/addSignedUrlKey" + }; + option (google.api.method_signature) = "project,backend_service,signed_url_key_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of all BackendService resources, regional and global, available to the specified project. + rpc AggregatedList(AggregatedListBackendServicesRequest) returns (BackendServiceAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/backendServices" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified BackendService resource. + rpc Delete(DeleteBackendServiceRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/backendServices/{backend_service}" + }; + option (google.api.method_signature) = "project,backend_service"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Deletes a key for validating requests with signed URLs for this backend service. + rpc DeleteSignedUrlKey(DeleteSignedUrlKeyBackendServiceRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/global/backendServices/{backend_service}/deleteSignedUrlKey" + }; + option (google.api.method_signature) = "project,backend_service,key_name"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified BackendService resource. + rpc Get(GetBackendServiceRequest) returns (BackendService) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/backendServices/{backend_service}" + }; + option (google.api.method_signature) = "project,backend_service"; + } + + // Gets the most recent health check results for this BackendService. Example request body: { "group": "/zones/us-east1-b/instanceGroups/lb-backend-example" } + rpc GetHealth(GetHealthBackendServiceRequest) returns (BackendServiceGroupHealth) { + option (google.api.http) = { + body: "resource_group_reference_resource" + post: "/compute/v1/projects/{project}/global/backendServices/{backend_service}/getHealth" + }; + option (google.api.method_signature) = "project,backend_service,resource_group_reference_resource"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyBackendServiceRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/backendServices/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,resource"; + } + + // Creates a BackendService resource in the specified project using the data included in the request. For more information, see Backend services overview . + rpc Insert(InsertBackendServiceRequest) returns (Operation) { + option (google.api.http) = { + body: "backend_service_resource" + post: "/compute/v1/projects/{project}/global/backendServices" + }; + option (google.api.method_signature) = "project,backend_service_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of BackendService resources available to the specified project. + rpc List(ListBackendServicesRequest) returns (BackendServiceList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/backendServices" + }; + option (google.api.method_signature) = "project"; + } + + // Patches the specified BackendService resource with the data included in the request. For more information, see Backend services overview. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + rpc Patch(PatchBackendServiceRequest) returns (Operation) { + option (google.api.http) = { + body: "backend_service_resource" + patch: "/compute/v1/projects/{project}/global/backendServices/{backend_service}" + }; + option (google.api.method_signature) = "project,backend_service,backend_service_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Sets the edge security policy for the specified backend service. + rpc SetEdgeSecurityPolicy(SetEdgeSecurityPolicyBackendServiceRequest) returns (Operation) { + option (google.api.http) = { + body: "security_policy_reference_resource" + post: "/compute/v1/projects/{project}/global/backendServices/{backend_service}/setEdgeSecurityPolicy" + }; + option (google.api.method_signature) = "project,backend_service,security_policy_reference_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyBackendServiceRequest) returns (Policy) { + option (google.api.http) = { + body: "global_set_policy_request_resource" + post: "/compute/v1/projects/{project}/global/backendServices/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,resource,global_set_policy_request_resource"; + } + + // Sets the Google Cloud Armor security policy for the specified backend service. For more information, see Google Cloud Armor Overview + rpc SetSecurityPolicy(SetSecurityPolicyBackendServiceRequest) returns (Operation) { + option (google.api.http) = { + body: "security_policy_reference_resource" + post: "/compute/v1/projects/{project}/global/backendServices/{backend_service}/setSecurityPolicy" + }; + option (google.api.method_signature) = "project,backend_service,security_policy_reference_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Updates the specified BackendService resource with the data included in the request. For more information, see Backend services overview. + rpc Update(UpdateBackendServiceRequest) returns (Operation) { + option (google.api.http) = { + body: "backend_service_resource" + put: "/compute/v1/projects/{project}/global/backendServices/{backend_service}" + }; + option (google.api.method_signature) = "project,backend_service,backend_service_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The DiskTypes API. +service DiskTypes { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute.readonly," + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of disk types. + rpc AggregatedList(AggregatedListDiskTypesRequest) returns (DiskTypeAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/diskTypes" + }; + option (google.api.method_signature) = "project"; + } + + // Returns the specified disk type. + rpc Get(GetDiskTypeRequest) returns (DiskType) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/diskTypes/{disk_type}" + }; + option (google.api.method_signature) = "project,zone,disk_type"; + } + + // Retrieves a list of disk types available to the specified project. + rpc List(ListDiskTypesRequest) returns (DiskTypeList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/diskTypes" + }; + option (google.api.method_signature) = "project,zone"; + } + +} + +// The Disks API. +service Disks { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Adds existing resource policies to a disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation. + rpc AddResourcePolicies(AddResourcePoliciesDiskRequest) returns (Operation) { + option (google.api.http) = { + body: "disks_add_resource_policies_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/disks/{disk}/addResourcePolicies" + }; + option (google.api.method_signature) = "project,zone,disk,disks_add_resource_policies_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Retrieves an aggregated list of persistent disks. + rpc AggregatedList(AggregatedListDisksRequest) returns (DiskAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/disks" + }; + option (google.api.method_signature) = "project"; + } + + // Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project. + rpc CreateSnapshot(CreateSnapshotDiskRequest) returns (Operation) { + option (google.api.http) = { + body: "snapshot_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/disks/{disk}/createSnapshot" + }; + option (google.api.method_signature) = "project,zone,disk,snapshot_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Deletes the specified persistent disk. Deleting a disk removes its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots. + rpc Delete(DeleteDiskRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/zones/{zone}/disks/{disk}" + }; + option (google.api.method_signature) = "project,zone,disk"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Returns the specified persistent disk. + rpc Get(GetDiskRequest) returns (Disk) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/disks/{disk}" + }; + option (google.api.method_signature) = "project,zone,disk"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyDiskRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/disks/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,zone,resource"; + } + + // Creates a persistent disk in the specified project using the data in the request. You can create a disk from a source (sourceImage, sourceSnapshot, or sourceDisk) or create an empty 500 GB data disk by omitting all properties. You can also create a disk that is larger than the default size by specifying the sizeGb property. + rpc Insert(InsertDiskRequest) returns (Operation) { + option (google.api.http) = { + body: "disk_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/disks" + }; + option (google.api.method_signature) = "project,zone,disk_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Retrieves a list of persistent disks contained within the specified zone. + rpc List(ListDisksRequest) returns (DiskList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/disks" + }; + option (google.api.method_signature) = "project,zone"; + } + + // Removes resource policies from a disk. + rpc RemoveResourcePolicies(RemoveResourcePoliciesDiskRequest) returns (Operation) { + option (google.api.http) = { + body: "disks_remove_resource_policies_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/disks/{disk}/removeResourcePolicies" + }; + option (google.api.method_signature) = "project,zone,disk,disks_remove_resource_policies_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Resizes the specified persistent disk. You can only increase the size of the disk. + rpc Resize(ResizeDiskRequest) returns (Operation) { + option (google.api.http) = { + body: "disks_resize_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/disks/{disk}/resize" + }; + option (google.api.method_signature) = "project,zone,disk,disks_resize_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyDiskRequest) returns (Policy) { + option (google.api.http) = { + body: "zone_set_policy_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/disks/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,zone,resource,zone_set_policy_request_resource"; + } + + // Sets the labels on a disk. To learn more about labels, read the Labeling Resources documentation. + rpc SetLabels(SetLabelsDiskRequest) returns (Operation) { + option (google.api.http) = { + body: "zone_set_labels_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/disks/{resource}/setLabels" + }; + option (google.api.method_signature) = "project,zone,resource,zone_set_labels_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsDiskRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/disks/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,zone,resource,test_permissions_request_resource"; + } + + // Updates the specified disk with the data included in the request. The update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: user_license. + rpc Update(UpdateDiskRequest) returns (Operation) { + option (google.api.http) = { + body: "disk_resource" + patch: "/compute/v1/projects/{project}/zones/{zone}/disks/{disk}" + }; + option (google.api.method_signature) = "project,zone,disk,disk_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + +} + +// The ExternalVpnGateways API. +service ExternalVpnGateways { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified externalVpnGateway. + rpc Delete(DeleteExternalVpnGatewayRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/externalVpnGateways/{external_vpn_gateway}" + }; + option (google.api.method_signature) = "project,external_vpn_gateway"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified externalVpnGateway. Get a list of available externalVpnGateways by making a list() request. + rpc Get(GetExternalVpnGatewayRequest) returns (ExternalVpnGateway) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/externalVpnGateways/{external_vpn_gateway}" + }; + option (google.api.method_signature) = "project,external_vpn_gateway"; + } + + // Creates a ExternalVpnGateway in the specified project using the data included in the request. + rpc Insert(InsertExternalVpnGatewayRequest) returns (Operation) { + option (google.api.http) = { + body: "external_vpn_gateway_resource" + post: "/compute/v1/projects/{project}/global/externalVpnGateways" + }; + option (google.api.method_signature) = "project,external_vpn_gateway_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of ExternalVpnGateway available to the specified project. + rpc List(ListExternalVpnGatewaysRequest) returns (ExternalVpnGatewayList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/externalVpnGateways" + }; + option (google.api.method_signature) = "project"; + } + + // Sets the labels on an ExternalVpnGateway. To learn more about labels, read the Labeling Resources documentation. + rpc SetLabels(SetLabelsExternalVpnGatewayRequest) returns (Operation) { + option (google.api.http) = { + body: "global_set_labels_request_resource" + post: "/compute/v1/projects/{project}/global/externalVpnGateways/{resource}/setLabels" + }; + option (google.api.method_signature) = "project,resource,global_set_labels_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsExternalVpnGatewayRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/global/externalVpnGateways/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,resource,test_permissions_request_resource"; + } + +} + +// The FirewallPolicies API. +service FirewallPolicies { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Inserts an association for the specified firewall policy. + rpc AddAssociation(AddAssociationFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_policy_association_resource" + post: "/compute/v1/locations/global/firewallPolicies/{firewall_policy}/addAssociation" + }; + option (google.api.method_signature) = "firewall_policy,firewall_policy_association_resource"; + option (google.cloud.operation_service) = "GlobalOrganizationOperations"; + } + + // Inserts a rule into a firewall policy. + rpc AddRule(AddRuleFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_policy_rule_resource" + post: "/compute/v1/locations/global/firewallPolicies/{firewall_policy}/addRule" + }; + option (google.api.method_signature) = "firewall_policy,firewall_policy_rule_resource"; + option (google.cloud.operation_service) = "GlobalOrganizationOperations"; + } + + // Copies rules to the specified firewall policy. + rpc CloneRules(CloneRulesFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/locations/global/firewallPolicies/{firewall_policy}/cloneRules" + }; + option (google.api.method_signature) = "firewall_policy"; + option (google.cloud.operation_service) = "GlobalOrganizationOperations"; + } + + // Deletes the specified policy. + rpc Delete(DeleteFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/locations/global/firewallPolicies/{firewall_policy}" + }; + option (google.api.method_signature) = "firewall_policy"; + option (google.cloud.operation_service) = "GlobalOrganizationOperations"; + } + + // Returns the specified firewall policy. + rpc Get(GetFirewallPolicyRequest) returns (FirewallPolicy) { + option (google.api.http) = { + get: "/compute/v1/locations/global/firewallPolicies/{firewall_policy}" + }; + option (google.api.method_signature) = "firewall_policy"; + } + + // Gets an association with the specified name. + rpc GetAssociation(GetAssociationFirewallPolicyRequest) returns (FirewallPolicyAssociation) { + option (google.api.http) = { + get: "/compute/v1/locations/global/firewallPolicies/{firewall_policy}/getAssociation" + }; + option (google.api.method_signature) = "firewall_policy"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyFirewallPolicyRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/locations/global/firewallPolicies/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "resource"; + } + + // Gets a rule of the specified priority. + rpc GetRule(GetRuleFirewallPolicyRequest) returns (FirewallPolicyRule) { + option (google.api.http) = { + get: "/compute/v1/locations/global/firewallPolicies/{firewall_policy}/getRule" + }; + option (google.api.method_signature) = "firewall_policy"; + } + + // Creates a new policy in the specified project using the data included in the request. + rpc Insert(InsertFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_policy_resource" + post: "/compute/v1/locations/global/firewallPolicies" + }; + option (google.api.method_signature) = "parent_id,firewall_policy_resource"; + option (google.cloud.operation_service) = "GlobalOrganizationOperations"; + } + + // Lists all the policies that have been configured for the specified folder or organization. + rpc List(ListFirewallPoliciesRequest) returns (FirewallPolicyList) { + option (google.api.http) = { + get: "/compute/v1/locations/global/firewallPolicies" + }; + option (google.api.method_signature) = ""; + } + + // Lists associations of a specified target, i.e., organization or folder. + rpc ListAssociations(ListAssociationsFirewallPolicyRequest) returns (FirewallPoliciesListAssociationsResponse) { + option (google.api.http) = { + get: "/compute/v1/locations/global/firewallPolicies/listAssociations" + }; + option (google.api.method_signature) = ""; + } + + // Moves the specified firewall policy. + rpc Move(MoveFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/locations/global/firewallPolicies/{firewall_policy}/move" + }; + option (google.api.method_signature) = "firewall_policy,parent_id"; + option (google.cloud.operation_service) = "GlobalOrganizationOperations"; + } + + // Patches the specified policy with the data included in the request. + rpc Patch(PatchFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_policy_resource" + patch: "/compute/v1/locations/global/firewallPolicies/{firewall_policy}" + }; + option (google.api.method_signature) = "firewall_policy,firewall_policy_resource"; + option (google.cloud.operation_service) = "GlobalOrganizationOperations"; + } + + // Patches a rule of the specified priority. + rpc PatchRule(PatchRuleFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_policy_rule_resource" + post: "/compute/v1/locations/global/firewallPolicies/{firewall_policy}/patchRule" + }; + option (google.api.method_signature) = "firewall_policy,firewall_policy_rule_resource"; + option (google.cloud.operation_service) = "GlobalOrganizationOperations"; + } + + // Removes an association for the specified firewall policy. + rpc RemoveAssociation(RemoveAssociationFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/locations/global/firewallPolicies/{firewall_policy}/removeAssociation" + }; + option (google.api.method_signature) = "firewall_policy"; + option (google.cloud.operation_service) = "GlobalOrganizationOperations"; + } + + // Deletes a rule of the specified priority. + rpc RemoveRule(RemoveRuleFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/locations/global/firewallPolicies/{firewall_policy}/removeRule" + }; + option (google.api.method_signature) = "firewall_policy"; + option (google.cloud.operation_service) = "GlobalOrganizationOperations"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyFirewallPolicyRequest) returns (Policy) { + option (google.api.http) = { + body: "global_organization_set_policy_request_resource" + post: "/compute/v1/locations/global/firewallPolicies/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "resource,global_organization_set_policy_request_resource"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsFirewallPolicyRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/locations/global/firewallPolicies/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "resource,test_permissions_request_resource"; + } + +} + +// The Firewalls API. +service Firewalls { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified firewall. + rpc Delete(DeleteFirewallRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/firewalls/{firewall}" + }; + option (google.api.method_signature) = "project,firewall"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified firewall. + rpc Get(GetFirewallRequest) returns (Firewall) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/firewalls/{firewall}" + }; + option (google.api.method_signature) = "project,firewall"; + } + + // Creates a firewall rule in the specified project using the data included in the request. + rpc Insert(InsertFirewallRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_resource" + post: "/compute/v1/projects/{project}/global/firewalls" + }; + option (google.api.method_signature) = "project,firewall_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of firewall rules available to the specified project. + rpc List(ListFirewallsRequest) returns (FirewallList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/firewalls" + }; + option (google.api.method_signature) = "project"; + } + + // Updates the specified firewall rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + rpc Patch(PatchFirewallRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_resource" + patch: "/compute/v1/projects/{project}/global/firewalls/{firewall}" + }; + option (google.api.method_signature) = "project,firewall,firewall_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Updates the specified firewall rule with the data included in the request. Note that all fields will be updated if using PUT, even fields that are not specified. To update individual fields, please use PATCH instead. + rpc Update(UpdateFirewallRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_resource" + put: "/compute/v1/projects/{project}/global/firewalls/{firewall}" + }; + option (google.api.method_signature) = "project,firewall,firewall_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The ForwardingRules API. +service ForwardingRules { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of forwarding rules. + rpc AggregatedList(AggregatedListForwardingRulesRequest) returns (ForwardingRuleAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/forwardingRules" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified ForwardingRule resource. + rpc Delete(DeleteForwardingRuleRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/forwardingRules/{forwarding_rule}" + }; + option (google.api.method_signature) = "project,region,forwarding_rule"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified ForwardingRule resource. + rpc Get(GetForwardingRuleRequest) returns (ForwardingRule) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/forwardingRules/{forwarding_rule}" + }; + option (google.api.method_signature) = "project,region,forwarding_rule"; + } + + // Creates a ForwardingRule resource in the specified project and region using the data included in the request. + rpc Insert(InsertForwardingRuleRequest) returns (Operation) { + option (google.api.http) = { + body: "forwarding_rule_resource" + post: "/compute/v1/projects/{project}/regions/{region}/forwardingRules" + }; + option (google.api.method_signature) = "project,region,forwarding_rule_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves a list of ForwardingRule resources available to the specified project and region. + rpc List(ListForwardingRulesRequest) returns (ForwardingRuleList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/forwardingRules" + }; + option (google.api.method_signature) = "project,region"; + } + + // Updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. Currently, you can only patch the network_tier field. + rpc Patch(PatchForwardingRuleRequest) returns (Operation) { + option (google.api.http) = { + body: "forwarding_rule_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/forwardingRules/{forwarding_rule}" + }; + option (google.api.method_signature) = "project,region,forwarding_rule,forwarding_rule_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Sets the labels on the specified resource. To learn more about labels, read the Labeling Resources documentation. + rpc SetLabels(SetLabelsForwardingRuleRequest) returns (Operation) { + option (google.api.http) = { + body: "region_set_labels_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/forwardingRules/{resource}/setLabels" + }; + option (google.api.method_signature) = "project,region,resource,region_set_labels_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Changes target URL for forwarding rule. The new target should be of the same type as the old target. + rpc SetTarget(SetTargetForwardingRuleRequest) returns (Operation) { + option (google.api.http) = { + body: "target_reference_resource" + post: "/compute/v1/projects/{project}/regions/{region}/forwardingRules/{forwarding_rule}/setTarget" + }; + option (google.api.method_signature) = "project,region,forwarding_rule,target_reference_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The GlobalAddresses API. +service GlobalAddresses { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified address resource. + rpc Delete(DeleteGlobalAddressRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/addresses/{address}" + }; + option (google.api.method_signature) = "project,address"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified address resource. + rpc Get(GetGlobalAddressRequest) returns (Address) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/addresses/{address}" + }; + option (google.api.method_signature) = "project,address"; + } + + // Creates an address resource in the specified project by using the data included in the request. + rpc Insert(InsertGlobalAddressRequest) returns (Operation) { + option (google.api.http) = { + body: "address_resource" + post: "/compute/v1/projects/{project}/global/addresses" + }; + option (google.api.method_signature) = "project,address_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves a list of global addresses. + rpc List(ListGlobalAddressesRequest) returns (AddressList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/addresses" + }; + option (google.api.method_signature) = "project"; + } + + // Sets the labels on a GlobalAddress. To learn more about labels, read the Labeling Resources documentation. + rpc SetLabels(SetLabelsGlobalAddressRequest) returns (Operation) { + option (google.api.http) = { + body: "global_set_labels_request_resource" + post: "/compute/v1/projects/{project}/global/addresses/{resource}/setLabels" + }; + option (google.api.method_signature) = "project,resource,global_set_labels_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The GlobalForwardingRules API. +service GlobalForwardingRules { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified GlobalForwardingRule resource. + rpc Delete(DeleteGlobalForwardingRuleRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/forwardingRules/{forwarding_rule}" + }; + option (google.api.method_signature) = "project,forwarding_rule"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified GlobalForwardingRule resource. Gets a list of available forwarding rules by making a list() request. + rpc Get(GetGlobalForwardingRuleRequest) returns (ForwardingRule) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/forwardingRules/{forwarding_rule}" + }; + option (google.api.method_signature) = "project,forwarding_rule"; + } + + // Creates a GlobalForwardingRule resource in the specified project using the data included in the request. + rpc Insert(InsertGlobalForwardingRuleRequest) returns (Operation) { + option (google.api.http) = { + body: "forwarding_rule_resource" + post: "/compute/v1/projects/{project}/global/forwardingRules" + }; + option (google.api.method_signature) = "project,forwarding_rule_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves a list of GlobalForwardingRule resources available to the specified project. + rpc List(ListGlobalForwardingRulesRequest) returns (ForwardingRuleList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/forwardingRules" + }; + option (google.api.method_signature) = "project"; + } + + // Updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. Currently, you can only patch the network_tier field. + rpc Patch(PatchGlobalForwardingRuleRequest) returns (Operation) { + option (google.api.http) = { + body: "forwarding_rule_resource" + patch: "/compute/v1/projects/{project}/global/forwardingRules/{forwarding_rule}" + }; + option (google.api.method_signature) = "project,forwarding_rule,forwarding_rule_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Sets the labels on the specified resource. To learn more about labels, read the Labeling resources documentation. + rpc SetLabels(SetLabelsGlobalForwardingRuleRequest) returns (Operation) { + option (google.api.http) = { + body: "global_set_labels_request_resource" + post: "/compute/v1/projects/{project}/global/forwardingRules/{resource}/setLabels" + }; + option (google.api.method_signature) = "project,resource,global_set_labels_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Changes target URL for the GlobalForwardingRule resource. The new target should be of the same type as the old target. + rpc SetTarget(SetTargetGlobalForwardingRuleRequest) returns (Operation) { + option (google.api.http) = { + body: "target_reference_resource" + post: "/compute/v1/projects/{project}/global/forwardingRules/{forwarding_rule}/setTarget" + }; + option (google.api.method_signature) = "project,forwarding_rule,target_reference_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The GlobalNetworkEndpointGroups API. +service GlobalNetworkEndpointGroups { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Attach a network endpoint to the specified network endpoint group. + rpc AttachNetworkEndpoints(AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "global_network_endpoint_groups_attach_endpoints_request_resource" + post: "/compute/v1/projects/{project}/global/networkEndpointGroups/{network_endpoint_group}/attachNetworkEndpoints" + }; + option (google.api.method_signature) = "project,network_endpoint_group,global_network_endpoint_groups_attach_endpoints_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Deletes the specified network endpoint group.Note that the NEG cannot be deleted if there are backend services referencing it. + rpc Delete(DeleteGlobalNetworkEndpointGroupRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/networkEndpointGroups/{network_endpoint_group}" + }; + option (google.api.method_signature) = "project,network_endpoint_group"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Detach the network endpoint from the specified network endpoint group. + rpc DetachNetworkEndpoints(DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "global_network_endpoint_groups_detach_endpoints_request_resource" + post: "/compute/v1/projects/{project}/global/networkEndpointGroups/{network_endpoint_group}/detachNetworkEndpoints" + }; + option (google.api.method_signature) = "project,network_endpoint_group,global_network_endpoint_groups_detach_endpoints_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified network endpoint group. + rpc Get(GetGlobalNetworkEndpointGroupRequest) returns (NetworkEndpointGroup) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/networkEndpointGroups/{network_endpoint_group}" + }; + option (google.api.method_signature) = "project,network_endpoint_group"; + } + + // Creates a network endpoint group in the specified project using the parameters that are included in the request. + rpc Insert(InsertGlobalNetworkEndpointGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "network_endpoint_group_resource" + post: "/compute/v1/projects/{project}/global/networkEndpointGroups" + }; + option (google.api.method_signature) = "project,network_endpoint_group_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of network endpoint groups that are located in the specified project. + rpc List(ListGlobalNetworkEndpointGroupsRequest) returns (NetworkEndpointGroupList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/networkEndpointGroups" + }; + option (google.api.method_signature) = "project"; + } + + // Lists the network endpoints in the specified network endpoint group. + rpc ListNetworkEndpoints(ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest) returns (NetworkEndpointGroupsListNetworkEndpoints) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/global/networkEndpointGroups/{network_endpoint_group}/listNetworkEndpoints" + }; + option (google.api.method_signature) = "project,network_endpoint_group"; + } + +} + +// The GlobalOperations API. +service GlobalOperations { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of all operations. + rpc AggregatedList(AggregatedListGlobalOperationsRequest) returns (OperationAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/operations" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified Operations resource. + rpc Delete(DeleteGlobalOperationRequest) returns (DeleteGlobalOperationResponse) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/operations/{operation}" + }; + option (google.api.method_signature) = "project,operation"; + } + + // Retrieves the specified Operations resource. + rpc Get(GetGlobalOperationRequest) returns (Operation) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/operations/{operation}" + }; + option (google.api.method_signature) = "project,operation"; + option (google.cloud.operation_polling_method) = true; + } + + // Retrieves a list of Operation resources contained within the specified project. + rpc List(ListGlobalOperationsRequest) returns (OperationList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/operations" + }; + option (google.api.method_signature) = "project"; + } + + // Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the `GET` method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. + rpc Wait(WaitGlobalOperationRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/global/operations/{operation}/wait" + }; + option (google.api.method_signature) = "project,operation"; + } + +} + +// The GlobalOrganizationOperations API. +service GlobalOrganizationOperations { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified Operations resource. + rpc Delete(DeleteGlobalOrganizationOperationRequest) returns (DeleteGlobalOrganizationOperationResponse) { + option (google.api.http) = { + delete: "/compute/v1/locations/global/operations/{operation}" + }; + option (google.api.method_signature) = "operation"; + } + + // Retrieves the specified Operations resource. Gets a list of operations by making a `list()` request. + rpc Get(GetGlobalOrganizationOperationRequest) returns (Operation) { + option (google.api.http) = { + get: "/compute/v1/locations/global/operations/{operation}" + }; + option (google.api.method_signature) = "operation"; + option (google.cloud.operation_polling_method) = true; + } + + // Retrieves a list of Operation resources contained within the specified organization. + rpc List(ListGlobalOrganizationOperationsRequest) returns (OperationList) { + option (google.api.http) = { + get: "/compute/v1/locations/global/operations" + }; + option (google.api.method_signature) = ""; + } + +} + +// The GlobalPublicDelegatedPrefixes API. +service GlobalPublicDelegatedPrefixes { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified global PublicDelegatedPrefix. + rpc Delete(DeleteGlobalPublicDelegatedPrefixeRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/publicDelegatedPrefixes/{public_delegated_prefix}" + }; + option (google.api.method_signature) = "project,public_delegated_prefix"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified global PublicDelegatedPrefix resource. + rpc Get(GetGlobalPublicDelegatedPrefixeRequest) returns (PublicDelegatedPrefix) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/publicDelegatedPrefixes/{public_delegated_prefix}" + }; + option (google.api.method_signature) = "project,public_delegated_prefix"; + } + + // Creates a global PublicDelegatedPrefix in the specified project using the parameters that are included in the request. + rpc Insert(InsertGlobalPublicDelegatedPrefixeRequest) returns (Operation) { + option (google.api.http) = { + body: "public_delegated_prefix_resource" + post: "/compute/v1/projects/{project}/global/publicDelegatedPrefixes" + }; + option (google.api.method_signature) = "project,public_delegated_prefix_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Lists the global PublicDelegatedPrefixes for a project. + rpc List(ListGlobalPublicDelegatedPrefixesRequest) returns (PublicDelegatedPrefixList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/publicDelegatedPrefixes" + }; + option (google.api.method_signature) = "project"; + } + + // Patches the specified global PublicDelegatedPrefix resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + rpc Patch(PatchGlobalPublicDelegatedPrefixeRequest) returns (Operation) { + option (google.api.http) = { + body: "public_delegated_prefix_resource" + patch: "/compute/v1/projects/{project}/global/publicDelegatedPrefixes/{public_delegated_prefix}" + }; + option (google.api.method_signature) = "project,public_delegated_prefix,public_delegated_prefix_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The HealthChecks API. +service HealthChecks { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves the list of all HealthCheck resources, regional and global, available to the specified project. + rpc AggregatedList(AggregatedListHealthChecksRequest) returns (HealthChecksAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/healthChecks" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified HealthCheck resource. + rpc Delete(DeleteHealthCheckRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/healthChecks/{health_check}" + }; + option (google.api.method_signature) = "project,health_check"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified HealthCheck resource. + rpc Get(GetHealthCheckRequest) returns (HealthCheck) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/healthChecks/{health_check}" + }; + option (google.api.method_signature) = "project,health_check"; + } + + // Creates a HealthCheck resource in the specified project using the data included in the request. + rpc Insert(InsertHealthCheckRequest) returns (Operation) { + option (google.api.http) = { + body: "health_check_resource" + post: "/compute/v1/projects/{project}/global/healthChecks" + }; + option (google.api.method_signature) = "project,health_check_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of HealthCheck resources available to the specified project. + rpc List(ListHealthChecksRequest) returns (HealthCheckList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/healthChecks" + }; + option (google.api.method_signature) = "project"; + } + + // Updates a HealthCheck resource in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + rpc Patch(PatchHealthCheckRequest) returns (Operation) { + option (google.api.http) = { + body: "health_check_resource" + patch: "/compute/v1/projects/{project}/global/healthChecks/{health_check}" + }; + option (google.api.method_signature) = "project,health_check,health_check_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Updates a HealthCheck resource in the specified project using the data included in the request. + rpc Update(UpdateHealthCheckRequest) returns (Operation) { + option (google.api.http) = { + body: "health_check_resource" + put: "/compute/v1/projects/{project}/global/healthChecks/{health_check}" + }; + option (google.api.method_signature) = "project,health_check,health_check_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The ImageFamilyViews API. +service ImageFamilyViews { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute.readonly," + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Returns the latest image that is part of an image family, is not deprecated and is rolled out in the specified zone. + rpc Get(GetImageFamilyViewRequest) returns (ImageFamilyView) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/imageFamilyViews/{family}" + }; + option (google.api.method_signature) = "project,zone,family"; + } + +} + +// The Images API. +service Images { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified image. + rpc Delete(DeleteImageRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/images/{image}" + }; + option (google.api.method_signature) = "project,image"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Sets the deprecation status of an image. If an empty request body is given, clears the deprecation status instead. + rpc Deprecate(DeprecateImageRequest) returns (Operation) { + option (google.api.http) = { + body: "deprecation_status_resource" + post: "/compute/v1/projects/{project}/global/images/{image}/deprecate" + }; + option (google.api.method_signature) = "project,image,deprecation_status_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified image. + rpc Get(GetImageRequest) returns (Image) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/images/{image}" + }; + option (google.api.method_signature) = "project,image"; + } + + // Returns the latest image that is part of an image family and is not deprecated. For more information on image families, see Public image families documentation. + rpc GetFromFamily(GetFromFamilyImageRequest) returns (Image) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/images/family/{family}" + }; + option (google.api.method_signature) = "project,family"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyImageRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/images/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,resource"; + } + + // Creates an image in the specified project using the data included in the request. + rpc Insert(InsertImageRequest) returns (Operation) { + option (google.api.http) = { + body: "image_resource" + post: "/compute/v1/projects/{project}/global/images" + }; + option (google.api.method_signature) = "project,image_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of custom images available to the specified project. Custom images are images you create that belong to your project. This method does not get any images that belong to other projects, including publicly-available images, like Debian 8. If you want to get a list of publicly-available images, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud. + rpc List(ListImagesRequest) returns (ImageList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/images" + }; + option (google.api.method_signature) = "project"; + } + + // Patches the specified image with the data included in the request. Only the following fields can be modified: family, description, deprecation status. + rpc Patch(PatchImageRequest) returns (Operation) { + option (google.api.http) = { + body: "image_resource" + patch: "/compute/v1/projects/{project}/global/images/{image}" + }; + option (google.api.method_signature) = "project,image,image_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyImageRequest) returns (Policy) { + option (google.api.http) = { + body: "global_set_policy_request_resource" + post: "/compute/v1/projects/{project}/global/images/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,resource,global_set_policy_request_resource"; + } + + // Sets the labels on an image. To learn more about labels, read the Labeling Resources documentation. + rpc SetLabels(SetLabelsImageRequest) returns (Operation) { + option (google.api.http) = { + body: "global_set_labels_request_resource" + post: "/compute/v1/projects/{project}/global/images/{resource}/setLabels" + }; + option (google.api.method_signature) = "project,resource,global_set_labels_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsImageRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/global/images/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,resource,test_permissions_request_resource"; + } + +} + +// The InstanceGroupManagers API. +service InstanceGroupManagers { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Flags the specified instances to be removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + rpc AbandonInstances(AbandonInstancesInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_group_managers_abandon_instances_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/abandonInstances" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager,instance_group_managers_abandon_instances_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Retrieves the list of managed instance groups and groups them by zone. + rpc AggregatedList(AggregatedListInstanceGroupManagersRequest) returns (InstanceGroupManagerAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/instanceGroupManagers" + }; + option (google.api.method_signature) = "project"; + } + + // Applies changes to selected instances on the managed instance group. This method can be used to apply new overrides and/or new versions. + rpc ApplyUpdatesToInstances(ApplyUpdatesToInstancesInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_group_managers_apply_updates_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/applyUpdatesToInstances" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager,instance_group_managers_apply_updates_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Creates instances with per-instance configurations in this managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method. + rpc CreateInstances(CreateInstancesInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_group_managers_create_instances_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/createInstances" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager,instance_group_managers_create_instances_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Deletes the specified managed instance group and all of the instances in that group. Note that the instance group must not belong to a backend service. Read Deleting an instance group for more information. + rpc Delete(DeleteInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Flags the specified instances in the managed instance group for immediate deletion. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. This operation is marked as DONE when the action is scheduled even if the instances are still being deleted. You must separately verify the status of the deleting action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + rpc DeleteInstances(DeleteInstancesInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_group_managers_delete_instances_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/deleteInstances" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager,instance_group_managers_delete_instances_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Deletes selected per-instance configurations for the managed instance group. + rpc DeletePerInstanceConfigs(DeletePerInstanceConfigsInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_group_managers_delete_per_instance_configs_req_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/deletePerInstanceConfigs" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager,instance_group_managers_delete_per_instance_configs_req_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Returns all of the details about the specified managed instance group. + rpc Get(GetInstanceGroupManagerRequest) returns (InstanceGroupManager) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager"; + } + + // Creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. A managed instance group can have up to 1000 VM instances per group. Please contact Cloud Support if you need an increase in this limit. + rpc Insert(InsertInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_group_manager_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Retrieves a list of managed instance groups that are contained within the specified project and zone. + rpc List(ListInstanceGroupManagersRequest) returns (InstanceGroupManagerList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers" + }; + option (google.api.method_signature) = "project,zone"; + } + + // Lists all errors thrown by actions on instances for a given managed instance group. The filter and orderBy query parameters are not supported. + rpc ListErrors(ListErrorsInstanceGroupManagersRequest) returns (InstanceGroupManagersListErrorsResponse) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/listErrors" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager"; + } + + // Lists all of the instances in the managed instance group. Each instance in the list has a currentAction, which indicates the action that the managed instance group is performing on the instance. For example, if the group is still creating an instance, the currentAction is CREATING. If a previous action failed, the list displays the errors for that failed action. The orderBy query parameter is not supported. The `pageToken` query parameter is supported only in the alpha and beta API and only if the group's `listManagedInstancesResults` field is set to `PAGINATED`. + rpc ListManagedInstances(ListManagedInstancesInstanceGroupManagersRequest) returns (InstanceGroupManagersListManagedInstancesResponse) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/listManagedInstances" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager"; + } + + // Lists all of the per-instance configurations defined for the managed instance group. The orderBy query parameter is not supported. + rpc ListPerInstanceConfigs(ListPerInstanceConfigsInstanceGroupManagersRequest) returns (InstanceGroupManagersListPerInstanceConfigsResp) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/listPerInstanceConfigs" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager"; + } + + // Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listManagedInstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. If you update your group to specify a new template or instance configuration, it's possible that your intended specification for each VM in the group is different from the current state of that VM. To learn how to apply an updated configuration to the VMs in a MIG, see Updating instances in a MIG. + rpc Patch(PatchInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_group_manager_resource" + patch: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager,instance_group_manager_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch. + rpc PatchPerInstanceConfigs(PatchPerInstanceConfigsInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_group_managers_patch_per_instance_configs_req_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/patchPerInstanceConfigs" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager,instance_group_managers_patch_per_instance_configs_req_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group's current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + rpc RecreateInstances(RecreateInstancesInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_group_managers_recreate_instances_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/recreateInstances" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager,instance_group_managers_recreate_instances_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Resizes the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes instances. The resize operation is marked DONE when the resize actions are scheduled even if the group has not yet added or deleted any instances. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. When resizing down, the instance group arbitrarily chooses the order in which VMs are deleted. The group takes into account some VM attributes when making the selection including: + The status of the VM instance. + The health of the VM instance. + The instance template version the VM is based on. + For regional managed instance groups, the location of the VM instance. This list is subject to change. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. + rpc Resize(ResizeInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/resize" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager,size"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Specifies the instance template to use when creating new instances in this group. The templates for existing instances in the group do not change unless you run recreateInstances, run applyUpdatesToInstances, or set the group's updatePolicy.type to PROACTIVE. + rpc SetInstanceTemplate(SetInstanceTemplateInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_group_managers_set_instance_template_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/setInstanceTemplate" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager,instance_group_managers_set_instance_template_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Modifies the target pools to which all instances in this managed instance group are assigned. The target pools automatically apply to all of the instances in the managed instance group. This operation is marked DONE when you make the request even if the instances have not yet been added to their target pools. The change might take some time to apply to all of the instances in the group depending on the size of the group. + rpc SetTargetPools(SetTargetPoolsInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_group_managers_set_target_pools_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/setTargetPools" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager,instance_group_managers_set_target_pools_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch. + rpc UpdatePerInstanceConfigs(UpdatePerInstanceConfigsInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_group_managers_update_per_instance_configs_req_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/updatePerInstanceConfigs" + }; + option (google.api.method_signature) = "project,zone,instance_group_manager,instance_group_managers_update_per_instance_configs_req_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + +} + +// The InstanceGroups API. +service InstanceGroups { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Adds a list of instances to the specified instance group. All of the instances in the instance group must be in the same network/subnetwork. Read Adding instances for more information. + rpc AddInstances(AddInstancesInstanceGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_groups_add_instances_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{instance_group}/addInstances" + }; + option (google.api.method_signature) = "project,zone,instance_group,instance_groups_add_instances_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Retrieves the list of instance groups and sorts them by zone. + rpc AggregatedList(AggregatedListInstanceGroupsRequest) returns (InstanceGroupAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/instanceGroups" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified instance group. The instances in the group are not deleted. Note that instance group must not belong to a backend service. Read Deleting an instance group for more information. + rpc Delete(DeleteInstanceGroupRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{instance_group}" + }; + option (google.api.method_signature) = "project,zone,instance_group"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Returns the specified zonal instance group. Get a list of available zonal instance groups by making a list() request. For managed instance groups, use the instanceGroupManagers or regionInstanceGroupManagers methods instead. + rpc Get(GetInstanceGroupRequest) returns (InstanceGroup) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{instance_group}" + }; + option (google.api.method_signature) = "project,zone,instance_group"; + } + + // Creates an instance group in the specified project using the parameters that are included in the request. + rpc Insert(InsertInstanceGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_group_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroups" + }; + option (google.api.method_signature) = "project,zone,instance_group_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Retrieves the list of zonal instance group resources contained within the specified zone. For managed instance groups, use the instanceGroupManagers or regionInstanceGroupManagers methods instead. + rpc List(ListInstanceGroupsRequest) returns (InstanceGroupList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/instanceGroups" + }; + option (google.api.method_signature) = "project,zone"; + } + + // Lists the instances in the specified instance group. The orderBy query parameter is not supported. The filter query parameter is supported, but only for expressions that use `eq` (equal) or `ne` (not equal) operators. + rpc ListInstances(ListInstancesInstanceGroupsRequest) returns (InstanceGroupsListInstances) { + option (google.api.http) = { + body: "instance_groups_list_instances_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{instance_group}/listInstances" + }; + option (google.api.method_signature) = "project,zone,instance_group,instance_groups_list_instances_request_resource"; + } + + // Removes one or more instances from the specified instance group, but does not delete those instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration before the VM instance is removed or deleted. + rpc RemoveInstances(RemoveInstancesInstanceGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_groups_remove_instances_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{instance_group}/removeInstances" + }; + option (google.api.method_signature) = "project,zone,instance_group,instance_groups_remove_instances_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Sets the named ports for the specified instance group. + rpc SetNamedPorts(SetNamedPortsInstanceGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_groups_set_named_ports_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{instance_group}/setNamedPorts" + }; + option (google.api.method_signature) = "project,zone,instance_group,instance_groups_set_named_ports_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + +} + +// The InstanceTemplates API. +service InstanceTemplates { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves the list of all InstanceTemplates resources, regional and global, available to the specified project. + rpc AggregatedList(AggregatedListInstanceTemplatesRequest) returns (InstanceTemplateAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/instanceTemplates" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified instance template. Deleting an instance template is permanent and cannot be undone. It is not possible to delete templates that are already in use by a managed instance group. + rpc Delete(DeleteInstanceTemplateRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/instanceTemplates/{instance_template}" + }; + option (google.api.method_signature) = "project,instance_template"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified instance template. + rpc Get(GetInstanceTemplateRequest) returns (InstanceTemplate) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/instanceTemplates/{instance_template}" + }; + option (google.api.method_signature) = "project,instance_template"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyInstanceTemplateRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/instanceTemplates/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,resource"; + } + + // Creates an instance template in the specified project using the data that is included in the request. If you are creating a new template to update an existing instance group, your new instance template must use the same network or, if applicable, the same subnetwork as the original template. + rpc Insert(InsertInstanceTemplateRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_template_resource" + post: "/compute/v1/projects/{project}/global/instanceTemplates" + }; + option (google.api.method_signature) = "project,instance_template_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves a list of instance templates that are contained within the specified project. + rpc List(ListInstanceTemplatesRequest) returns (InstanceTemplateList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/instanceTemplates" + }; + option (google.api.method_signature) = "project"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyInstanceTemplateRequest) returns (Policy) { + option (google.api.http) = { + body: "global_set_policy_request_resource" + post: "/compute/v1/projects/{project}/global/instanceTemplates/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,resource,global_set_policy_request_resource"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsInstanceTemplateRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/global/instanceTemplates/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,resource,test_permissions_request_resource"; + } + +} + +// The Instances API. +service Instances { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Adds an access config to an instance's network interface. + rpc AddAccessConfig(AddAccessConfigInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "access_config_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/addAccessConfig" + }; + option (google.api.method_signature) = "project,zone,instance,network_interface,access_config_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Adds existing resource policies to an instance. You can only add one policy right now which will be applied to this instance for scheduling live migrations. + rpc AddResourcePolicies(AddResourcePoliciesInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "instances_add_resource_policies_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/addResourcePolicies" + }; + option (google.api.method_signature) = "project,zone,instance,instances_add_resource_policies_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Retrieves an aggregated list of all of the instances in your project across all regions and zones. The performance of this method degrades when a filter is specified on a project that has a very large number of instances. + rpc AggregatedList(AggregatedListInstancesRequest) returns (InstanceAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/instances" + }; + option (google.api.method_signature) = "project"; + } + + // Attaches an existing Disk resource to an instance. You must first create the disk before you can attach it. It is not possible to create and attach a disk at the same time. For more information, read Adding a persistent disk to your instance. + rpc AttachDisk(AttachDiskInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "attached_disk_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/attachDisk" + }; + option (google.api.method_signature) = "project,zone,instance,attached_disk_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Creates multiple instances. Count specifies the number of instances to create. For more information, see About bulk creation of VMs. + rpc BulkInsert(BulkInsertInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "bulk_insert_instance_resource_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/bulkInsert" + }; + option (google.api.method_signature) = "project,zone,bulk_insert_instance_resource_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Deletes the specified Instance resource. For more information, see Deleting an instance. + rpc Delete(DeleteInstanceRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}" + }; + option (google.api.method_signature) = "project,zone,instance"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Deletes an access config from an instance's network interface. + rpc DeleteAccessConfig(DeleteAccessConfigInstanceRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/deleteAccessConfig" + }; + option (google.api.method_signature) = "project,zone,instance,access_config,network_interface"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Detaches a disk from an instance. + rpc DetachDisk(DetachDiskInstanceRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/detachDisk" + }; + option (google.api.method_signature) = "project,zone,instance,device_name"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Returns the specified Instance resource. + rpc Get(GetInstanceRequest) returns (Instance) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}" + }; + option (google.api.method_signature) = "project,zone,instance"; + } + + // Returns effective firewalls applied to an interface of the instance. + rpc GetEffectiveFirewalls(GetEffectiveFirewallsInstanceRequest) returns (InstancesGetEffectiveFirewallsResponse) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/getEffectiveFirewalls" + }; + option (google.api.method_signature) = "project,zone,instance,network_interface"; + } + + // Returns the specified guest attributes entry. + rpc GetGuestAttributes(GetGuestAttributesInstanceRequest) returns (GuestAttributes) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/getGuestAttributes" + }; + option (google.api.method_signature) = "project,zone,instance"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyInstanceRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/instances/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,zone,resource"; + } + + // Returns the screenshot from the specified instance. + rpc GetScreenshot(GetScreenshotInstanceRequest) returns (Screenshot) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/screenshot" + }; + option (google.api.method_signature) = "project,zone,instance"; + } + + // Returns the last 1 MB of serial port output from the specified instance. + rpc GetSerialPortOutput(GetSerialPortOutputInstanceRequest) returns (SerialPortOutput) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/serialPort" + }; + option (google.api.method_signature) = "project,zone,instance"; + } + + // Returns the Shielded Instance Identity of an instance + rpc GetShieldedInstanceIdentity(GetShieldedInstanceIdentityInstanceRequest) returns (ShieldedInstanceIdentity) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/getShieldedInstanceIdentity" + }; + option (google.api.method_signature) = "project,zone,instance"; + } + + // Creates an instance resource in the specified project using the data included in the request. + rpc Insert(InsertInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances" + }; + option (google.api.method_signature) = "project,zone,instance_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Retrieves the list of instances contained within the specified zone. + rpc List(ListInstancesRequest) returns (InstanceList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/instances" + }; + option (google.api.method_signature) = "project,zone"; + } + + // Retrieves a list of resources that refer to the VM instance specified in the request. For example, if the VM instance is part of a managed or unmanaged instance group, the referrers list includes the instance group. For more information, read Viewing referrers to VM instances. + rpc ListReferrers(ListReferrersInstancesRequest) returns (InstanceListReferrers) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/referrers" + }; + option (google.api.method_signature) = "project,zone,instance"; + } + + // Removes resource policies from an instance. + rpc RemoveResourcePolicies(RemoveResourcePoliciesInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "instances_remove_resource_policies_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/removeResourcePolicies" + }; + option (google.api.method_signature) = "project,zone,instance,instances_remove_resource_policies_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more information, see Resetting an instance. + rpc Reset(ResetInstanceRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/reset" + }; + option (google.api.method_signature) = "project,zone,instance"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Resumes an instance that was suspended using the instances().suspend method. + rpc Resume(ResumeInstanceRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/resume" + }; + option (google.api.method_signature) = "project,zone,instance"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Sends diagnostic interrupt to the instance. + rpc SendDiagnosticInterrupt(SendDiagnosticInterruptInstanceRequest) returns (SendDiagnosticInterruptInstanceResponse) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/sendDiagnosticInterrupt" + }; + option (google.api.method_signature) = "project,zone,instance"; + } + + // Sets deletion protection on the instance. + rpc SetDeletionProtection(SetDeletionProtectionInstanceRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{resource}/setDeletionProtection" + }; + option (google.api.method_signature) = "project,zone,resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Sets the auto-delete flag for a disk attached to an instance. + rpc SetDiskAutoDelete(SetDiskAutoDeleteInstanceRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setDiskAutoDelete" + }; + option (google.api.method_signature) = "project,zone,instance,auto_delete,device_name"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyInstanceRequest) returns (Policy) { + option (google.api.http) = { + body: "zone_set_policy_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,zone,resource,zone_set_policy_request_resource"; + } + + // Sets labels on an instance. To learn more about labels, read the Labeling Resources documentation. + rpc SetLabels(SetLabelsInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "instances_set_labels_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setLabels" + }; + option (google.api.method_signature) = "project,zone,instance,instances_set_labels_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Changes the number and/or type of accelerator for a stopped instance to the values specified in the request. + rpc SetMachineResources(SetMachineResourcesInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "instances_set_machine_resources_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setMachineResources" + }; + option (google.api.method_signature) = "project,zone,instance,instances_set_machine_resources_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Changes the machine type for a stopped instance to the machine type specified in the request. + rpc SetMachineType(SetMachineTypeInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "instances_set_machine_type_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setMachineType" + }; + option (google.api.method_signature) = "project,zone,instance,instances_set_machine_type_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Sets metadata for the specified instance to the data included in the request. + rpc SetMetadata(SetMetadataInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "metadata_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setMetadata" + }; + option (google.api.method_signature) = "project,zone,instance,metadata_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Changes the minimum CPU platform that this instance should use. This method can only be called on a stopped instance. For more information, read Specifying a Minimum CPU Platform. + rpc SetMinCpuPlatform(SetMinCpuPlatformInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "instances_set_min_cpu_platform_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setMinCpuPlatform" + }; + option (google.api.method_signature) = "project,zone,instance,instances_set_min_cpu_platform_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Sets name of an instance. + rpc SetName(SetNameInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "instances_set_name_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setName" + }; + option (google.api.method_signature) = "project,zone,instance,instances_set_name_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Sets an instance's scheduling options. You can only call this method on a stopped instance, that is, a VM instance that is in a `TERMINATED` state. See Instance Life Cycle for more information on the possible instance states. For more information about setting scheduling options for a VM, see Set VM host maintenance policy. + rpc SetScheduling(SetSchedulingInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "scheduling_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setScheduling" + }; + option (google.api.method_signature) = "project,zone,instance,scheduling_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Sets the service account on the instance. For more information, read Changing the service account and access scopes for an instance. + rpc SetServiceAccount(SetServiceAccountInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "instances_set_service_account_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setServiceAccount" + }; + option (google.api.method_signature) = "project,zone,instance,instances_set_service_account_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Sets the Shielded Instance integrity policy for an instance. You can only use this method on a running instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + rpc SetShieldedInstanceIntegrityPolicy(SetShieldedInstanceIntegrityPolicyInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "shielded_instance_integrity_policy_resource" + patch: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setShieldedInstanceIntegrityPolicy" + }; + option (google.api.method_signature) = "project,zone,instance,shielded_instance_integrity_policy_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Sets network tags for the specified instance to the data included in the request. + rpc SetTags(SetTagsInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "tags_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setTags" + }; + option (google.api.method_signature) = "project,zone,instance,tags_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Simulates a host maintenance event on a VM. For more information, see Simulate a host maintenance event. + rpc SimulateMaintenanceEvent(SimulateMaintenanceEventInstanceRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/simulateMaintenanceEvent" + }; + option (google.api.method_signature) = "project,zone,instance"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance. + rpc Start(StartInstanceRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/start" + }; + option (google.api.method_signature) = "project,zone,instance"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance. + rpc StartWithEncryptionKey(StartWithEncryptionKeyInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "instances_start_with_encryption_key_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/startWithEncryptionKey" + }; + option (google.api.method_signature) = "project,zone,instance,instances_start_with_encryption_key_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. Stopped instances do not incur VM usage charges while they are stopped. However, resources that the VM is using, such as persistent disks and static IP addresses, will continue to be charged until they are deleted. For more information, see Stopping an instance. + rpc Stop(StopInstanceRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/stop" + }; + option (google.api.method_signature) = "project,zone,instance"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // This method suspends a running instance, saving its state to persistent storage, and allows you to resume the instance at a later time. Suspended instances have no compute costs (cores or RAM), and incur only storage charges for the saved VM memory and localSSD data. Any charged resources the virtual machine was using, such as persistent disks and static IP addresses, will continue to be charged while the instance is suspended. For more information, see Suspending and resuming an instance. + rpc Suspend(SuspendInstanceRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/suspend" + }; + option (google.api.method_signature) = "project,zone,instance"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsInstanceRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,zone,resource,test_permissions_request_resource"; + } + + // Updates an instance only if the necessary resources are available. This method can update only a specific set of instance properties. See Updating a running instance for a list of updatable instance properties. + rpc Update(UpdateInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_resource" + put: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}" + }; + option (google.api.method_signature) = "project,zone,instance,instance_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Updates the specified access config from an instance's network interface with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + rpc UpdateAccessConfig(UpdateAccessConfigInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "access_config_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/updateAccessConfig" + }; + option (google.api.method_signature) = "project,zone,instance,network_interface,access_config_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Updates the Display config for a VM instance. You can only use this method on a stopped VM instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + rpc UpdateDisplayDevice(UpdateDisplayDeviceInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "display_device_resource" + patch: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/updateDisplayDevice" + }; + option (google.api.method_signature) = "project,zone,instance,display_device_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Updates an instance's network interface. This method can only update an interface's alias IP range and attached network. See Modifying alias IP ranges for an existing instance for instructions on changing alias IP ranges. See Migrating a VM between networks for instructions on migrating an interface. This method follows PATCH semantics. + rpc UpdateNetworkInterface(UpdateNetworkInterfaceInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "network_interface_resource" + patch: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/updateNetworkInterface" + }; + option (google.api.method_signature) = "project,zone,instance,network_interface,network_interface_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Updates the Shielded Instance config for an instance. You can only use this method on a stopped instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + rpc UpdateShieldedInstanceConfig(UpdateShieldedInstanceConfigInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "shielded_instance_config_resource" + patch: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/updateShieldedInstanceConfig" + }; + option (google.api.method_signature) = "project,zone,instance,shielded_instance_config_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + +} + +// The InterconnectAttachments API. +service InterconnectAttachments { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of interconnect attachments. + rpc AggregatedList(AggregatedListInterconnectAttachmentsRequest) returns (InterconnectAttachmentAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/interconnectAttachments" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified interconnect attachment. + rpc Delete(DeleteInterconnectAttachmentRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/interconnectAttachments/{interconnect_attachment}" + }; + option (google.api.method_signature) = "project,region,interconnect_attachment"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified interconnect attachment. + rpc Get(GetInterconnectAttachmentRequest) returns (InterconnectAttachment) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/interconnectAttachments/{interconnect_attachment}" + }; + option (google.api.method_signature) = "project,region,interconnect_attachment"; + } + + // Creates an InterconnectAttachment in the specified project using the data included in the request. + rpc Insert(InsertInterconnectAttachmentRequest) returns (Operation) { + option (google.api.http) = { + body: "interconnect_attachment_resource" + post: "/compute/v1/projects/{project}/regions/{region}/interconnectAttachments" + }; + option (google.api.method_signature) = "project,region,interconnect_attachment_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves the list of interconnect attachments contained within the specified region. + rpc List(ListInterconnectAttachmentsRequest) returns (InterconnectAttachmentList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/interconnectAttachments" + }; + option (google.api.method_signature) = "project,region"; + } + + // Updates the specified interconnect attachment with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + rpc Patch(PatchInterconnectAttachmentRequest) returns (Operation) { + option (google.api.http) = { + body: "interconnect_attachment_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/interconnectAttachments/{interconnect_attachment}" + }; + option (google.api.method_signature) = "project,region,interconnect_attachment,interconnect_attachment_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Sets the labels on an InterconnectAttachment. To learn more about labels, read the Labeling Resources documentation. + rpc SetLabels(SetLabelsInterconnectAttachmentRequest) returns (Operation) { + option (google.api.http) = { + body: "region_set_labels_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/interconnectAttachments/{resource}/setLabels" + }; + option (google.api.method_signature) = "project,region,resource,region_set_labels_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The InterconnectLocations API. +service InterconnectLocations { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute.readonly," + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Returns the details for the specified interconnect location. Gets a list of available interconnect locations by making a list() request. + rpc Get(GetInterconnectLocationRequest) returns (InterconnectLocation) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/interconnectLocations/{interconnect_location}" + }; + option (google.api.method_signature) = "project,interconnect_location"; + } + + // Retrieves the list of interconnect locations available to the specified project. + rpc List(ListInterconnectLocationsRequest) returns (InterconnectLocationList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/interconnectLocations" + }; + option (google.api.method_signature) = "project"; + } + +} + +// The Interconnects API. +service Interconnects { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified Interconnect. + rpc Delete(DeleteInterconnectRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/interconnects/{interconnect}" + }; + option (google.api.method_signature) = "project,interconnect"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified Interconnect. Get a list of available Interconnects by making a list() request. + rpc Get(GetInterconnectRequest) returns (Interconnect) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/interconnects/{interconnect}" + }; + option (google.api.method_signature) = "project,interconnect"; + } + + // Returns the interconnectDiagnostics for the specified Interconnect. + rpc GetDiagnostics(GetDiagnosticsInterconnectRequest) returns (InterconnectsGetDiagnosticsResponse) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/interconnects/{interconnect}/getDiagnostics" + }; + option (google.api.method_signature) = "project,interconnect"; + } + + // Creates an Interconnect in the specified project using the data included in the request. + rpc Insert(InsertInterconnectRequest) returns (Operation) { + option (google.api.http) = { + body: "interconnect_resource" + post: "/compute/v1/projects/{project}/global/interconnects" + }; + option (google.api.method_signature) = "project,interconnect_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of Interconnects available to the specified project. + rpc List(ListInterconnectsRequest) returns (InterconnectList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/interconnects" + }; + option (google.api.method_signature) = "project"; + } + + // Updates the specified Interconnect with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + rpc Patch(PatchInterconnectRequest) returns (Operation) { + option (google.api.http) = { + body: "interconnect_resource" + patch: "/compute/v1/projects/{project}/global/interconnects/{interconnect}" + }; + option (google.api.method_signature) = "project,interconnect,interconnect_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Sets the labels on an Interconnect. To learn more about labels, read the Labeling Resources documentation. + rpc SetLabels(SetLabelsInterconnectRequest) returns (Operation) { + option (google.api.http) = { + body: "global_set_labels_request_resource" + post: "/compute/v1/projects/{project}/global/interconnects/{resource}/setLabels" + }; + option (google.api.method_signature) = "project,resource,global_set_labels_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The LicenseCodes API. +service LicenseCodes { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute.readonly," + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Return a specified license code. License codes are mirrored across all projects that have permissions to read the License Code. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + rpc Get(GetLicenseCodeRequest) returns (LicenseCode) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/licenseCodes/{license_code}" + }; + option (google.api.method_signature) = "project,license_code"; + } + + // Returns permissions that a caller has on the specified resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + rpc TestIamPermissions(TestIamPermissionsLicenseCodeRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/global/licenseCodes/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,resource,test_permissions_request_resource"; + } + +} + +// The Licenses API. +service Licenses { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified license. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + rpc Delete(DeleteLicenseRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/licenses/{license}" + }; + option (google.api.method_signature) = "project,license"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified License resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + rpc Get(GetLicenseRequest) returns (License) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/licenses/{license}" + }; + option (google.api.method_signature) = "project,license"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + rpc GetIamPolicy(GetIamPolicyLicenseRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/licenses/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,resource"; + } + + // Create a License resource in the specified project. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + rpc Insert(InsertLicenseRequest) returns (Operation) { + option (google.api.http) = { + body: "license_resource" + post: "/compute/v1/projects/{project}/global/licenses" + }; + option (google.api.method_signature) = "project,license_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of licenses available in the specified project. This method does not get any licenses that belong to other projects, including licenses attached to publicly-available images, like Debian 9. If you want to get a list of publicly-available licenses, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + rpc List(ListLicensesRequest) returns (LicensesListResponse) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/licenses" + }; + option (google.api.method_signature) = "project"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + rpc SetIamPolicy(SetIamPolicyLicenseRequest) returns (Policy) { + option (google.api.http) = { + body: "global_set_policy_request_resource" + post: "/compute/v1/projects/{project}/global/licenses/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,resource,global_set_policy_request_resource"; + } + + // Returns permissions that a caller has on the specified resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + rpc TestIamPermissions(TestIamPermissionsLicenseRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/global/licenses/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,resource,test_permissions_request_resource"; + } + +} + +// The MachineImages API. +service MachineImages { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified machine image. Deleting a machine image is permanent and cannot be undone. + rpc Delete(DeleteMachineImageRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/machineImages/{machine_image}" + }; + option (google.api.method_signature) = "project,machine_image"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified machine image. + rpc Get(GetMachineImageRequest) returns (MachineImage) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/machineImages/{machine_image}" + }; + option (google.api.method_signature) = "project,machine_image"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyMachineImageRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/machineImages/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,resource"; + } + + // Creates a machine image in the specified project using the data that is included in the request. If you are creating a new machine image to update an existing instance, your new machine image should use the same network or, if applicable, the same subnetwork as the original instance. + rpc Insert(InsertMachineImageRequest) returns (Operation) { + option (google.api.http) = { + body: "machine_image_resource" + post: "/compute/v1/projects/{project}/global/machineImages" + }; + option (google.api.method_signature) = "project,machine_image_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves a list of machine images that are contained within the specified project. + rpc List(ListMachineImagesRequest) returns (MachineImageList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/machineImages" + }; + option (google.api.method_signature) = "project"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyMachineImageRequest) returns (Policy) { + option (google.api.http) = { + body: "global_set_policy_request_resource" + post: "/compute/v1/projects/{project}/global/machineImages/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,resource,global_set_policy_request_resource"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsMachineImageRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/global/machineImages/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,resource,test_permissions_request_resource"; + } + +} + +// The MachineTypes API. +service MachineTypes { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute.readonly," + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of machine types. + rpc AggregatedList(AggregatedListMachineTypesRequest) returns (MachineTypeAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/machineTypes" + }; + option (google.api.method_signature) = "project"; + } + + // Returns the specified machine type. + rpc Get(GetMachineTypeRequest) returns (MachineType) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/machineTypes/{machine_type}" + }; + option (google.api.method_signature) = "project,zone,machine_type"; + } + + // Retrieves a list of machine types available to the specified project. + rpc List(ListMachineTypesRequest) returns (MachineTypeList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/machineTypes" + }; + option (google.api.method_signature) = "project,zone"; + } + +} + +// The NetworkAttachments API. +service NetworkAttachments { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves the list of all NetworkAttachment resources, regional and global, available to the specified project. + rpc AggregatedList(AggregatedListNetworkAttachmentsRequest) returns (NetworkAttachmentAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/networkAttachments" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified NetworkAttachment in the given scope + rpc Delete(DeleteNetworkAttachmentRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/networkAttachments/{network_attachment}" + }; + option (google.api.method_signature) = "project,region,network_attachment"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified NetworkAttachment resource in the given scope. + rpc Get(GetNetworkAttachmentRequest) returns (NetworkAttachment) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/networkAttachments/{network_attachment}" + }; + option (google.api.method_signature) = "project,region,network_attachment"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyNetworkAttachmentRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/networkAttachments/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,region,resource"; + } + + // Creates a NetworkAttachment in the specified project in the given scope using the parameters that are included in the request. + rpc Insert(InsertNetworkAttachmentRequest) returns (Operation) { + option (google.api.http) = { + body: "network_attachment_resource" + post: "/compute/v1/projects/{project}/regions/{region}/networkAttachments" + }; + option (google.api.method_signature) = "project,region,network_attachment_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Lists the NetworkAttachments for a project in the given scope. + rpc List(ListNetworkAttachmentsRequest) returns (NetworkAttachmentList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/networkAttachments" + }; + option (google.api.method_signature) = "project,region"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyNetworkAttachmentRequest) returns (Policy) { + option (google.api.http) = { + body: "region_set_policy_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/networkAttachments/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,region,resource,region_set_policy_request_resource"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsNetworkAttachmentRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/networkAttachments/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,region,resource,test_permissions_request_resource"; + } + +} + +// The NetworkEdgeSecurityServices API. +service NetworkEdgeSecurityServices { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves the list of all NetworkEdgeSecurityService resources available to the specified project. + rpc AggregatedList(AggregatedListNetworkEdgeSecurityServicesRequest) returns (NetworkEdgeSecurityServiceAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/networkEdgeSecurityServices" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified service. + rpc Delete(DeleteNetworkEdgeSecurityServiceRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/networkEdgeSecurityServices/{network_edge_security_service}" + }; + option (google.api.method_signature) = "project,region,network_edge_security_service"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Gets a specified NetworkEdgeSecurityService. + rpc Get(GetNetworkEdgeSecurityServiceRequest) returns (NetworkEdgeSecurityService) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/networkEdgeSecurityServices/{network_edge_security_service}" + }; + option (google.api.method_signature) = "project,region,network_edge_security_service"; + } + + // Creates a new service in the specified project using the data included in the request. + rpc Insert(InsertNetworkEdgeSecurityServiceRequest) returns (Operation) { + option (google.api.http) = { + body: "network_edge_security_service_resource" + post: "/compute/v1/projects/{project}/regions/{region}/networkEdgeSecurityServices" + }; + option (google.api.method_signature) = "project,region,network_edge_security_service_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Patches the specified policy with the data included in the request. + rpc Patch(PatchNetworkEdgeSecurityServiceRequest) returns (Operation) { + option (google.api.http) = { + body: "network_edge_security_service_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/networkEdgeSecurityServices/{network_edge_security_service}" + }; + option (google.api.method_signature) = "project,region,network_edge_security_service,network_edge_security_service_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The NetworkEndpointGroups API. +service NetworkEndpointGroups { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves the list of network endpoint groups and sorts them by zone. + rpc AggregatedList(AggregatedListNetworkEndpointGroupsRequest) returns (NetworkEndpointGroupAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/networkEndpointGroups" + }; + option (google.api.method_signature) = "project"; + } + + // Attach a list of network endpoints to the specified network endpoint group. + rpc AttachNetworkEndpoints(AttachNetworkEndpointsNetworkEndpointGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "network_endpoint_groups_attach_endpoints_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/networkEndpointGroups/{network_endpoint_group}/attachNetworkEndpoints" + }; + option (google.api.method_signature) = "project,zone,network_endpoint_group,network_endpoint_groups_attach_endpoints_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Deletes the specified network endpoint group. The network endpoints in the NEG and the VM instances they belong to are not terminated when the NEG is deleted. Note that the NEG cannot be deleted if there are backend services referencing it. + rpc Delete(DeleteNetworkEndpointGroupRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/zones/{zone}/networkEndpointGroups/{network_endpoint_group}" + }; + option (google.api.method_signature) = "project,zone,network_endpoint_group"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Detach a list of network endpoints from the specified network endpoint group. + rpc DetachNetworkEndpoints(DetachNetworkEndpointsNetworkEndpointGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "network_endpoint_groups_detach_endpoints_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/networkEndpointGroups/{network_endpoint_group}/detachNetworkEndpoints" + }; + option (google.api.method_signature) = "project,zone,network_endpoint_group,network_endpoint_groups_detach_endpoints_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Returns the specified network endpoint group. + rpc Get(GetNetworkEndpointGroupRequest) returns (NetworkEndpointGroup) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/networkEndpointGroups/{network_endpoint_group}" + }; + option (google.api.method_signature) = "project,zone,network_endpoint_group"; + } + + // Creates a network endpoint group in the specified project using the parameters that are included in the request. + rpc Insert(InsertNetworkEndpointGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "network_endpoint_group_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/networkEndpointGroups" + }; + option (google.api.method_signature) = "project,zone,network_endpoint_group_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Retrieves the list of network endpoint groups that are located in the specified project and zone. + rpc List(ListNetworkEndpointGroupsRequest) returns (NetworkEndpointGroupList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/networkEndpointGroups" + }; + option (google.api.method_signature) = "project,zone"; + } + + // Lists the network endpoints in the specified network endpoint group. + rpc ListNetworkEndpoints(ListNetworkEndpointsNetworkEndpointGroupsRequest) returns (NetworkEndpointGroupsListNetworkEndpoints) { + option (google.api.http) = { + body: "network_endpoint_groups_list_endpoints_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/networkEndpointGroups/{network_endpoint_group}/listNetworkEndpoints" + }; + option (google.api.method_signature) = "project,zone,network_endpoint_group,network_endpoint_groups_list_endpoints_request_resource"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsNetworkEndpointGroupRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/networkEndpointGroups/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,zone,resource,test_permissions_request_resource"; + } + +} + +// The NetworkFirewallPolicies API. +service NetworkFirewallPolicies { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Inserts an association for the specified firewall policy. + rpc AddAssociation(AddAssociationNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_policy_association_resource" + post: "/compute/v1/projects/{project}/global/firewallPolicies/{firewall_policy}/addAssociation" + }; + option (google.api.method_signature) = "project,firewall_policy,firewall_policy_association_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Inserts a rule into a firewall policy. + rpc AddRule(AddRuleNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_policy_rule_resource" + post: "/compute/v1/projects/{project}/global/firewallPolicies/{firewall_policy}/addRule" + }; + option (google.api.method_signature) = "project,firewall_policy,firewall_policy_rule_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Copies rules to the specified firewall policy. + rpc CloneRules(CloneRulesNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/global/firewallPolicies/{firewall_policy}/cloneRules" + }; + option (google.api.method_signature) = "project,firewall_policy"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Deletes the specified policy. + rpc Delete(DeleteNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/firewallPolicies/{firewall_policy}" + }; + option (google.api.method_signature) = "project,firewall_policy"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified network firewall policy. + rpc Get(GetNetworkFirewallPolicyRequest) returns (FirewallPolicy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/firewallPolicies/{firewall_policy}" + }; + option (google.api.method_signature) = "project,firewall_policy"; + } + + // Gets an association with the specified name. + rpc GetAssociation(GetAssociationNetworkFirewallPolicyRequest) returns (FirewallPolicyAssociation) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/firewallPolicies/{firewall_policy}/getAssociation" + }; + option (google.api.method_signature) = "project,firewall_policy"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyNetworkFirewallPolicyRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/firewallPolicies/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,resource"; + } + + // Gets a rule of the specified priority. + rpc GetRule(GetRuleNetworkFirewallPolicyRequest) returns (FirewallPolicyRule) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/firewallPolicies/{firewall_policy}/getRule" + }; + option (google.api.method_signature) = "project,firewall_policy"; + } + + // Creates a new policy in the specified project using the data included in the request. + rpc Insert(InsertNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_policy_resource" + post: "/compute/v1/projects/{project}/global/firewallPolicies" + }; + option (google.api.method_signature) = "project,firewall_policy_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Lists all the policies that have been configured for the specified project. + rpc List(ListNetworkFirewallPoliciesRequest) returns (FirewallPolicyList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/firewallPolicies" + }; + option (google.api.method_signature) = "project"; + } + + // Patches the specified policy with the data included in the request. + rpc Patch(PatchNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_policy_resource" + patch: "/compute/v1/projects/{project}/global/firewallPolicies/{firewall_policy}" + }; + option (google.api.method_signature) = "project,firewall_policy,firewall_policy_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Patches a rule of the specified priority. + rpc PatchRule(PatchRuleNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_policy_rule_resource" + post: "/compute/v1/projects/{project}/global/firewallPolicies/{firewall_policy}/patchRule" + }; + option (google.api.method_signature) = "project,firewall_policy,firewall_policy_rule_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Removes an association for the specified firewall policy. + rpc RemoveAssociation(RemoveAssociationNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/global/firewallPolicies/{firewall_policy}/removeAssociation" + }; + option (google.api.method_signature) = "project,firewall_policy"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Deletes a rule of the specified priority. + rpc RemoveRule(RemoveRuleNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/global/firewallPolicies/{firewall_policy}/removeRule" + }; + option (google.api.method_signature) = "project,firewall_policy"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyNetworkFirewallPolicyRequest) returns (Policy) { + option (google.api.http) = { + body: "global_set_policy_request_resource" + post: "/compute/v1/projects/{project}/global/firewallPolicies/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,resource,global_set_policy_request_resource"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsNetworkFirewallPolicyRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/global/firewallPolicies/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,resource,test_permissions_request_resource"; + } + +} + +// The Networks API. +service Networks { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Adds a peering to the specified network. + rpc AddPeering(AddPeeringNetworkRequest) returns (Operation) { + option (google.api.http) = { + body: "networks_add_peering_request_resource" + post: "/compute/v1/projects/{project}/global/networks/{network}/addPeering" + }; + option (google.api.method_signature) = "project,network,networks_add_peering_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Deletes the specified network. + rpc Delete(DeleteNetworkRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/networks/{network}" + }; + option (google.api.method_signature) = "project,network"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified network. + rpc Get(GetNetworkRequest) returns (Network) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/networks/{network}" + }; + option (google.api.method_signature) = "project,network"; + } + + // Returns the effective firewalls on a given network. + rpc GetEffectiveFirewalls(GetEffectiveFirewallsNetworkRequest) returns (NetworksGetEffectiveFirewallsResponse) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/networks/{network}/getEffectiveFirewalls" + }; + option (google.api.method_signature) = "project,network"; + } + + // Creates a network in the specified project using the data included in the request. + rpc Insert(InsertNetworkRequest) returns (Operation) { + option (google.api.http) = { + body: "network_resource" + post: "/compute/v1/projects/{project}/global/networks" + }; + option (google.api.method_signature) = "project,network_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of networks available to the specified project. + rpc List(ListNetworksRequest) returns (NetworkList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/networks" + }; + option (google.api.method_signature) = "project"; + } + + // Lists the peering routes exchanged over peering connection. + rpc ListPeeringRoutes(ListPeeringRoutesNetworksRequest) returns (ExchangedPeeringRoutesList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/networks/{network}/listPeeringRoutes" + }; + option (google.api.method_signature) = "project,network"; + } + + // Patches the specified network with the data included in the request. Only the following fields can be modified: routingConfig.routingMode. + rpc Patch(PatchNetworkRequest) returns (Operation) { + option (google.api.http) = { + body: "network_resource" + patch: "/compute/v1/projects/{project}/global/networks/{network}" + }; + option (google.api.method_signature) = "project,network,network_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Removes a peering from the specified network. + rpc RemovePeering(RemovePeeringNetworkRequest) returns (Operation) { + option (google.api.http) = { + body: "networks_remove_peering_request_resource" + post: "/compute/v1/projects/{project}/global/networks/{network}/removePeering" + }; + option (google.api.method_signature) = "project,network,networks_remove_peering_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Switches the network mode from auto subnet mode to custom subnet mode. + rpc SwitchToCustomMode(SwitchToCustomModeNetworkRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/global/networks/{network}/switchToCustomMode" + }; + option (google.api.method_signature) = "project,network"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Updates the specified network peering with the data included in the request. You can only modify the NetworkPeering.export_custom_routes field and the NetworkPeering.import_custom_routes field. + rpc UpdatePeering(UpdatePeeringNetworkRequest) returns (Operation) { + option (google.api.http) = { + body: "networks_update_peering_request_resource" + patch: "/compute/v1/projects/{project}/global/networks/{network}/updatePeering" + }; + option (google.api.method_signature) = "project,network,networks_update_peering_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The NodeGroups API. +service NodeGroups { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Adds specified number of nodes to the node group. + rpc AddNodes(AddNodesNodeGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "node_groups_add_nodes_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/nodeGroups/{node_group}/addNodes" + }; + option (google.api.method_signature) = "project,zone,node_group,node_groups_add_nodes_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Retrieves an aggregated list of node groups. Note: use nodeGroups.listNodes for more details about each group. + rpc AggregatedList(AggregatedListNodeGroupsRequest) returns (NodeGroupAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/nodeGroups" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified NodeGroup resource. + rpc Delete(DeleteNodeGroupRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/zones/{zone}/nodeGroups/{node_group}" + }; + option (google.api.method_signature) = "project,zone,node_group"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Deletes specified nodes from the node group. + rpc DeleteNodes(DeleteNodesNodeGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "node_groups_delete_nodes_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/nodeGroups/{node_group}/deleteNodes" + }; + option (google.api.method_signature) = "project,zone,node_group,node_groups_delete_nodes_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Returns the specified NodeGroup. Get a list of available NodeGroups by making a list() request. Note: the "nodes" field should not be used. Use nodeGroups.listNodes instead. + rpc Get(GetNodeGroupRequest) returns (NodeGroup) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/nodeGroups/{node_group}" + }; + option (google.api.method_signature) = "project,zone,node_group"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyNodeGroupRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/nodeGroups/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,zone,resource"; + } + + // Creates a NodeGroup resource in the specified project using the data included in the request. + rpc Insert(InsertNodeGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "node_group_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/nodeGroups" + }; + option (google.api.method_signature) = "project,zone,initial_node_count,node_group_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Retrieves a list of node groups available to the specified project. Note: use nodeGroups.listNodes for more details about each group. + rpc List(ListNodeGroupsRequest) returns (NodeGroupList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/nodeGroups" + }; + option (google.api.method_signature) = "project,zone"; + } + + // Lists nodes in the node group. + rpc ListNodes(ListNodesNodeGroupsRequest) returns (NodeGroupsListNodes) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/zones/{zone}/nodeGroups/{node_group}/listNodes" + }; + option (google.api.method_signature) = "project,zone,node_group"; + } + + // Updates the specified node group. + rpc Patch(PatchNodeGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "node_group_resource" + patch: "/compute/v1/projects/{project}/zones/{zone}/nodeGroups/{node_group}" + }; + option (google.api.method_signature) = "project,zone,node_group,node_group_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyNodeGroupRequest) returns (Policy) { + option (google.api.http) = { + body: "zone_set_policy_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/nodeGroups/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,zone,resource,zone_set_policy_request_resource"; + } + + // Updates the node template of the node group. + rpc SetNodeTemplate(SetNodeTemplateNodeGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "node_groups_set_node_template_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/nodeGroups/{node_group}/setNodeTemplate" + }; + option (google.api.method_signature) = "project,zone,node_group,node_groups_set_node_template_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Simulates maintenance event on specified nodes from the node group. + rpc SimulateMaintenanceEvent(SimulateMaintenanceEventNodeGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "node_groups_simulate_maintenance_event_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/nodeGroups/{node_group}/simulateMaintenanceEvent" + }; + option (google.api.method_signature) = "project,zone,node_group,node_groups_simulate_maintenance_event_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsNodeGroupRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/nodeGroups/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,zone,resource,test_permissions_request_resource"; + } + +} + +// The NodeTemplates API. +service NodeTemplates { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of node templates. + rpc AggregatedList(AggregatedListNodeTemplatesRequest) returns (NodeTemplateAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/nodeTemplates" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified NodeTemplate resource. + rpc Delete(DeleteNodeTemplateRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/nodeTemplates/{node_template}" + }; + option (google.api.method_signature) = "project,region,node_template"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified node template. + rpc Get(GetNodeTemplateRequest) returns (NodeTemplate) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/nodeTemplates/{node_template}" + }; + option (google.api.method_signature) = "project,region,node_template"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyNodeTemplateRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/nodeTemplates/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,region,resource"; + } + + // Creates a NodeTemplate resource in the specified project using the data included in the request. + rpc Insert(InsertNodeTemplateRequest) returns (Operation) { + option (google.api.http) = { + body: "node_template_resource" + post: "/compute/v1/projects/{project}/regions/{region}/nodeTemplates" + }; + option (google.api.method_signature) = "project,region,node_template_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves a list of node templates available to the specified project. + rpc List(ListNodeTemplatesRequest) returns (NodeTemplateList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/nodeTemplates" + }; + option (google.api.method_signature) = "project,region"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyNodeTemplateRequest) returns (Policy) { + option (google.api.http) = { + body: "region_set_policy_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/nodeTemplates/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,region,resource,region_set_policy_request_resource"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsNodeTemplateRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/nodeTemplates/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,region,resource,test_permissions_request_resource"; + } + +} + +// The NodeTypes API. +service NodeTypes { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute.readonly," + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of node types. + rpc AggregatedList(AggregatedListNodeTypesRequest) returns (NodeTypeAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/nodeTypes" + }; + option (google.api.method_signature) = "project"; + } + + // Returns the specified node type. + rpc Get(GetNodeTypeRequest) returns (NodeType) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/nodeTypes/{node_type}" + }; + option (google.api.method_signature) = "project,zone,node_type"; + } + + // Retrieves a list of node types available to the specified project. + rpc List(ListNodeTypesRequest) returns (NodeTypeList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/nodeTypes" + }; + option (google.api.method_signature) = "project,zone"; + } + +} + +// The PacketMirrorings API. +service PacketMirrorings { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of packetMirrorings. + rpc AggregatedList(AggregatedListPacketMirroringsRequest) returns (PacketMirroringAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/packetMirrorings" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified PacketMirroring resource. + rpc Delete(DeletePacketMirroringRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/packetMirrorings/{packet_mirroring}" + }; + option (google.api.method_signature) = "project,region,packet_mirroring"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified PacketMirroring resource. + rpc Get(GetPacketMirroringRequest) returns (PacketMirroring) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/packetMirrorings/{packet_mirroring}" + }; + option (google.api.method_signature) = "project,region,packet_mirroring"; + } + + // Creates a PacketMirroring resource in the specified project and region using the data included in the request. + rpc Insert(InsertPacketMirroringRequest) returns (Operation) { + option (google.api.http) = { + body: "packet_mirroring_resource" + post: "/compute/v1/projects/{project}/regions/{region}/packetMirrorings" + }; + option (google.api.method_signature) = "project,region,packet_mirroring_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves a list of PacketMirroring resources available to the specified project and region. + rpc List(ListPacketMirroringsRequest) returns (PacketMirroringList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/packetMirrorings" + }; + option (google.api.method_signature) = "project,region"; + } + + // Patches the specified PacketMirroring resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + rpc Patch(PatchPacketMirroringRequest) returns (Operation) { + option (google.api.http) = { + body: "packet_mirroring_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/packetMirrorings/{packet_mirroring}" + }; + option (google.api.method_signature) = "project,region,packet_mirroring,packet_mirroring_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsPacketMirroringRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/packetMirrorings/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,region,resource,test_permissions_request_resource"; + } + +} + +// The Projects API. +service Projects { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Disable this project as a shared VPC host project. + rpc DisableXpnHost(DisableXpnHostProjectRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/disableXpnHost" + }; + option (google.api.method_signature) = "project"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Disable a service resource (also known as service project) associated with this host project. + rpc DisableXpnResource(DisableXpnResourceProjectRequest) returns (Operation) { + option (google.api.http) = { + body: "projects_disable_xpn_resource_request_resource" + post: "/compute/v1/projects/{project}/disableXpnResource" + }; + option (google.api.method_signature) = "project,projects_disable_xpn_resource_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Enable this project as a shared VPC host project. + rpc EnableXpnHost(EnableXpnHostProjectRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/enableXpnHost" + }; + option (google.api.method_signature) = "project"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Enable service resource (a.k.a service project) for a host project, so that subnets in the host project can be used by instances in the service project. + rpc EnableXpnResource(EnableXpnResourceProjectRequest) returns (Operation) { + option (google.api.http) = { + body: "projects_enable_xpn_resource_request_resource" + post: "/compute/v1/projects/{project}/enableXpnResource" + }; + option (google.api.method_signature) = "project,projects_enable_xpn_resource_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified Project resource. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request. + rpc Get(GetProjectRequest) returns (Project) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}" + }; + option (google.api.method_signature) = "project"; + } + + // Gets the shared VPC host project that this project links to. May be empty if no link exists. + rpc GetXpnHost(GetXpnHostProjectRequest) returns (Project) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/getXpnHost" + }; + option (google.api.method_signature) = "project"; + } + + // Gets service resources (a.k.a service project) associated with this host project. + rpc GetXpnResources(GetXpnResourcesProjectsRequest) returns (ProjectsGetXpnResources) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/getXpnResources" + }; + option (google.api.method_signature) = "project"; + } + + // Lists all shared VPC host projects visible to the user in an organization. + rpc ListXpnHosts(ListXpnHostsProjectsRequest) returns (XpnHostList) { + option (google.api.http) = { + body: "projects_list_xpn_hosts_request_resource" + post: "/compute/v1/projects/{project}/listXpnHosts" + }; + option (google.api.method_signature) = "project,projects_list_xpn_hosts_request_resource"; + } + + // Moves a persistent disk from one zone to another. + rpc MoveDisk(MoveDiskProjectRequest) returns (Operation) { + option (google.api.http) = { + body: "disk_move_request_resource" + post: "/compute/v1/projects/{project}/moveDisk" + }; + option (google.api.method_signature) = "project,disk_move_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Moves an instance and its attached persistent disks from one zone to another. *Note*: Moving VMs or disks by using this method might cause unexpected behavior. For more information, see the [known issue](/compute/docs/troubleshooting/known-issues#moving_vms_or_disks_using_the_moveinstance_api_or_the_causes_unexpected_behavior). + rpc MoveInstance(MoveInstanceProjectRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_move_request_resource" + post: "/compute/v1/projects/{project}/moveInstance" + }; + option (google.api.method_signature) = "project,instance_move_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Sets metadata common to all instances within the specified project using the data included in the request. + rpc SetCommonInstanceMetadata(SetCommonInstanceMetadataProjectRequest) returns (Operation) { + option (google.api.http) = { + body: "metadata_resource" + post: "/compute/v1/projects/{project}/setCommonInstanceMetadata" + }; + option (google.api.method_signature) = "project,metadata_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Sets the default network tier of the project. The default network tier is used when an address/forwardingRule/instance is created without specifying the network tier field. + rpc SetDefaultNetworkTier(SetDefaultNetworkTierProjectRequest) returns (Operation) { + option (google.api.http) = { + body: "projects_set_default_network_tier_request_resource" + post: "/compute/v1/projects/{project}/setDefaultNetworkTier" + }; + option (google.api.method_signature) = "project,projects_set_default_network_tier_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Enables the usage export feature and sets the usage export bucket where reports are stored. If you provide an empty request body using this method, the usage export feature will be disabled. + rpc SetUsageExportBucket(SetUsageExportBucketProjectRequest) returns (Operation) { + option (google.api.http) = { + body: "usage_export_location_resource" + post: "/compute/v1/projects/{project}/setUsageExportBucket" + }; + option (google.api.method_signature) = "project,usage_export_location_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The PublicAdvertisedPrefixes API. +service PublicAdvertisedPrefixes { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified PublicAdvertisedPrefix + rpc Delete(DeletePublicAdvertisedPrefixeRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/publicAdvertisedPrefixes/{public_advertised_prefix}" + }; + option (google.api.method_signature) = "project,public_advertised_prefix"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified PublicAdvertisedPrefix resource. + rpc Get(GetPublicAdvertisedPrefixeRequest) returns (PublicAdvertisedPrefix) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/publicAdvertisedPrefixes/{public_advertised_prefix}" + }; + option (google.api.method_signature) = "project,public_advertised_prefix"; + } + + // Creates a PublicAdvertisedPrefix in the specified project using the parameters that are included in the request. + rpc Insert(InsertPublicAdvertisedPrefixeRequest) returns (Operation) { + option (google.api.http) = { + body: "public_advertised_prefix_resource" + post: "/compute/v1/projects/{project}/global/publicAdvertisedPrefixes" + }; + option (google.api.method_signature) = "project,public_advertised_prefix_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Lists the PublicAdvertisedPrefixes for a project. + rpc List(ListPublicAdvertisedPrefixesRequest) returns (PublicAdvertisedPrefixList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/publicAdvertisedPrefixes" + }; + option (google.api.method_signature) = "project"; + } + + // Patches the specified Router resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + rpc Patch(PatchPublicAdvertisedPrefixeRequest) returns (Operation) { + option (google.api.http) = { + body: "public_advertised_prefix_resource" + patch: "/compute/v1/projects/{project}/global/publicAdvertisedPrefixes/{public_advertised_prefix}" + }; + option (google.api.method_signature) = "project,public_advertised_prefix,public_advertised_prefix_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The PublicDelegatedPrefixes API. +service PublicDelegatedPrefixes { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists all PublicDelegatedPrefix resources owned by the specific project across all scopes. + rpc AggregatedList(AggregatedListPublicDelegatedPrefixesRequest) returns (PublicDelegatedPrefixAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/publicDelegatedPrefixes" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified PublicDelegatedPrefix in the given region. + rpc Delete(DeletePublicDelegatedPrefixeRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/publicDelegatedPrefixes/{public_delegated_prefix}" + }; + option (google.api.method_signature) = "project,region,public_delegated_prefix"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified PublicDelegatedPrefix resource in the given region. + rpc Get(GetPublicDelegatedPrefixeRequest) returns (PublicDelegatedPrefix) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/publicDelegatedPrefixes/{public_delegated_prefix}" + }; + option (google.api.method_signature) = "project,region,public_delegated_prefix"; + } + + // Creates a PublicDelegatedPrefix in the specified project in the given region using the parameters that are included in the request. + rpc Insert(InsertPublicDelegatedPrefixeRequest) returns (Operation) { + option (google.api.http) = { + body: "public_delegated_prefix_resource" + post: "/compute/v1/projects/{project}/regions/{region}/publicDelegatedPrefixes" + }; + option (google.api.method_signature) = "project,region,public_delegated_prefix_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Lists the PublicDelegatedPrefixes for a project in the given region. + rpc List(ListPublicDelegatedPrefixesRequest) returns (PublicDelegatedPrefixList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/publicDelegatedPrefixes" + }; + option (google.api.method_signature) = "project,region"; + } + + // Patches the specified PublicDelegatedPrefix resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + rpc Patch(PatchPublicDelegatedPrefixeRequest) returns (Operation) { + option (google.api.http) = { + body: "public_delegated_prefix_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/publicDelegatedPrefixes/{public_delegated_prefix}" + }; + option (google.api.method_signature) = "project,region,public_delegated_prefix,public_delegated_prefix_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The RegionAutoscalers API. +service RegionAutoscalers { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified autoscaler. + rpc Delete(DeleteRegionAutoscalerRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/autoscalers/{autoscaler}" + }; + option (google.api.method_signature) = "project,region,autoscaler"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified autoscaler. + rpc Get(GetRegionAutoscalerRequest) returns (Autoscaler) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/autoscalers/{autoscaler}" + }; + option (google.api.method_signature) = "project,region,autoscaler"; + } + + // Creates an autoscaler in the specified project using the data included in the request. + rpc Insert(InsertRegionAutoscalerRequest) returns (Operation) { + option (google.api.http) = { + body: "autoscaler_resource" + post: "/compute/v1/projects/{project}/regions/{region}/autoscalers" + }; + option (google.api.method_signature) = "project,region,autoscaler_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves a list of autoscalers contained within the specified region. + rpc List(ListRegionAutoscalersRequest) returns (RegionAutoscalerList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/autoscalers" + }; + option (google.api.method_signature) = "project,region"; + } + + // Updates an autoscaler in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + rpc Patch(PatchRegionAutoscalerRequest) returns (Operation) { + option (google.api.http) = { + body: "autoscaler_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/autoscalers" + }; + option (google.api.method_signature) = "project,region,autoscaler_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Updates an autoscaler in the specified project using the data included in the request. + rpc Update(UpdateRegionAutoscalerRequest) returns (Operation) { + option (google.api.http) = { + body: "autoscaler_resource" + put: "/compute/v1/projects/{project}/regions/{region}/autoscalers" + }; + option (google.api.method_signature) = "project,region,autoscaler_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The RegionBackendServices API. +service RegionBackendServices { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified regional BackendService resource. + rpc Delete(DeleteRegionBackendServiceRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/backendServices/{backend_service}" + }; + option (google.api.method_signature) = "project,region,backend_service"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified regional BackendService resource. + rpc Get(GetRegionBackendServiceRequest) returns (BackendService) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/backendServices/{backend_service}" + }; + option (google.api.method_signature) = "project,region,backend_service"; + } + + // Gets the most recent health check results for this regional BackendService. + rpc GetHealth(GetHealthRegionBackendServiceRequest) returns (BackendServiceGroupHealth) { + option (google.api.http) = { + body: "resource_group_reference_resource" + post: "/compute/v1/projects/{project}/regions/{region}/backendServices/{backend_service}/getHealth" + }; + option (google.api.method_signature) = "project,region,backend_service,resource_group_reference_resource"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyRegionBackendServiceRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/backendServices/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,region,resource"; + } + + // Creates a regional BackendService resource in the specified project using the data included in the request. For more information, see Backend services overview. + rpc Insert(InsertRegionBackendServiceRequest) returns (Operation) { + option (google.api.http) = { + body: "backend_service_resource" + post: "/compute/v1/projects/{project}/regions/{region}/backendServices" + }; + option (google.api.method_signature) = "project,region,backend_service_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves the list of regional BackendService resources available to the specified project in the given region. + rpc List(ListRegionBackendServicesRequest) returns (BackendServiceList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/backendServices" + }; + option (google.api.method_signature) = "project,region"; + } + + // Updates the specified regional BackendService resource with the data included in the request. For more information, see Understanding backend services This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + rpc Patch(PatchRegionBackendServiceRequest) returns (Operation) { + option (google.api.http) = { + body: "backend_service_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/backendServices/{backend_service}" + }; + option (google.api.method_signature) = "project,region,backend_service,backend_service_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyRegionBackendServiceRequest) returns (Policy) { + option (google.api.http) = { + body: "region_set_policy_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/backendServices/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,region,resource,region_set_policy_request_resource"; + } + + // Updates the specified regional BackendService resource with the data included in the request. For more information, see Backend services overview . + rpc Update(UpdateRegionBackendServiceRequest) returns (Operation) { + option (google.api.http) = { + body: "backend_service_resource" + put: "/compute/v1/projects/{project}/regions/{region}/backendServices/{backend_service}" + }; + option (google.api.method_signature) = "project,region,backend_service,backend_service_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The RegionCommitments API. +service RegionCommitments { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of commitments by region. + rpc AggregatedList(AggregatedListRegionCommitmentsRequest) returns (CommitmentAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/commitments" + }; + option (google.api.method_signature) = "project"; + } + + // Returns the specified commitment resource. + rpc Get(GetRegionCommitmentRequest) returns (Commitment) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/commitments/{commitment}" + }; + option (google.api.method_signature) = "project,region,commitment"; + } + + // Creates a commitment in the specified project using the data included in the request. + rpc Insert(InsertRegionCommitmentRequest) returns (Operation) { + option (google.api.http) = { + body: "commitment_resource" + post: "/compute/v1/projects/{project}/regions/{region}/commitments" + }; + option (google.api.method_signature) = "project,region,commitment_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves a list of commitments contained within the specified region. + rpc List(ListRegionCommitmentsRequest) returns (CommitmentList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/commitments" + }; + option (google.api.method_signature) = "project,region"; + } + + // Updates the specified commitment with the data included in the request. Update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: auto_renew. + rpc Update(UpdateRegionCommitmentRequest) returns (Operation) { + option (google.api.http) = { + body: "commitment_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/commitments/{commitment}" + }; + option (google.api.method_signature) = "project,region,commitment,commitment_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The RegionDiskTypes API. +service RegionDiskTypes { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute.readonly," + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Returns the specified regional disk type. + rpc Get(GetRegionDiskTypeRequest) returns (DiskType) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/diskTypes/{disk_type}" + }; + option (google.api.method_signature) = "project,region,disk_type"; + } + + // Retrieves a list of regional disk types available to the specified project. + rpc List(ListRegionDiskTypesRequest) returns (RegionDiskTypeList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/diskTypes" + }; + option (google.api.method_signature) = "project,region"; + } + +} + +// The RegionDisks API. +service RegionDisks { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Adds existing resource policies to a regional disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation. + rpc AddResourcePolicies(AddResourcePoliciesRegionDiskRequest) returns (Operation) { + option (google.api.http) = { + body: "region_disks_add_resource_policies_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/disks/{disk}/addResourcePolicies" + }; + option (google.api.method_signature) = "project,region,disk,region_disks_add_resource_policies_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project. + rpc CreateSnapshot(CreateSnapshotRegionDiskRequest) returns (Operation) { + option (google.api.http) = { + body: "snapshot_resource" + post: "/compute/v1/projects/{project}/regions/{region}/disks/{disk}/createSnapshot" + }; + option (google.api.method_signature) = "project,region,disk,snapshot_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Deletes the specified regional persistent disk. Deleting a regional disk removes all the replicas of its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots. + rpc Delete(DeleteRegionDiskRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/disks/{disk}" + }; + option (google.api.method_signature) = "project,region,disk"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns a specified regional persistent disk. + rpc Get(GetRegionDiskRequest) returns (Disk) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/disks/{disk}" + }; + option (google.api.method_signature) = "project,region,disk"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyRegionDiskRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/disks/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,region,resource"; + } + + // Creates a persistent regional disk in the specified project using the data included in the request. + rpc Insert(InsertRegionDiskRequest) returns (Operation) { + option (google.api.http) = { + body: "disk_resource" + post: "/compute/v1/projects/{project}/regions/{region}/disks" + }; + option (google.api.method_signature) = "project,region,disk_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves the list of persistent disks contained within the specified region. + rpc List(ListRegionDisksRequest) returns (DiskList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/disks" + }; + option (google.api.method_signature) = "project,region"; + } + + // Removes resource policies from a regional disk. + rpc RemoveResourcePolicies(RemoveResourcePoliciesRegionDiskRequest) returns (Operation) { + option (google.api.http) = { + body: "region_disks_remove_resource_policies_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/disks/{disk}/removeResourcePolicies" + }; + option (google.api.method_signature) = "project,region,disk,region_disks_remove_resource_policies_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Resizes the specified regional persistent disk. + rpc Resize(ResizeRegionDiskRequest) returns (Operation) { + option (google.api.http) = { + body: "region_disks_resize_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/disks/{disk}/resize" + }; + option (google.api.method_signature) = "project,region,disk,region_disks_resize_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyRegionDiskRequest) returns (Policy) { + option (google.api.http) = { + body: "region_set_policy_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/disks/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,region,resource,region_set_policy_request_resource"; + } + + // Sets the labels on the target regional disk. + rpc SetLabels(SetLabelsRegionDiskRequest) returns (Operation) { + option (google.api.http) = { + body: "region_set_labels_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/disks/{resource}/setLabels" + }; + option (google.api.method_signature) = "project,region,resource,region_set_labels_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsRegionDiskRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/disks/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,region,resource,test_permissions_request_resource"; + } + + // Update the specified disk with the data included in the request. Update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: user_license. + rpc Update(UpdateRegionDiskRequest) returns (Operation) { + option (google.api.http) = { + body: "disk_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/disks/{disk}" + }; + option (google.api.method_signature) = "project,region,disk,disk_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The RegionHealthCheckServices API. +service RegionHealthCheckServices { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified regional HealthCheckService. + rpc Delete(DeleteRegionHealthCheckServiceRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/healthCheckServices/{health_check_service}" + }; + option (google.api.method_signature) = "project,region,health_check_service"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified regional HealthCheckService resource. + rpc Get(GetRegionHealthCheckServiceRequest) returns (HealthCheckService) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/healthCheckServices/{health_check_service}" + }; + option (google.api.method_signature) = "project,region,health_check_service"; + } + + // Creates a regional HealthCheckService resource in the specified project and region using the data included in the request. + rpc Insert(InsertRegionHealthCheckServiceRequest) returns (Operation) { + option (google.api.http) = { + body: "health_check_service_resource" + post: "/compute/v1/projects/{project}/regions/{region}/healthCheckServices" + }; + option (google.api.method_signature) = "project,region,health_check_service_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Lists all the HealthCheckService resources that have been configured for the specified project in the given region. + rpc List(ListRegionHealthCheckServicesRequest) returns (HealthCheckServicesList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/healthCheckServices" + }; + option (google.api.method_signature) = "project,region"; + } + + // Updates the specified regional HealthCheckService resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + rpc Patch(PatchRegionHealthCheckServiceRequest) returns (Operation) { + option (google.api.http) = { + body: "health_check_service_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/healthCheckServices/{health_check_service}" + }; + option (google.api.method_signature) = "project,region,health_check_service,health_check_service_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The RegionHealthChecks API. +service RegionHealthChecks { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified HealthCheck resource. + rpc Delete(DeleteRegionHealthCheckRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/healthChecks/{health_check}" + }; + option (google.api.method_signature) = "project,region,health_check"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified HealthCheck resource. + rpc Get(GetRegionHealthCheckRequest) returns (HealthCheck) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/healthChecks/{health_check}" + }; + option (google.api.method_signature) = "project,region,health_check"; + } + + // Creates a HealthCheck resource in the specified project using the data included in the request. + rpc Insert(InsertRegionHealthCheckRequest) returns (Operation) { + option (google.api.http) = { + body: "health_check_resource" + post: "/compute/v1/projects/{project}/regions/{region}/healthChecks" + }; + option (google.api.method_signature) = "project,region,health_check_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves the list of HealthCheck resources available to the specified project. + rpc List(ListRegionHealthChecksRequest) returns (HealthCheckList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/healthChecks" + }; + option (google.api.method_signature) = "project,region"; + } + + // Updates a HealthCheck resource in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + rpc Patch(PatchRegionHealthCheckRequest) returns (Operation) { + option (google.api.http) = { + body: "health_check_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/healthChecks/{health_check}" + }; + option (google.api.method_signature) = "project,region,health_check,health_check_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Updates a HealthCheck resource in the specified project using the data included in the request. + rpc Update(UpdateRegionHealthCheckRequest) returns (Operation) { + option (google.api.http) = { + body: "health_check_resource" + put: "/compute/v1/projects/{project}/regions/{region}/healthChecks/{health_check}" + }; + option (google.api.method_signature) = "project,region,health_check,health_check_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The RegionInstanceGroupManagers API. +service RegionInstanceGroupManagers { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Flags the specified instances to be immediately removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + rpc AbandonInstances(AbandonInstancesRegionInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "region_instance_group_managers_abandon_instances_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/abandonInstances" + }; + option (google.api.method_signature) = "project,region,instance_group_manager,region_instance_group_managers_abandon_instances_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Apply updates to selected instances the managed instance group. + rpc ApplyUpdatesToInstances(ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "region_instance_group_managers_apply_updates_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/applyUpdatesToInstances" + }; + option (google.api.method_signature) = "project,region,instance_group_manager,region_instance_group_managers_apply_updates_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Creates instances with per-instance configurations in this regional managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method. + rpc CreateInstances(CreateInstancesRegionInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "region_instance_group_managers_create_instances_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/createInstances" + }; + option (google.api.method_signature) = "project,region,instance_group_manager,region_instance_group_managers_create_instances_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Deletes the specified managed instance group and all of the instances in that group. + rpc Delete(DeleteRegionInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}" + }; + option (google.api.method_signature) = "project,region,instance_group_manager"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Flags the specified instances in the managed instance group to be immediately deleted. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. The deleteInstances operation is marked DONE if the deleteInstances request is successful. The underlying actions take additional time. You must separately verify the status of the deleting action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + rpc DeleteInstances(DeleteInstancesRegionInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "region_instance_group_managers_delete_instances_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/deleteInstances" + }; + option (google.api.method_signature) = "project,region,instance_group_manager,region_instance_group_managers_delete_instances_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Deletes selected per-instance configurations for the managed instance group. + rpc DeletePerInstanceConfigs(DeletePerInstanceConfigsRegionInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "region_instance_group_manager_delete_instance_config_req_resource" + post: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/deletePerInstanceConfigs" + }; + option (google.api.method_signature) = "project,region,instance_group_manager,region_instance_group_manager_delete_instance_config_req_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns all of the details about the specified managed instance group. + rpc Get(GetRegionInstanceGroupManagerRequest) returns (InstanceGroupManager) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}" + }; + option (google.api.method_signature) = "project,region,instance_group_manager"; + } + + // Creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. A regional managed instance group can contain up to 2000 instances. + rpc Insert(InsertRegionInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_group_manager_resource" + post: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers" + }; + option (google.api.method_signature) = "project,region,instance_group_manager_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves the list of managed instance groups that are contained within the specified region. + rpc List(ListRegionInstanceGroupManagersRequest) returns (RegionInstanceGroupManagerList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers" + }; + option (google.api.method_signature) = "project,region"; + } + + // Lists all errors thrown by actions on instances for a given regional managed instance group. The filter and orderBy query parameters are not supported. + rpc ListErrors(ListErrorsRegionInstanceGroupManagersRequest) returns (RegionInstanceGroupManagersListErrorsResponse) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/listErrors" + }; + option (google.api.method_signature) = "project,region,instance_group_manager"; + } + + // Lists the instances in the managed instance group and instances that are scheduled to be created. The list includes any current actions that the group has scheduled for its instances. The orderBy query parameter is not supported. The `pageToken` query parameter is supported only in the alpha and beta API and only if the group's `listManagedInstancesResults` field is set to `PAGINATED`. + rpc ListManagedInstances(ListManagedInstancesRegionInstanceGroupManagersRequest) returns (RegionInstanceGroupManagersListInstancesResponse) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/listManagedInstances" + }; + option (google.api.method_signature) = "project,region,instance_group_manager"; + } + + // Lists all of the per-instance configurations defined for the managed instance group. The orderBy query parameter is not supported. + rpc ListPerInstanceConfigs(ListPerInstanceConfigsRegionInstanceGroupManagersRequest) returns (RegionInstanceGroupManagersListInstanceConfigsResp) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/listPerInstanceConfigs" + }; + option (google.api.method_signature) = "project,region,instance_group_manager"; + } + + // Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listmanagedinstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. If you update your group to specify a new template or instance configuration, it's possible that your intended specification for each VM in the group is different from the current state of that VM. To learn how to apply an updated configuration to the VMs in a MIG, see Updating instances in a MIG. + rpc Patch(PatchRegionInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_group_manager_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}" + }; + option (google.api.method_signature) = "project,region,instance_group_manager,instance_group_manager_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch. + rpc PatchPerInstanceConfigs(PatchPerInstanceConfigsRegionInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "region_instance_group_manager_patch_instance_config_req_resource" + post: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/patchPerInstanceConfigs" + }; + option (google.api.method_signature) = "project,region,instance_group_manager,region_instance_group_manager_patch_instance_config_req_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group's current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + rpc RecreateInstances(RecreateInstancesRegionInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "region_instance_group_managers_recreate_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/recreateInstances" + }; + option (google.api.method_signature) = "project,region,instance_group_manager,region_instance_group_managers_recreate_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Changes the intended size of the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes one or more instances. The resize operation is marked DONE if the resize request is successful. The underlying actions take additional time. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. + rpc Resize(ResizeRegionInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/resize" + }; + option (google.api.method_signature) = "project,region,instance_group_manager,size"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Sets the instance template to use when creating new instances or recreating instances in this group. Existing instances are not affected. + rpc SetInstanceTemplate(SetInstanceTemplateRegionInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "region_instance_group_managers_set_template_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/setInstanceTemplate" + }; + option (google.api.method_signature) = "project,region,instance_group_manager,region_instance_group_managers_set_template_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Modifies the target pools to which all new instances in this group are assigned. Existing instances in the group are not affected. + rpc SetTargetPools(SetTargetPoolsRegionInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "region_instance_group_managers_set_target_pools_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/setTargetPools" + }; + option (google.api.method_signature) = "project,region,instance_group_manager,region_instance_group_managers_set_target_pools_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch. + rpc UpdatePerInstanceConfigs(UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest) returns (Operation) { + option (google.api.http) = { + body: "region_instance_group_manager_update_instance_config_req_resource" + post: "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/updatePerInstanceConfigs" + }; + option (google.api.method_signature) = "project,region,instance_group_manager,region_instance_group_manager_update_instance_config_req_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The RegionInstanceGroups API. +service RegionInstanceGroups { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Returns the specified instance group resource. + rpc Get(GetRegionInstanceGroupRequest) returns (InstanceGroup) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/instanceGroups/{instance_group}" + }; + option (google.api.method_signature) = "project,region,instance_group"; + } + + // Retrieves the list of instance group resources contained within the specified region. + rpc List(ListRegionInstanceGroupsRequest) returns (RegionInstanceGroupList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/instanceGroups" + }; + option (google.api.method_signature) = "project,region"; + } + + // Lists the instances in the specified instance group and displays information about the named ports. Depending on the specified options, this method can list all instances or only the instances that are running. The orderBy query parameter is not supported. + rpc ListInstances(ListInstancesRegionInstanceGroupsRequest) returns (RegionInstanceGroupsListInstances) { + option (google.api.http) = { + body: "region_instance_groups_list_instances_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/instanceGroups/{instance_group}/listInstances" + }; + option (google.api.method_signature) = "project,region,instance_group,region_instance_groups_list_instances_request_resource"; + } + + // Sets the named ports for the specified regional instance group. + rpc SetNamedPorts(SetNamedPortsRegionInstanceGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "region_instance_groups_set_named_ports_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/instanceGroups/{instance_group}/setNamedPorts" + }; + option (google.api.method_signature) = "project,region,instance_group,region_instance_groups_set_named_ports_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The RegionInstanceTemplates API. +service RegionInstanceTemplates { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified instance template. Deleting an instance template is permanent and cannot be undone. + rpc Delete(DeleteRegionInstanceTemplateRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/instanceTemplates/{instance_template}" + }; + option (google.api.method_signature) = "project,region,instance_template"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified instance template. + rpc Get(GetRegionInstanceTemplateRequest) returns (InstanceTemplate) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/instanceTemplates/{instance_template}" + }; + option (google.api.method_signature) = "project,region,instance_template"; + } + + // Creates an instance template in the specified project and region using the global instance template whose URL is included in the request. + rpc Insert(InsertRegionInstanceTemplateRequest) returns (Operation) { + option (google.api.http) = { + body: "instance_template_resource" + post: "/compute/v1/projects/{project}/regions/{region}/instanceTemplates" + }; + option (google.api.method_signature) = "project,region,instance_template_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves a list of instance templates that are contained within the specified project and region. + rpc List(ListRegionInstanceTemplatesRequest) returns (InstanceTemplateList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/instanceTemplates" + }; + option (google.api.method_signature) = "project,region"; + } + +} + +// The RegionInstances API. +service RegionInstances { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates multiple instances in a given region. Count specifies the number of instances to create. + rpc BulkInsert(BulkInsertRegionInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "bulk_insert_instance_resource_resource" + post: "/compute/v1/projects/{project}/regions/{region}/instances/bulkInsert" + }; + option (google.api.method_signature) = "project,region,bulk_insert_instance_resource_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The RegionNetworkEndpointGroups API. +service RegionNetworkEndpointGroups { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified network endpoint group. Note that the NEG cannot be deleted if it is configured as a backend of a backend service. + rpc Delete(DeleteRegionNetworkEndpointGroupRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/networkEndpointGroups/{network_endpoint_group}" + }; + option (google.api.method_signature) = "project,region,network_endpoint_group"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified network endpoint group. + rpc Get(GetRegionNetworkEndpointGroupRequest) returns (NetworkEndpointGroup) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/networkEndpointGroups/{network_endpoint_group}" + }; + option (google.api.method_signature) = "project,region,network_endpoint_group"; + } + + // Creates a network endpoint group in the specified project using the parameters that are included in the request. + rpc Insert(InsertRegionNetworkEndpointGroupRequest) returns (Operation) { + option (google.api.http) = { + body: "network_endpoint_group_resource" + post: "/compute/v1/projects/{project}/regions/{region}/networkEndpointGroups" + }; + option (google.api.method_signature) = "project,region,network_endpoint_group_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves the list of regional network endpoint groups available to the specified project in the given region. + rpc List(ListRegionNetworkEndpointGroupsRequest) returns (NetworkEndpointGroupList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/networkEndpointGroups" + }; + option (google.api.method_signature) = "project,region"; + } + +} + +// The RegionNetworkFirewallPolicies API. +service RegionNetworkFirewallPolicies { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Inserts an association for the specified network firewall policy. + rpc AddAssociation(AddAssociationRegionNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_policy_association_resource" + post: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies/{firewall_policy}/addAssociation" + }; + option (google.api.method_signature) = "project,region,firewall_policy,firewall_policy_association_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Inserts a rule into a network firewall policy. + rpc AddRule(AddRuleRegionNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_policy_rule_resource" + post: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies/{firewall_policy}/addRule" + }; + option (google.api.method_signature) = "project,region,firewall_policy,firewall_policy_rule_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Copies rules to the specified network firewall policy. + rpc CloneRules(CloneRulesRegionNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies/{firewall_policy}/cloneRules" + }; + option (google.api.method_signature) = "project,region,firewall_policy"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Deletes the specified network firewall policy. + rpc Delete(DeleteRegionNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies/{firewall_policy}" + }; + option (google.api.method_signature) = "project,region,firewall_policy"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified network firewall policy. + rpc Get(GetRegionNetworkFirewallPolicyRequest) returns (FirewallPolicy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies/{firewall_policy}" + }; + option (google.api.method_signature) = "project,region,firewall_policy"; + } + + // Gets an association with the specified name. + rpc GetAssociation(GetAssociationRegionNetworkFirewallPolicyRequest) returns (FirewallPolicyAssociation) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies/{firewall_policy}/getAssociation" + }; + option (google.api.method_signature) = "project,region,firewall_policy"; + } + + // Returns the effective firewalls on a given network. + rpc GetEffectiveFirewalls(GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest) returns (RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies/getEffectiveFirewalls" + }; + option (google.api.method_signature) = "project,region,network"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyRegionNetworkFirewallPolicyRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,region,resource"; + } + + // Gets a rule of the specified priority. + rpc GetRule(GetRuleRegionNetworkFirewallPolicyRequest) returns (FirewallPolicyRule) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies/{firewall_policy}/getRule" + }; + option (google.api.method_signature) = "project,region,firewall_policy"; + } + + // Creates a new network firewall policy in the specified project and region. + rpc Insert(InsertRegionNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_policy_resource" + post: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies" + }; + option (google.api.method_signature) = "project,region,firewall_policy_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Lists all the network firewall policies that have been configured for the specified project in the given region. + rpc List(ListRegionNetworkFirewallPoliciesRequest) returns (FirewallPolicyList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies" + }; + option (google.api.method_signature) = "project,region"; + } + + // Patches the specified network firewall policy. + rpc Patch(PatchRegionNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_policy_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies/{firewall_policy}" + }; + option (google.api.method_signature) = "project,region,firewall_policy,firewall_policy_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Patches a rule of the specified priority. + rpc PatchRule(PatchRuleRegionNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "firewall_policy_rule_resource" + post: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies/{firewall_policy}/patchRule" + }; + option (google.api.method_signature) = "project,region,firewall_policy,firewall_policy_rule_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Removes an association for the specified network firewall policy. + rpc RemoveAssociation(RemoveAssociationRegionNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies/{firewall_policy}/removeAssociation" + }; + option (google.api.method_signature) = "project,region,firewall_policy"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Deletes a rule of the specified priority. + rpc RemoveRule(RemoveRuleRegionNetworkFirewallPolicyRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies/{firewall_policy}/removeRule" + }; + option (google.api.method_signature) = "project,region,firewall_policy"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyRegionNetworkFirewallPolicyRequest) returns (Policy) { + option (google.api.http) = { + body: "region_set_policy_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,region,resource,region_set_policy_request_resource"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsRegionNetworkFirewallPolicyRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/firewallPolicies/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,region,resource,test_permissions_request_resource"; + } + +} + +// The RegionNotificationEndpoints API. +service RegionNotificationEndpoints { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified NotificationEndpoint in the given region + rpc Delete(DeleteRegionNotificationEndpointRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/notificationEndpoints/{notification_endpoint}" + }; + option (google.api.method_signature) = "project,region,notification_endpoint"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified NotificationEndpoint resource in the given region. + rpc Get(GetRegionNotificationEndpointRequest) returns (NotificationEndpoint) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/notificationEndpoints/{notification_endpoint}" + }; + option (google.api.method_signature) = "project,region,notification_endpoint"; + } + + // Create a NotificationEndpoint in the specified project in the given region using the parameters that are included in the request. + rpc Insert(InsertRegionNotificationEndpointRequest) returns (Operation) { + option (google.api.http) = { + body: "notification_endpoint_resource" + post: "/compute/v1/projects/{project}/regions/{region}/notificationEndpoints" + }; + option (google.api.method_signature) = "project,region,notification_endpoint_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Lists the NotificationEndpoints for a project in the given region. + rpc List(ListRegionNotificationEndpointsRequest) returns (NotificationEndpointList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/notificationEndpoints" + }; + option (google.api.method_signature) = "project,region"; + } + +} + +// The RegionOperations API. +service RegionOperations { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified region-specific Operations resource. + rpc Delete(DeleteRegionOperationRequest) returns (DeleteRegionOperationResponse) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/operations/{operation}" + }; + option (google.api.method_signature) = "project,region,operation"; + } + + // Retrieves the specified region-specific Operations resource. + rpc Get(GetRegionOperationRequest) returns (Operation) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/operations/{operation}" + }; + option (google.api.method_signature) = "project,region,operation"; + option (google.cloud.operation_polling_method) = true; + } + + // Retrieves a list of Operation resources contained within the specified region. + rpc List(ListRegionOperationsRequest) returns (OperationList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/operations" + }; + option (google.api.method_signature) = "project,region"; + } + + // Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the `GET` method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. + rpc Wait(WaitRegionOperationRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/regions/{region}/operations/{operation}/wait" + }; + option (google.api.method_signature) = "project,region,operation"; + } + +} + +// The RegionSecurityPolicies API. +service RegionSecurityPolicies { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified policy. + rpc Delete(DeleteRegionSecurityPolicyRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/securityPolicies/{security_policy}" + }; + option (google.api.method_signature) = "project,region,security_policy"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // List all of the ordered rules present in a single specified policy. + rpc Get(GetRegionSecurityPolicyRequest) returns (SecurityPolicy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/securityPolicies/{security_policy}" + }; + option (google.api.method_signature) = "project,region,security_policy"; + } + + // Creates a new policy in the specified project using the data included in the request. + rpc Insert(InsertRegionSecurityPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "security_policy_resource" + post: "/compute/v1/projects/{project}/regions/{region}/securityPolicies" + }; + option (google.api.method_signature) = "project,region,security_policy_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // List all the policies that have been configured for the specified project and region. + rpc List(ListRegionSecurityPoliciesRequest) returns (SecurityPolicyList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/securityPolicies" + }; + option (google.api.method_signature) = "project,region"; + } + + // Patches the specified policy with the data included in the request. To clear fields in the rule, leave the fields empty and specify them in the updateMask. This cannot be used to be update the rules in the policy. Please use the per rule methods like addRule, patchRule, and removeRule instead. + rpc Patch(PatchRegionSecurityPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "security_policy_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/securityPolicies/{security_policy}" + }; + option (google.api.method_signature) = "project,region,security_policy,security_policy_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The RegionSslCertificates API. +service RegionSslCertificates { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified SslCertificate resource in the region. + rpc Delete(DeleteRegionSslCertificateRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/sslCertificates/{ssl_certificate}" + }; + option (google.api.method_signature) = "project,region,ssl_certificate"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified SslCertificate resource in the specified region. Get a list of available SSL certificates by making a list() request. + rpc Get(GetRegionSslCertificateRequest) returns (SslCertificate) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/sslCertificates/{ssl_certificate}" + }; + option (google.api.method_signature) = "project,region,ssl_certificate"; + } + + // Creates a SslCertificate resource in the specified project and region using the data included in the request + rpc Insert(InsertRegionSslCertificateRequest) returns (Operation) { + option (google.api.http) = { + body: "ssl_certificate_resource" + post: "/compute/v1/projects/{project}/regions/{region}/sslCertificates" + }; + option (google.api.method_signature) = "project,region,ssl_certificate_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves the list of SslCertificate resources available to the specified project in the specified region. + rpc List(ListRegionSslCertificatesRequest) returns (SslCertificateList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/sslCertificates" + }; + option (google.api.method_signature) = "project,region"; + } + +} + +// The RegionSslPolicies API. +service RegionSslPolicies { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified SSL policy. The SSL policy resource can be deleted only if it is not in use by any TargetHttpsProxy or TargetSslProxy resources. + rpc Delete(DeleteRegionSslPolicyRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/sslPolicies/{ssl_policy}" + }; + option (google.api.method_signature) = "project,region,ssl_policy"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Lists all of the ordered rules present in a single specified policy. + rpc Get(GetRegionSslPolicyRequest) returns (SslPolicy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/sslPolicies/{ssl_policy}" + }; + option (google.api.method_signature) = "project,region,ssl_policy"; + } + + // Creates a new policy in the specified project and region using the data included in the request. + rpc Insert(InsertRegionSslPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "ssl_policy_resource" + post: "/compute/v1/projects/{project}/regions/{region}/sslPolicies" + }; + option (google.api.method_signature) = "project,region,ssl_policy_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Lists all the SSL policies that have been configured for the specified project and region. + rpc List(ListRegionSslPoliciesRequest) returns (SslPoliciesList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/sslPolicies" + }; + option (google.api.method_signature) = "project,region"; + } + + // Lists all features that can be specified in the SSL policy when using custom profile. + rpc ListAvailableFeatures(ListAvailableFeaturesRegionSslPoliciesRequest) returns (SslPoliciesListAvailableFeaturesResponse) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/sslPolicies/listAvailableFeatures" + }; + option (google.api.method_signature) = "project,region"; + } + + // Patches the specified SSL policy with the data included in the request. + rpc Patch(PatchRegionSslPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "ssl_policy_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/sslPolicies/{ssl_policy}" + }; + option (google.api.method_signature) = "project,region,ssl_policy,ssl_policy_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The RegionTargetHttpProxies API. +service RegionTargetHttpProxies { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified TargetHttpProxy resource. + rpc Delete(DeleteRegionTargetHttpProxyRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/targetHttpProxies/{target_http_proxy}" + }; + option (google.api.method_signature) = "project,region,target_http_proxy"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified TargetHttpProxy resource in the specified region. + rpc Get(GetRegionTargetHttpProxyRequest) returns (TargetHttpProxy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/targetHttpProxies/{target_http_proxy}" + }; + option (google.api.method_signature) = "project,region,target_http_proxy"; + } + + // Creates a TargetHttpProxy resource in the specified project and region using the data included in the request. + rpc Insert(InsertRegionTargetHttpProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_http_proxy_resource" + post: "/compute/v1/projects/{project}/regions/{region}/targetHttpProxies" + }; + option (google.api.method_signature) = "project,region,target_http_proxy_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves the list of TargetHttpProxy resources available to the specified project in the specified region. + rpc List(ListRegionTargetHttpProxiesRequest) returns (TargetHttpProxyList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/targetHttpProxies" + }; + option (google.api.method_signature) = "project,region"; + } + + // Changes the URL map for TargetHttpProxy. + rpc SetUrlMap(SetUrlMapRegionTargetHttpProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "url_map_reference_resource" + post: "/compute/v1/projects/{project}/regions/{region}/targetHttpProxies/{target_http_proxy}/setUrlMap" + }; + option (google.api.method_signature) = "project,region,target_http_proxy,url_map_reference_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The RegionTargetHttpsProxies API. +service RegionTargetHttpsProxies { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified TargetHttpsProxy resource. + rpc Delete(DeleteRegionTargetHttpsProxyRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/targetHttpsProxies/{target_https_proxy}" + }; + option (google.api.method_signature) = "project,region,target_https_proxy"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified TargetHttpsProxy resource in the specified region. + rpc Get(GetRegionTargetHttpsProxyRequest) returns (TargetHttpsProxy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/targetHttpsProxies/{target_https_proxy}" + }; + option (google.api.method_signature) = "project,region,target_https_proxy"; + } + + // Creates a TargetHttpsProxy resource in the specified project and region using the data included in the request. + rpc Insert(InsertRegionTargetHttpsProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_https_proxy_resource" + post: "/compute/v1/projects/{project}/regions/{region}/targetHttpsProxies" + }; + option (google.api.method_signature) = "project,region,target_https_proxy_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves the list of TargetHttpsProxy resources available to the specified project in the specified region. + rpc List(ListRegionTargetHttpsProxiesRequest) returns (TargetHttpsProxyList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/targetHttpsProxies" + }; + option (google.api.method_signature) = "project,region"; + } + + // Patches the specified regional TargetHttpsProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + rpc Patch(PatchRegionTargetHttpsProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_https_proxy_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/targetHttpsProxies/{target_https_proxy}" + }; + option (google.api.method_signature) = "project,region,target_https_proxy,target_https_proxy_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Replaces SslCertificates for TargetHttpsProxy. + rpc SetSslCertificates(SetSslCertificatesRegionTargetHttpsProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "region_target_https_proxies_set_ssl_certificates_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/targetHttpsProxies/{target_https_proxy}/setSslCertificates" + }; + option (google.api.method_signature) = "project,region,target_https_proxy,region_target_https_proxies_set_ssl_certificates_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Changes the URL map for TargetHttpsProxy. + rpc SetUrlMap(SetUrlMapRegionTargetHttpsProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "url_map_reference_resource" + post: "/compute/v1/projects/{project}/regions/{region}/targetHttpsProxies/{target_https_proxy}/setUrlMap" + }; + option (google.api.method_signature) = "project,region,target_https_proxy,url_map_reference_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The RegionTargetTcpProxies API. +service RegionTargetTcpProxies { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified TargetTcpProxy resource. + rpc Delete(DeleteRegionTargetTcpProxyRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/targetTcpProxies/{target_tcp_proxy}" + }; + option (google.api.method_signature) = "project,region,target_tcp_proxy"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified TargetTcpProxy resource. + rpc Get(GetRegionTargetTcpProxyRequest) returns (TargetTcpProxy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/targetTcpProxies/{target_tcp_proxy}" + }; + option (google.api.method_signature) = "project,region,target_tcp_proxy"; + } + + // Creates a TargetTcpProxy resource in the specified project and region using the data included in the request. + rpc Insert(InsertRegionTargetTcpProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_tcp_proxy_resource" + post: "/compute/v1/projects/{project}/regions/{region}/targetTcpProxies" + }; + option (google.api.method_signature) = "project,region,target_tcp_proxy_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves a list of TargetTcpProxy resources available to the specified project in a given region. + rpc List(ListRegionTargetTcpProxiesRequest) returns (TargetTcpProxyList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/targetTcpProxies" + }; + option (google.api.method_signature) = "project,region"; + } + +} + +// The RegionUrlMaps API. +service RegionUrlMaps { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified UrlMap resource. + rpc Delete(DeleteRegionUrlMapRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/urlMaps/{url_map}" + }; + option (google.api.method_signature) = "project,region,url_map"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified UrlMap resource. + rpc Get(GetRegionUrlMapRequest) returns (UrlMap) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/urlMaps/{url_map}" + }; + option (google.api.method_signature) = "project,region,url_map"; + } + + // Creates a UrlMap resource in the specified project using the data included in the request. + rpc Insert(InsertRegionUrlMapRequest) returns (Operation) { + option (google.api.http) = { + body: "url_map_resource" + post: "/compute/v1/projects/{project}/regions/{region}/urlMaps" + }; + option (google.api.method_signature) = "project,region,url_map_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves the list of UrlMap resources available to the specified project in the specified region. + rpc List(ListRegionUrlMapsRequest) returns (UrlMapList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/urlMaps" + }; + option (google.api.method_signature) = "project,region"; + } + + // Patches the specified UrlMap resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + rpc Patch(PatchRegionUrlMapRequest) returns (Operation) { + option (google.api.http) = { + body: "url_map_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/urlMaps/{url_map}" + }; + option (google.api.method_signature) = "project,region,url_map,url_map_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Updates the specified UrlMap resource with the data included in the request. + rpc Update(UpdateRegionUrlMapRequest) returns (Operation) { + option (google.api.http) = { + body: "url_map_resource" + put: "/compute/v1/projects/{project}/regions/{region}/urlMaps/{url_map}" + }; + option (google.api.method_signature) = "project,region,url_map,url_map_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling this method does NOT create the UrlMap. + rpc Validate(ValidateRegionUrlMapRequest) returns (UrlMapsValidateResponse) { + option (google.api.http) = { + body: "region_url_maps_validate_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/urlMaps/{url_map}/validate" + }; + option (google.api.method_signature) = "project,region,url_map,region_url_maps_validate_request_resource"; + } + +} + +// The Regions API. +service Regions { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute.readonly," + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Returns the specified Region resource. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request. + rpc Get(GetRegionRequest) returns (Region) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}" + }; + option (google.api.method_signature) = "project,region"; + } + + // Retrieves the list of region resources available to the specified project. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `items.quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request. + rpc List(ListRegionsRequest) returns (RegionList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions" + }; + option (google.api.method_signature) = "project"; + } + +} + +// The Reservations API. +service Reservations { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of reservations. + rpc AggregatedList(AggregatedListReservationsRequest) returns (ReservationAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/reservations" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified reservation. + rpc Delete(DeleteReservationRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/zones/{zone}/reservations/{reservation}" + }; + option (google.api.method_signature) = "project,zone,reservation"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Retrieves information about the specified reservation. + rpc Get(GetReservationRequest) returns (Reservation) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/reservations/{reservation}" + }; + option (google.api.method_signature) = "project,zone,reservation"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyReservationRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/reservations/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,zone,resource"; + } + + // Creates a new reservation. For more information, read Reserving zonal resources. + rpc Insert(InsertReservationRequest) returns (Operation) { + option (google.api.http) = { + body: "reservation_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/reservations" + }; + option (google.api.method_signature) = "project,zone,reservation_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // A list of all the reservations that have been configured for the specified project in specified zone. + rpc List(ListReservationsRequest) returns (ReservationList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/reservations" + }; + option (google.api.method_signature) = "project,zone"; + } + + // Resizes the reservation (applicable to standalone reservations only). For more information, read Modifying reservations. + rpc Resize(ResizeReservationRequest) returns (Operation) { + option (google.api.http) = { + body: "reservations_resize_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/reservations/{reservation}/resize" + }; + option (google.api.method_signature) = "project,zone,reservation,reservations_resize_request_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyReservationRequest) returns (Policy) { + option (google.api.http) = { + body: "zone_set_policy_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/reservations/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,zone,resource,zone_set_policy_request_resource"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsReservationRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/reservations/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,zone,resource,test_permissions_request_resource"; + } + + // Update share settings of the reservation. + rpc Update(UpdateReservationRequest) returns (Operation) { + option (google.api.http) = { + body: "reservation_resource" + patch: "/compute/v1/projects/{project}/zones/{zone}/reservations/{reservation}" + }; + option (google.api.method_signature) = "project,zone,reservation,reservation_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + +} + +// The ResourcePolicies API. +service ResourcePolicies { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of resource policies. + rpc AggregatedList(AggregatedListResourcePoliciesRequest) returns (ResourcePolicyAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/resourcePolicies" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified resource policy. + rpc Delete(DeleteResourcePolicyRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/resourcePolicies/{resource_policy}" + }; + option (google.api.method_signature) = "project,region,resource_policy"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves all information of the specified resource policy. + rpc Get(GetResourcePolicyRequest) returns (ResourcePolicy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/resourcePolicies/{resource_policy}" + }; + option (google.api.method_signature) = "project,region,resource_policy"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyResourcePolicyRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/resourcePolicies/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,region,resource"; + } + + // Creates a new resource policy. + rpc Insert(InsertResourcePolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "resource_policy_resource" + post: "/compute/v1/projects/{project}/regions/{region}/resourcePolicies" + }; + option (google.api.method_signature) = "project,region,resource_policy_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // A list all the resource policies that have been configured for the specified project in specified region. + rpc List(ListResourcePoliciesRequest) returns (ResourcePolicyList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/resourcePolicies" + }; + option (google.api.method_signature) = "project,region"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyResourcePolicyRequest) returns (Policy) { + option (google.api.http) = { + body: "region_set_policy_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/resourcePolicies/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,region,resource,region_set_policy_request_resource"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsResourcePolicyRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/resourcePolicies/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,region,resource,test_permissions_request_resource"; + } + +} + +// The Routers API. +service Routers { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of routers. + rpc AggregatedList(AggregatedListRoutersRequest) returns (RouterAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/routers" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified Router resource. + rpc Delete(DeleteRouterRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/routers/{router}" + }; + option (google.api.method_signature) = "project,region,router"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified Router resource. + rpc Get(GetRouterRequest) returns (Router) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/routers/{router}" + }; + option (google.api.method_signature) = "project,region,router"; + } + + // Retrieves runtime Nat mapping information of VM endpoints. + rpc GetNatMappingInfo(GetNatMappingInfoRoutersRequest) returns (VmEndpointNatMappingsList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/routers/{router}/getNatMappingInfo" + }; + option (google.api.method_signature) = "project,region,router"; + } + + // Retrieves runtime information of the specified router. + rpc GetRouterStatus(GetRouterStatusRouterRequest) returns (RouterStatusResponse) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/routers/{router}/getRouterStatus" + }; + option (google.api.method_signature) = "project,region,router"; + } + + // Creates a Router resource in the specified project and region using the data included in the request. + rpc Insert(InsertRouterRequest) returns (Operation) { + option (google.api.http) = { + body: "router_resource" + post: "/compute/v1/projects/{project}/regions/{region}/routers" + }; + option (google.api.method_signature) = "project,region,router_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves a list of Router resources available to the specified project. + rpc List(ListRoutersRequest) returns (RouterList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/routers" + }; + option (google.api.method_signature) = "project,region"; + } + + // Patches the specified Router resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + rpc Patch(PatchRouterRequest) returns (Operation) { + option (google.api.http) = { + body: "router_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/routers/{router}" + }; + option (google.api.method_signature) = "project,region,router,router_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Preview fields auto-generated during router create and update operations. Calling this method does NOT create or update the router. + rpc Preview(PreviewRouterRequest) returns (RoutersPreviewResponse) { + option (google.api.http) = { + body: "router_resource" + post: "/compute/v1/projects/{project}/regions/{region}/routers/{router}/preview" + }; + option (google.api.method_signature) = "project,region,router,router_resource"; + } + + // Updates the specified Router resource with the data included in the request. This method conforms to PUT semantics, which requests that the state of the target resource be created or replaced with the state defined by the representation enclosed in the request message payload. + rpc Update(UpdateRouterRequest) returns (Operation) { + option (google.api.http) = { + body: "router_resource" + put: "/compute/v1/projects/{project}/regions/{region}/routers/{router}" + }; + option (google.api.method_signature) = "project,region,router,router_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The Routes API. +service Routes { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified Route resource. + rpc Delete(DeleteRouteRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/routes/{route}" + }; + option (google.api.method_signature) = "project,route"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified Route resource. + rpc Get(GetRouteRequest) returns (Route) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/routes/{route}" + }; + option (google.api.method_signature) = "project,route"; + } + + // Creates a Route resource in the specified project using the data included in the request. + rpc Insert(InsertRouteRequest) returns (Operation) { + option (google.api.http) = { + body: "route_resource" + post: "/compute/v1/projects/{project}/global/routes" + }; + option (google.api.method_signature) = "project,route_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of Route resources available to the specified project. + rpc List(ListRoutesRequest) returns (RouteList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/routes" + }; + option (google.api.method_signature) = "project"; + } + +} + +// The SecurityPolicies API. +service SecurityPolicies { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Inserts a rule into a security policy. + rpc AddRule(AddRuleSecurityPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "security_policy_rule_resource" + post: "/compute/v1/projects/{project}/global/securityPolicies/{security_policy}/addRule" + }; + option (google.api.method_signature) = "project,security_policy,security_policy_rule_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of all SecurityPolicy resources, regional and global, available to the specified project. + rpc AggregatedList(AggregatedListSecurityPoliciesRequest) returns (SecurityPoliciesAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/securityPolicies" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified policy. + rpc Delete(DeleteSecurityPolicyRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/securityPolicies/{security_policy}" + }; + option (google.api.method_signature) = "project,security_policy"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // List all of the ordered rules present in a single specified policy. + rpc Get(GetSecurityPolicyRequest) returns (SecurityPolicy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/securityPolicies/{security_policy}" + }; + option (google.api.method_signature) = "project,security_policy"; + } + + // Gets a rule at the specified priority. + rpc GetRule(GetRuleSecurityPolicyRequest) returns (SecurityPolicyRule) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/securityPolicies/{security_policy}/getRule" + }; + option (google.api.method_signature) = "project,security_policy"; + } + + // Creates a new policy in the specified project using the data included in the request. + rpc Insert(InsertSecurityPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "security_policy_resource" + post: "/compute/v1/projects/{project}/global/securityPolicies" + }; + option (google.api.method_signature) = "project,security_policy_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // List all the policies that have been configured for the specified project. + rpc List(ListSecurityPoliciesRequest) returns (SecurityPolicyList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/securityPolicies" + }; + option (google.api.method_signature) = "project"; + } + + // Gets the current list of preconfigured Web Application Firewall (WAF) expressions. + rpc ListPreconfiguredExpressionSets(ListPreconfiguredExpressionSetsSecurityPoliciesRequest) returns (SecurityPoliciesListPreconfiguredExpressionSetsResponse) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/securityPolicies/listPreconfiguredExpressionSets" + }; + option (google.api.method_signature) = "project"; + } + + // Patches the specified policy with the data included in the request. To clear fields in the rule, leave the fields empty and specify them in the updateMask. This cannot be used to be update the rules in the policy. Please use the per rule methods like addRule, patchRule, and removeRule instead. + rpc Patch(PatchSecurityPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "security_policy_resource" + patch: "/compute/v1/projects/{project}/global/securityPolicies/{security_policy}" + }; + option (google.api.method_signature) = "project,security_policy,security_policy_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Patches a rule at the specified priority. + rpc PatchRule(PatchRuleSecurityPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "security_policy_rule_resource" + post: "/compute/v1/projects/{project}/global/securityPolicies/{security_policy}/patchRule" + }; + option (google.api.method_signature) = "project,security_policy,security_policy_rule_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Deletes a rule at the specified priority. + rpc RemoveRule(RemoveRuleSecurityPolicyRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/global/securityPolicies/{security_policy}/removeRule" + }; + option (google.api.method_signature) = "project,security_policy"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Sets the labels on a security policy. To learn more about labels, read the Labeling Resources documentation. + rpc SetLabels(SetLabelsSecurityPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "global_set_labels_request_resource" + post: "/compute/v1/projects/{project}/global/securityPolicies/{resource}/setLabels" + }; + option (google.api.method_signature) = "project,resource,global_set_labels_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The ServiceAttachments API. +service ServiceAttachments { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves the list of all ServiceAttachment resources, regional and global, available to the specified project. + rpc AggregatedList(AggregatedListServiceAttachmentsRequest) returns (ServiceAttachmentAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/serviceAttachments" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified ServiceAttachment in the given scope + rpc Delete(DeleteServiceAttachmentRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/serviceAttachments/{service_attachment}" + }; + option (google.api.method_signature) = "project,region,service_attachment"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified ServiceAttachment resource in the given scope. + rpc Get(GetServiceAttachmentRequest) returns (ServiceAttachment) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/serviceAttachments/{service_attachment}" + }; + option (google.api.method_signature) = "project,region,service_attachment"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicyServiceAttachmentRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/serviceAttachments/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,region,resource"; + } + + // Creates a ServiceAttachment in the specified project in the given scope using the parameters that are included in the request. + rpc Insert(InsertServiceAttachmentRequest) returns (Operation) { + option (google.api.http) = { + body: "service_attachment_resource" + post: "/compute/v1/projects/{project}/regions/{region}/serviceAttachments" + }; + option (google.api.method_signature) = "project,region,service_attachment_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Lists the ServiceAttachments for a project in the given scope. + rpc List(ListServiceAttachmentsRequest) returns (ServiceAttachmentList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/serviceAttachments" + }; + option (google.api.method_signature) = "project,region"; + } + + // Patches the specified ServiceAttachment resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + rpc Patch(PatchServiceAttachmentRequest) returns (Operation) { + option (google.api.http) = { + body: "service_attachment_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/serviceAttachments/{service_attachment}" + }; + option (google.api.method_signature) = "project,region,service_attachment,service_attachment_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicyServiceAttachmentRequest) returns (Policy) { + option (google.api.http) = { + body: "region_set_policy_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/serviceAttachments/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,region,resource,region_set_policy_request_resource"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsServiceAttachmentRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/serviceAttachments/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,region,resource,test_permissions_request_resource"; + } + +} + +// The Snapshots API. +service Snapshots { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified Snapshot resource. Keep in mind that deleting a single snapshot might not necessarily delete all the data on that snapshot. If any data on the snapshot that is marked for deletion is needed for subsequent snapshots, the data will be moved to the next corresponding snapshot. For more information, see Deleting snapshots. + rpc Delete(DeleteSnapshotRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/snapshots/{snapshot}" + }; + option (google.api.method_signature) = "project,snapshot"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified Snapshot resource. + rpc Get(GetSnapshotRequest) returns (Snapshot) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/snapshots/{snapshot}" + }; + option (google.api.method_signature) = "project,snapshot"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicySnapshotRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/snapshots/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,resource"; + } + + // Creates a snapshot in the specified project using the data included in the request. For regular snapshot creation, consider using this method instead of disks.createSnapshot, as this method supports more features, such as creating snapshots in a project different from the source disk project. + rpc Insert(InsertSnapshotRequest) returns (Operation) { + option (google.api.http) = { + body: "snapshot_resource" + post: "/compute/v1/projects/{project}/global/snapshots" + }; + option (google.api.method_signature) = "project,snapshot_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of Snapshot resources contained within the specified project. + rpc List(ListSnapshotsRequest) returns (SnapshotList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/snapshots" + }; + option (google.api.method_signature) = "project"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicySnapshotRequest) returns (Policy) { + option (google.api.http) = { + body: "global_set_policy_request_resource" + post: "/compute/v1/projects/{project}/global/snapshots/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,resource,global_set_policy_request_resource"; + } + + // Sets the labels on a snapshot. To learn more about labels, read the Labeling Resources documentation. + rpc SetLabels(SetLabelsSnapshotRequest) returns (Operation) { + option (google.api.http) = { + body: "global_set_labels_request_resource" + post: "/compute/v1/projects/{project}/global/snapshots/{resource}/setLabels" + }; + option (google.api.method_signature) = "project,resource,global_set_labels_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsSnapshotRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/global/snapshots/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,resource,test_permissions_request_resource"; + } + +} + +// The SslCertificates API. +service SslCertificates { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves the list of all SslCertificate resources, regional and global, available to the specified project. + rpc AggregatedList(AggregatedListSslCertificatesRequest) returns (SslCertificateAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/sslCertificates" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified SslCertificate resource. + rpc Delete(DeleteSslCertificateRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/sslCertificates/{ssl_certificate}" + }; + option (google.api.method_signature) = "project,ssl_certificate"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified SslCertificate resource. + rpc Get(GetSslCertificateRequest) returns (SslCertificate) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/sslCertificates/{ssl_certificate}" + }; + option (google.api.method_signature) = "project,ssl_certificate"; + } + + // Creates a SslCertificate resource in the specified project using the data included in the request. + rpc Insert(InsertSslCertificateRequest) returns (Operation) { + option (google.api.http) = { + body: "ssl_certificate_resource" + post: "/compute/v1/projects/{project}/global/sslCertificates" + }; + option (google.api.method_signature) = "project,ssl_certificate_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of SslCertificate resources available to the specified project. + rpc List(ListSslCertificatesRequest) returns (SslCertificateList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/sslCertificates" + }; + option (google.api.method_signature) = "project"; + } + +} + +// The SslPolicies API. +service SslPolicies { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves the list of all SslPolicy resources, regional and global, available to the specified project. + rpc AggregatedList(AggregatedListSslPoliciesRequest) returns (SslPoliciesAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/sslPolicies" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified SSL policy. The SSL policy resource can be deleted only if it is not in use by any TargetHttpsProxy or TargetSslProxy resources. + rpc Delete(DeleteSslPolicyRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/sslPolicies/{ssl_policy}" + }; + option (google.api.method_signature) = "project,ssl_policy"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Lists all of the ordered rules present in a single specified policy. + rpc Get(GetSslPolicyRequest) returns (SslPolicy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/sslPolicies/{ssl_policy}" + }; + option (google.api.method_signature) = "project,ssl_policy"; + } + + // Returns the specified SSL policy resource. + rpc Insert(InsertSslPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "ssl_policy_resource" + post: "/compute/v1/projects/{project}/global/sslPolicies" + }; + option (google.api.method_signature) = "project,ssl_policy_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Lists all the SSL policies that have been configured for the specified project. + rpc List(ListSslPoliciesRequest) returns (SslPoliciesList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/sslPolicies" + }; + option (google.api.method_signature) = "project"; + } + + // Lists all features that can be specified in the SSL policy when using custom profile. + rpc ListAvailableFeatures(ListAvailableFeaturesSslPoliciesRequest) returns (SslPoliciesListAvailableFeaturesResponse) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/sslPolicies/listAvailableFeatures" + }; + option (google.api.method_signature) = "project"; + } + + // Patches the specified SSL policy with the data included in the request. + rpc Patch(PatchSslPolicyRequest) returns (Operation) { + option (google.api.http) = { + body: "ssl_policy_resource" + patch: "/compute/v1/projects/{project}/global/sslPolicies/{ssl_policy}" + }; + option (google.api.method_signature) = "project,ssl_policy,ssl_policy_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The Subnetworks API. +service Subnetworks { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of subnetworks. + rpc AggregatedList(AggregatedListSubnetworksRequest) returns (SubnetworkAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/subnetworks" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified subnetwork. + rpc Delete(DeleteSubnetworkRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/subnetworks/{subnetwork}" + }; + option (google.api.method_signature) = "project,region,subnetwork"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Expands the IP CIDR range of the subnetwork to a specified value. + rpc ExpandIpCidrRange(ExpandIpCidrRangeSubnetworkRequest) returns (Operation) { + option (google.api.http) = { + body: "subnetworks_expand_ip_cidr_range_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/subnetworks/{subnetwork}/expandIpCidrRange" + }; + option (google.api.method_signature) = "project,region,subnetwork,subnetworks_expand_ip_cidr_range_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified subnetwork. + rpc Get(GetSubnetworkRequest) returns (Subnetwork) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/subnetworks/{subnetwork}" + }; + option (google.api.method_signature) = "project,region,subnetwork"; + } + + // Gets the access control policy for a resource. May be empty if no such policy or resource exists. + rpc GetIamPolicy(GetIamPolicySubnetworkRequest) returns (Policy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/subnetworks/{resource}/getIamPolicy" + }; + option (google.api.method_signature) = "project,region,resource"; + } + + // Creates a subnetwork in the specified project using the data included in the request. + rpc Insert(InsertSubnetworkRequest) returns (Operation) { + option (google.api.http) = { + body: "subnetwork_resource" + post: "/compute/v1/projects/{project}/regions/{region}/subnetworks" + }; + option (google.api.method_signature) = "project,region,subnetwork_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves a list of subnetworks available to the specified project. + rpc List(ListSubnetworksRequest) returns (SubnetworkList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/subnetworks" + }; + option (google.api.method_signature) = "project,region"; + } + + // Retrieves an aggregated list of all usable subnetworks in the project. + rpc ListUsable(ListUsableSubnetworksRequest) returns (UsableSubnetworksAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/subnetworks/listUsable" + }; + option (google.api.method_signature) = "project"; + } + + // Patches the specified subnetwork with the data included in the request. Only certain fields can be updated with a patch request as indicated in the field descriptions. You must specify the current fingerprint of the subnetwork resource being patched. + rpc Patch(PatchSubnetworkRequest) returns (Operation) { + option (google.api.http) = { + body: "subnetwork_resource" + patch: "/compute/v1/projects/{project}/regions/{region}/subnetworks/{subnetwork}" + }; + option (google.api.method_signature) = "project,region,subnetwork,subnetwork_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Sets the access control policy on the specified resource. Replaces any existing policy. + rpc SetIamPolicy(SetIamPolicySubnetworkRequest) returns (Policy) { + option (google.api.http) = { + body: "region_set_policy_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/subnetworks/{resource}/setIamPolicy" + }; + option (google.api.method_signature) = "project,region,resource,region_set_policy_request_resource"; + } + + // Set whether VMs in this subnet can access Google services without assigning external IP addresses through Private Google Access. + rpc SetPrivateIpGoogleAccess(SetPrivateIpGoogleAccessSubnetworkRequest) returns (Operation) { + option (google.api.http) = { + body: "subnetworks_set_private_ip_google_access_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/subnetworks/{subnetwork}/setPrivateIpGoogleAccess" + }; + option (google.api.method_signature) = "project,region,subnetwork,subnetworks_set_private_ip_google_access_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsSubnetworkRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/subnetworks/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,region,resource,test_permissions_request_resource"; + } + +} + +// The TargetGrpcProxies API. +service TargetGrpcProxies { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified TargetGrpcProxy in the given scope + rpc Delete(DeleteTargetGrpcProxyRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/targetGrpcProxies/{target_grpc_proxy}" + }; + option (google.api.method_signature) = "project,target_grpc_proxy"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified TargetGrpcProxy resource in the given scope. + rpc Get(GetTargetGrpcProxyRequest) returns (TargetGrpcProxy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/targetGrpcProxies/{target_grpc_proxy}" + }; + option (google.api.method_signature) = "project,target_grpc_proxy"; + } + + // Creates a TargetGrpcProxy in the specified project in the given scope using the parameters that are included in the request. + rpc Insert(InsertTargetGrpcProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_grpc_proxy_resource" + post: "/compute/v1/projects/{project}/global/targetGrpcProxies" + }; + option (google.api.method_signature) = "project,target_grpc_proxy_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Lists the TargetGrpcProxies for a project in the given scope. + rpc List(ListTargetGrpcProxiesRequest) returns (TargetGrpcProxyList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/targetGrpcProxies" + }; + option (google.api.method_signature) = "project"; + } + + // Patches the specified TargetGrpcProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + rpc Patch(PatchTargetGrpcProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_grpc_proxy_resource" + patch: "/compute/v1/projects/{project}/global/targetGrpcProxies/{target_grpc_proxy}" + }; + option (google.api.method_signature) = "project,target_grpc_proxy,target_grpc_proxy_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The TargetHttpProxies API. +service TargetHttpProxies { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves the list of all TargetHttpProxy resources, regional and global, available to the specified project. + rpc AggregatedList(AggregatedListTargetHttpProxiesRequest) returns (TargetHttpProxyAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/targetHttpProxies" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified TargetHttpProxy resource. + rpc Delete(DeleteTargetHttpProxyRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/targetHttpProxies/{target_http_proxy}" + }; + option (google.api.method_signature) = "project,target_http_proxy"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified TargetHttpProxy resource. + rpc Get(GetTargetHttpProxyRequest) returns (TargetHttpProxy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/targetHttpProxies/{target_http_proxy}" + }; + option (google.api.method_signature) = "project,target_http_proxy"; + } + + // Creates a TargetHttpProxy resource in the specified project using the data included in the request. + rpc Insert(InsertTargetHttpProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_http_proxy_resource" + post: "/compute/v1/projects/{project}/global/targetHttpProxies" + }; + option (google.api.method_signature) = "project,target_http_proxy_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of TargetHttpProxy resources available to the specified project. + rpc List(ListTargetHttpProxiesRequest) returns (TargetHttpProxyList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/targetHttpProxies" + }; + option (google.api.method_signature) = "project"; + } + + // Patches the specified TargetHttpProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + rpc Patch(PatchTargetHttpProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_http_proxy_resource" + patch: "/compute/v1/projects/{project}/global/targetHttpProxies/{target_http_proxy}" + }; + option (google.api.method_signature) = "project,target_http_proxy,target_http_proxy_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Changes the URL map for TargetHttpProxy. + rpc SetUrlMap(SetUrlMapTargetHttpProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "url_map_reference_resource" + post: "/compute/v1/projects/{project}/targetHttpProxies/{target_http_proxy}/setUrlMap" + }; + option (google.api.method_signature) = "project,target_http_proxy,url_map_reference_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The TargetHttpsProxies API. +service TargetHttpsProxies { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves the list of all TargetHttpsProxy resources, regional and global, available to the specified project. + rpc AggregatedList(AggregatedListTargetHttpsProxiesRequest) returns (TargetHttpsProxyAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/targetHttpsProxies" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified TargetHttpsProxy resource. + rpc Delete(DeleteTargetHttpsProxyRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/targetHttpsProxies/{target_https_proxy}" + }; + option (google.api.method_signature) = "project,target_https_proxy"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified TargetHttpsProxy resource. + rpc Get(GetTargetHttpsProxyRequest) returns (TargetHttpsProxy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/targetHttpsProxies/{target_https_proxy}" + }; + option (google.api.method_signature) = "project,target_https_proxy"; + } + + // Creates a TargetHttpsProxy resource in the specified project using the data included in the request. + rpc Insert(InsertTargetHttpsProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_https_proxy_resource" + post: "/compute/v1/projects/{project}/global/targetHttpsProxies" + }; + option (google.api.method_signature) = "project,target_https_proxy_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of TargetHttpsProxy resources available to the specified project. + rpc List(ListTargetHttpsProxiesRequest) returns (TargetHttpsProxyList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/targetHttpsProxies" + }; + option (google.api.method_signature) = "project"; + } + + // Patches the specified TargetHttpsProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + rpc Patch(PatchTargetHttpsProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_https_proxy_resource" + patch: "/compute/v1/projects/{project}/global/targetHttpsProxies/{target_https_proxy}" + }; + option (google.api.method_signature) = "project,target_https_proxy,target_https_proxy_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Changes the Certificate Map for TargetHttpsProxy. + rpc SetCertificateMap(SetCertificateMapTargetHttpsProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_https_proxies_set_certificate_map_request_resource" + post: "/compute/v1/projects/{project}/global/targetHttpsProxies/{target_https_proxy}/setCertificateMap" + }; + option (google.api.method_signature) = "project,target_https_proxy,target_https_proxies_set_certificate_map_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Sets the QUIC override policy for TargetHttpsProxy. + rpc SetQuicOverride(SetQuicOverrideTargetHttpsProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_https_proxies_set_quic_override_request_resource" + post: "/compute/v1/projects/{project}/global/targetHttpsProxies/{target_https_proxy}/setQuicOverride" + }; + option (google.api.method_signature) = "project,target_https_proxy,target_https_proxies_set_quic_override_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Replaces SslCertificates for TargetHttpsProxy. + rpc SetSslCertificates(SetSslCertificatesTargetHttpsProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_https_proxies_set_ssl_certificates_request_resource" + post: "/compute/v1/projects/{project}/targetHttpsProxies/{target_https_proxy}/setSslCertificates" + }; + option (google.api.method_signature) = "project,target_https_proxy,target_https_proxies_set_ssl_certificates_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Sets the SSL policy for TargetHttpsProxy. The SSL policy specifies the server-side support for SSL features. This affects connections between clients and the HTTPS proxy load balancer. They do not affect the connection between the load balancer and the backends. + rpc SetSslPolicy(SetSslPolicyTargetHttpsProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "ssl_policy_reference_resource" + post: "/compute/v1/projects/{project}/global/targetHttpsProxies/{target_https_proxy}/setSslPolicy" + }; + option (google.api.method_signature) = "project,target_https_proxy,ssl_policy_reference_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Changes the URL map for TargetHttpsProxy. + rpc SetUrlMap(SetUrlMapTargetHttpsProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "url_map_reference_resource" + post: "/compute/v1/projects/{project}/targetHttpsProxies/{target_https_proxy}/setUrlMap" + }; + option (google.api.method_signature) = "project,target_https_proxy,url_map_reference_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The TargetInstances API. +service TargetInstances { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of target instances. + rpc AggregatedList(AggregatedListTargetInstancesRequest) returns (TargetInstanceAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/targetInstances" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified TargetInstance resource. + rpc Delete(DeleteTargetInstanceRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/zones/{zone}/targetInstances/{target_instance}" + }; + option (google.api.method_signature) = "project,zone,target_instance"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Returns the specified TargetInstance resource. + rpc Get(GetTargetInstanceRequest) returns (TargetInstance) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/targetInstances/{target_instance}" + }; + option (google.api.method_signature) = "project,zone,target_instance"; + } + + // Creates a TargetInstance resource in the specified project and zone using the data included in the request. + rpc Insert(InsertTargetInstanceRequest) returns (Operation) { + option (google.api.http) = { + body: "target_instance_resource" + post: "/compute/v1/projects/{project}/zones/{zone}/targetInstances" + }; + option (google.api.method_signature) = "project,zone,target_instance_resource"; + option (google.cloud.operation_service) = "ZoneOperations"; + } + + // Retrieves a list of TargetInstance resources available to the specified project and zone. + rpc List(ListTargetInstancesRequest) returns (TargetInstanceList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/targetInstances" + }; + option (google.api.method_signature) = "project,zone"; + } + +} + +// The TargetPools API. +service TargetPools { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Adds health check URLs to a target pool. + rpc AddHealthCheck(AddHealthCheckTargetPoolRequest) returns (Operation) { + option (google.api.http) = { + body: "target_pools_add_health_check_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/targetPools/{target_pool}/addHealthCheck" + }; + option (google.api.method_signature) = "project,region,target_pool,target_pools_add_health_check_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Adds an instance to a target pool. + rpc AddInstance(AddInstanceTargetPoolRequest) returns (Operation) { + option (google.api.http) = { + body: "target_pools_add_instance_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/targetPools/{target_pool}/addInstance" + }; + option (google.api.method_signature) = "project,region,target_pool,target_pools_add_instance_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves an aggregated list of target pools. + rpc AggregatedList(AggregatedListTargetPoolsRequest) returns (TargetPoolAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/targetPools" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified target pool. + rpc Delete(DeleteTargetPoolRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/targetPools/{target_pool}" + }; + option (google.api.method_signature) = "project,region,target_pool"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified target pool. + rpc Get(GetTargetPoolRequest) returns (TargetPool) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/targetPools/{target_pool}" + }; + option (google.api.method_signature) = "project,region,target_pool"; + } + + // Gets the most recent health check results for each IP for the instance that is referenced by the given target pool. + rpc GetHealth(GetHealthTargetPoolRequest) returns (TargetPoolInstanceHealth) { + option (google.api.http) = { + body: "instance_reference_resource" + post: "/compute/v1/projects/{project}/regions/{region}/targetPools/{target_pool}/getHealth" + }; + option (google.api.method_signature) = "project,region,target_pool,instance_reference_resource"; + } + + // Creates a target pool in the specified project and region using the data included in the request. + rpc Insert(InsertTargetPoolRequest) returns (Operation) { + option (google.api.http) = { + body: "target_pool_resource" + post: "/compute/v1/projects/{project}/regions/{region}/targetPools" + }; + option (google.api.method_signature) = "project,region,target_pool_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves a list of target pools available to the specified project and region. + rpc List(ListTargetPoolsRequest) returns (TargetPoolList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/targetPools" + }; + option (google.api.method_signature) = "project,region"; + } + + // Removes health check URL from a target pool. + rpc RemoveHealthCheck(RemoveHealthCheckTargetPoolRequest) returns (Operation) { + option (google.api.http) = { + body: "target_pools_remove_health_check_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/targetPools/{target_pool}/removeHealthCheck" + }; + option (google.api.method_signature) = "project,region,target_pool,target_pools_remove_health_check_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Removes instance URL from a target pool. + rpc RemoveInstance(RemoveInstanceTargetPoolRequest) returns (Operation) { + option (google.api.http) = { + body: "target_pools_remove_instance_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/targetPools/{target_pool}/removeInstance" + }; + option (google.api.method_signature) = "project,region,target_pool,target_pools_remove_instance_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Changes a backup target pool's configurations. + rpc SetBackup(SetBackupTargetPoolRequest) returns (Operation) { + option (google.api.http) = { + body: "target_reference_resource" + post: "/compute/v1/projects/{project}/regions/{region}/targetPools/{target_pool}/setBackup" + }; + option (google.api.method_signature) = "project,region,target_pool,target_reference_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The TargetSslProxies API. +service TargetSslProxies { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified TargetSslProxy resource. + rpc Delete(DeleteTargetSslProxyRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/targetSslProxies/{target_ssl_proxy}" + }; + option (google.api.method_signature) = "project,target_ssl_proxy"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified TargetSslProxy resource. + rpc Get(GetTargetSslProxyRequest) returns (TargetSslProxy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/targetSslProxies/{target_ssl_proxy}" + }; + option (google.api.method_signature) = "project,target_ssl_proxy"; + } + + // Creates a TargetSslProxy resource in the specified project using the data included in the request. + rpc Insert(InsertTargetSslProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_ssl_proxy_resource" + post: "/compute/v1/projects/{project}/global/targetSslProxies" + }; + option (google.api.method_signature) = "project,target_ssl_proxy_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of TargetSslProxy resources available to the specified project. + rpc List(ListTargetSslProxiesRequest) returns (TargetSslProxyList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/targetSslProxies" + }; + option (google.api.method_signature) = "project"; + } + + // Changes the BackendService for TargetSslProxy. + rpc SetBackendService(SetBackendServiceTargetSslProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_ssl_proxies_set_backend_service_request_resource" + post: "/compute/v1/projects/{project}/global/targetSslProxies/{target_ssl_proxy}/setBackendService" + }; + option (google.api.method_signature) = "project,target_ssl_proxy,target_ssl_proxies_set_backend_service_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Changes the Certificate Map for TargetSslProxy. + rpc SetCertificateMap(SetCertificateMapTargetSslProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_ssl_proxies_set_certificate_map_request_resource" + post: "/compute/v1/projects/{project}/global/targetSslProxies/{target_ssl_proxy}/setCertificateMap" + }; + option (google.api.method_signature) = "project,target_ssl_proxy,target_ssl_proxies_set_certificate_map_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Changes the ProxyHeaderType for TargetSslProxy. + rpc SetProxyHeader(SetProxyHeaderTargetSslProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_ssl_proxies_set_proxy_header_request_resource" + post: "/compute/v1/projects/{project}/global/targetSslProxies/{target_ssl_proxy}/setProxyHeader" + }; + option (google.api.method_signature) = "project,target_ssl_proxy,target_ssl_proxies_set_proxy_header_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Changes SslCertificates for TargetSslProxy. + rpc SetSslCertificates(SetSslCertificatesTargetSslProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_ssl_proxies_set_ssl_certificates_request_resource" + post: "/compute/v1/projects/{project}/global/targetSslProxies/{target_ssl_proxy}/setSslCertificates" + }; + option (google.api.method_signature) = "project,target_ssl_proxy,target_ssl_proxies_set_ssl_certificates_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Sets the SSL policy for TargetSslProxy. The SSL policy specifies the server-side support for SSL features. This affects connections between clients and the SSL proxy load balancer. They do not affect the connection between the load balancer and the backends. + rpc SetSslPolicy(SetSslPolicyTargetSslProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "ssl_policy_reference_resource" + post: "/compute/v1/projects/{project}/global/targetSslProxies/{target_ssl_proxy}/setSslPolicy" + }; + option (google.api.method_signature) = "project,target_ssl_proxy,ssl_policy_reference_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The TargetTcpProxies API. +service TargetTcpProxies { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves the list of all TargetTcpProxy resources, regional and global, available to the specified project. + rpc AggregatedList(AggregatedListTargetTcpProxiesRequest) returns (TargetTcpProxyAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/targetTcpProxies" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified TargetTcpProxy resource. + rpc Delete(DeleteTargetTcpProxyRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/targetTcpProxies/{target_tcp_proxy}" + }; + option (google.api.method_signature) = "project,target_tcp_proxy"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified TargetTcpProxy resource. + rpc Get(GetTargetTcpProxyRequest) returns (TargetTcpProxy) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/targetTcpProxies/{target_tcp_proxy}" + }; + option (google.api.method_signature) = "project,target_tcp_proxy"; + } + + // Creates a TargetTcpProxy resource in the specified project using the data included in the request. + rpc Insert(InsertTargetTcpProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_tcp_proxy_resource" + post: "/compute/v1/projects/{project}/global/targetTcpProxies" + }; + option (google.api.method_signature) = "project,target_tcp_proxy_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of TargetTcpProxy resources available to the specified project. + rpc List(ListTargetTcpProxiesRequest) returns (TargetTcpProxyList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/targetTcpProxies" + }; + option (google.api.method_signature) = "project"; + } + + // Changes the BackendService for TargetTcpProxy. + rpc SetBackendService(SetBackendServiceTargetTcpProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_tcp_proxies_set_backend_service_request_resource" + post: "/compute/v1/projects/{project}/global/targetTcpProxies/{target_tcp_proxy}/setBackendService" + }; + option (google.api.method_signature) = "project,target_tcp_proxy,target_tcp_proxies_set_backend_service_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Changes the ProxyHeaderType for TargetTcpProxy. + rpc SetProxyHeader(SetProxyHeaderTargetTcpProxyRequest) returns (Operation) { + option (google.api.http) = { + body: "target_tcp_proxies_set_proxy_header_request_resource" + post: "/compute/v1/projects/{project}/global/targetTcpProxies/{target_tcp_proxy}/setProxyHeader" + }; + option (google.api.method_signature) = "project,target_tcp_proxy,target_tcp_proxies_set_proxy_header_request_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + +} + +// The TargetVpnGateways API. +service TargetVpnGateways { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of target VPN gateways. + rpc AggregatedList(AggregatedListTargetVpnGatewaysRequest) returns (TargetVpnGatewayAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/targetVpnGateways" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified target VPN gateway. + rpc Delete(DeleteTargetVpnGatewayRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/targetVpnGateways/{target_vpn_gateway}" + }; + option (google.api.method_signature) = "project,region,target_vpn_gateway"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified target VPN gateway. + rpc Get(GetTargetVpnGatewayRequest) returns (TargetVpnGateway) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/targetVpnGateways/{target_vpn_gateway}" + }; + option (google.api.method_signature) = "project,region,target_vpn_gateway"; + } + + // Creates a target VPN gateway in the specified project and region using the data included in the request. + rpc Insert(InsertTargetVpnGatewayRequest) returns (Operation) { + option (google.api.http) = { + body: "target_vpn_gateway_resource" + post: "/compute/v1/projects/{project}/regions/{region}/targetVpnGateways" + }; + option (google.api.method_signature) = "project,region,target_vpn_gateway_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves a list of target VPN gateways available to the specified project and region. + rpc List(ListTargetVpnGatewaysRequest) returns (TargetVpnGatewayList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/targetVpnGateways" + }; + option (google.api.method_signature) = "project,region"; + } + + // Sets the labels on a TargetVpnGateway. To learn more about labels, read the Labeling Resources documentation. + rpc SetLabels(SetLabelsTargetVpnGatewayRequest) returns (Operation) { + option (google.api.http) = { + body: "region_set_labels_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/targetVpnGateways/{resource}/setLabels" + }; + option (google.api.method_signature) = "project,region,resource,region_set_labels_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The UrlMaps API. +service UrlMaps { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves the list of all UrlMap resources, regional and global, available to the specified project. + rpc AggregatedList(AggregatedListUrlMapsRequest) returns (UrlMapsAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/urlMaps" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified UrlMap resource. + rpc Delete(DeleteUrlMapRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/global/urlMaps/{url_map}" + }; + option (google.api.method_signature) = "project,url_map"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Returns the specified UrlMap resource. + rpc Get(GetUrlMapRequest) returns (UrlMap) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/urlMaps/{url_map}" + }; + option (google.api.method_signature) = "project,url_map"; + } + + // Creates a UrlMap resource in the specified project using the data included in the request. + rpc Insert(InsertUrlMapRequest) returns (Operation) { + option (google.api.http) = { + body: "url_map_resource" + post: "/compute/v1/projects/{project}/global/urlMaps" + }; + option (google.api.method_signature) = "project,url_map_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Initiates a cache invalidation operation, invalidating the specified path, scoped to the specified UrlMap. For more information, see [Invalidating cached content](/cdn/docs/invalidating-cached-content). + rpc InvalidateCache(InvalidateCacheUrlMapRequest) returns (Operation) { + option (google.api.http) = { + body: "cache_invalidation_rule_resource" + post: "/compute/v1/projects/{project}/global/urlMaps/{url_map}/invalidateCache" + }; + option (google.api.method_signature) = "project,url_map,cache_invalidation_rule_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Retrieves the list of UrlMap resources available to the specified project. + rpc List(ListUrlMapsRequest) returns (UrlMapList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/global/urlMaps" + }; + option (google.api.method_signature) = "project"; + } + + // Patches the specified UrlMap resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + rpc Patch(PatchUrlMapRequest) returns (Operation) { + option (google.api.http) = { + body: "url_map_resource" + patch: "/compute/v1/projects/{project}/global/urlMaps/{url_map}" + }; + option (google.api.method_signature) = "project,url_map,url_map_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Updates the specified UrlMap resource with the data included in the request. + rpc Update(UpdateUrlMapRequest) returns (Operation) { + option (google.api.http) = { + body: "url_map_resource" + put: "/compute/v1/projects/{project}/global/urlMaps/{url_map}" + }; + option (google.api.method_signature) = "project,url_map,url_map_resource"; + option (google.cloud.operation_service) = "GlobalOperations"; + } + + // Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling this method does NOT create the UrlMap. + rpc Validate(ValidateUrlMapRequest) returns (UrlMapsValidateResponse) { + option (google.api.http) = { + body: "url_maps_validate_request_resource" + post: "/compute/v1/projects/{project}/global/urlMaps/{url_map}/validate" + }; + option (google.api.method_signature) = "project,url_map,url_maps_validate_request_resource"; + } + +} + +// The VpnGateways API. +service VpnGateways { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of VPN gateways. + rpc AggregatedList(AggregatedListVpnGatewaysRequest) returns (VpnGatewayAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/vpnGateways" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified VPN gateway. + rpc Delete(DeleteVpnGatewayRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/vpnGateways/{vpn_gateway}" + }; + option (google.api.method_signature) = "project,region,vpn_gateway"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified VPN gateway. + rpc Get(GetVpnGatewayRequest) returns (VpnGateway) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/vpnGateways/{vpn_gateway}" + }; + option (google.api.method_signature) = "project,region,vpn_gateway"; + } + + // Returns the status for the specified VPN gateway. + rpc GetStatus(GetStatusVpnGatewayRequest) returns (VpnGatewaysGetStatusResponse) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/vpnGateways/{vpn_gateway}/getStatus" + }; + option (google.api.method_signature) = "project,region,vpn_gateway"; + } + + // Creates a VPN gateway in the specified project and region using the data included in the request. + rpc Insert(InsertVpnGatewayRequest) returns (Operation) { + option (google.api.http) = { + body: "vpn_gateway_resource" + post: "/compute/v1/projects/{project}/regions/{region}/vpnGateways" + }; + option (google.api.method_signature) = "project,region,vpn_gateway_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves a list of VPN gateways available to the specified project and region. + rpc List(ListVpnGatewaysRequest) returns (VpnGatewayList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/vpnGateways" + }; + option (google.api.method_signature) = "project,region"; + } + + // Sets the labels on a VpnGateway. To learn more about labels, read the Labeling Resources documentation. + rpc SetLabels(SetLabelsVpnGatewayRequest) returns (Operation) { + option (google.api.http) = { + body: "region_set_labels_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/vpnGateways/{resource}/setLabels" + }; + option (google.api.method_signature) = "project,region,resource,region_set_labels_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns permissions that a caller has on the specified resource. + rpc TestIamPermissions(TestIamPermissionsVpnGatewayRequest) returns (TestPermissionsResponse) { + option (google.api.http) = { + body: "test_permissions_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/vpnGateways/{resource}/testIamPermissions" + }; + option (google.api.method_signature) = "project,region,resource,test_permissions_request_resource"; + } + +} + +// The VpnTunnels API. +service VpnTunnels { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of VPN tunnels. + rpc AggregatedList(AggregatedListVpnTunnelsRequest) returns (VpnTunnelAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/vpnTunnels" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified VpnTunnel resource. + rpc Delete(DeleteVpnTunnelRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/vpnTunnels/{vpn_tunnel}" + }; + option (google.api.method_signature) = "project,region,vpn_tunnel"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Returns the specified VpnTunnel resource. + rpc Get(GetVpnTunnelRequest) returns (VpnTunnel) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/vpnTunnels/{vpn_tunnel}" + }; + option (google.api.method_signature) = "project,region,vpn_tunnel"; + } + + // Creates a VpnTunnel resource in the specified project and region using the data included in the request. + rpc Insert(InsertVpnTunnelRequest) returns (Operation) { + option (google.api.http) = { + body: "vpn_tunnel_resource" + post: "/compute/v1/projects/{project}/regions/{region}/vpnTunnels" + }; + option (google.api.method_signature) = "project,region,vpn_tunnel_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves a list of VpnTunnel resources contained in the specified project and region. + rpc List(ListVpnTunnelsRequest) returns (VpnTunnelList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/vpnTunnels" + }; + option (google.api.method_signature) = "project,region"; + } + + // Sets the labels on a VpnTunnel. To learn more about labels, read the Labeling Resources documentation. + rpc SetLabels(SetLabelsVpnTunnelRequest) returns (Operation) { + option (google.api.http) = { + body: "region_set_labels_request_resource" + post: "/compute/v1/projects/{project}/regions/{region}/vpnTunnels/{resource}/setLabels" + }; + option (google.api.method_signature) = "project,region,resource,region_set_labels_request_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + +} + +// The ZoneOperations API. +service ZoneOperations { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Deletes the specified zone-specific Operations resource. + rpc Delete(DeleteZoneOperationRequest) returns (DeleteZoneOperationResponse) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/zones/{zone}/operations/{operation}" + }; + option (google.api.method_signature) = "project,zone,operation"; + } + + // Retrieves the specified zone-specific Operations resource. + rpc Get(GetZoneOperationRequest) returns (Operation) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/operations/{operation}" + }; + option (google.api.method_signature) = "project,zone,operation"; + option (google.cloud.operation_polling_method) = true; + } + + // Retrieves a list of Operation resources contained within the specified zone. + rpc List(ListZoneOperationsRequest) returns (OperationList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}/operations" + }; + option (google.api.method_signature) = "project,zone"; + } + + // Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method waits for no more than the 2 minutes and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. + rpc Wait(WaitZoneOperationRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/{project}/zones/{zone}/operations/{operation}/wait" + }; + option (google.api.method_signature) = "project,zone,operation"; + } + +} + +// The Zones API. +service Zones { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute.readonly," + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Returns the specified Zone resource. + rpc Get(GetZoneRequest) returns (Zone) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones/{zone}" + }; + option (google.api.method_signature) = "project,zone"; + } + + // Retrieves the list of Zone resources available to the specified project. + rpc List(ListZonesRequest) returns (ZoneList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/zones" + }; + option (google.api.method_signature) = "project"; + } + +} + diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/accelerator_types.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/accelerator_types.aggregated_list.js new file mode 100644 index 00000000000..01280cc37ee --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/accelerator_types.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_AcceleratorTypes_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {AcceleratorTypesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new AcceleratorTypesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_AcceleratorTypes_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/accelerator_types.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/accelerator_types.get.js new file mode 100644 index 00000000000..73fe0b6f07d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/accelerator_types.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(acceleratorType, project, zone) { + // [START compute_v1_generated_AcceleratorTypes_Get_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. + */ + /** + * Name of the accelerator type to return. + */ + // const acceleratorType = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {AcceleratorTypesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new AcceleratorTypesClient(); + + async function callGet() { + // Construct request + const request = { + acceleratorType, + project, + zone, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_AcceleratorTypes_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/accelerator_types.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/accelerator_types.list.js new file mode 100644 index 00000000000..20c54275089 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/accelerator_types.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, zone) { + // [START compute_v1_generated_AcceleratorTypes_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {AcceleratorTypesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new AcceleratorTypesClient(); + + async function callList() { + // Construct request + const request = { + project, + zone, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_AcceleratorTypes_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.aggregated_list.js new file mode 100644 index 00000000000..c73c9e79333 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Addresses_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {AddressesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new AddressesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_Addresses_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.delete.js new file mode 100644 index 00000000000..0869b66a8bb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(address, project, region) { + // [START compute_v1_generated_Addresses_Delete_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. + */ + /** + * Name of the address resource to delete. + */ + // const address = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {AddressesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new AddressesClient(); + + async function callDelete() { + // Construct request + const request = { + address, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_Addresses_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.get.js new file mode 100644 index 00000000000..b1669f8bae1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(address, project, region) { + // [START compute_v1_generated_Addresses_Get_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. + */ + /** + * Name of the address resource to return. + */ + // const address = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {AddressesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new AddressesClient(); + + async function callGet() { + // Construct request + const request = { + address, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Addresses_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.insert.js new file mode 100644 index 00000000000..c97677a130f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(addressResource, project, region) { + // [START compute_v1_generated_Addresses_Insert_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. + */ + /** + * The body resource for this request + */ + // const addressResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {AddressesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new AddressesClient(); + + async function callInsert() { + // Construct request + const request = { + addressResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_Addresses_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.list.js new file mode 100644 index 00000000000..08f4e3f3ad1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_Addresses_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {AddressesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new AddressesClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_Addresses_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.set_labels.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.set_labels.js new file mode 100644 index 00000000000..f51c957a17b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/addresses.set_labels.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, regionSetLabelsRequestResource, resource) { + // [START compute_v1_generated_Addresses_SetLabels_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionSetLabelsRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {AddressesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new AddressesClient(); + + async function callSetLabels() { + // Construct request + const request = { + project, + region, + regionSetLabelsRequestResource, + resource, + }; + + // Run request + const response = await computeClient.setLabels(request); + console.log(response); + } + + callSetLabels(); + // [END compute_v1_generated_Addresses_SetLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.aggregated_list.js new file mode 100644 index 00000000000..2e96d54fb99 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Autoscalers_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {AutoscalersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new AutoscalersClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_Autoscalers_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.delete.js new file mode 100644 index 00000000000..b4ce06c4ce0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(autoscaler, project, zone) { + // [START compute_v1_generated_Autoscalers_Delete_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. + */ + /** + * Name of the autoscaler to delete. + */ + // const autoscaler = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {AutoscalersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new AutoscalersClient(); + + async function callDelete() { + // Construct request + const request = { + autoscaler, + project, + zone, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_Autoscalers_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.get.js new file mode 100644 index 00000000000..0cc6e2852e0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(autoscaler, project, zone) { + // [START compute_v1_generated_Autoscalers_Get_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. + */ + /** + * Name of the autoscaler to return. + */ + // const autoscaler = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {AutoscalersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new AutoscalersClient(); + + async function callGet() { + // Construct request + const request = { + autoscaler, + project, + zone, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Autoscalers_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.insert.js new file mode 100644 index 00000000000..5a32a942127 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(autoscalerResource, project, zone) { + // [START compute_v1_generated_Autoscalers_Insert_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. + */ + /** + * The body resource for this request + */ + // const autoscalerResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {AutoscalersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new AutoscalersClient(); + + async function callInsert() { + // Construct request + const request = { + autoscalerResource, + project, + zone, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_Autoscalers_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.list.js new file mode 100644 index 00000000000..9ac775e67c0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, zone) { + // [START compute_v1_generated_Autoscalers_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * Name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {AutoscalersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new AutoscalersClient(); + + async function callList() { + // Construct request + const request = { + project, + zone, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_Autoscalers_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.patch.js new file mode 100644 index 00000000000..f8947d5cd1c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.patch.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(autoscalerResource, project, zone) { + // [START compute_v1_generated_Autoscalers_Patch_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. + */ + /** + * Name of the autoscaler to patch. + */ + // const autoscaler = 'abc123' + /** + * The body resource for this request + */ + // const autoscalerResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {AutoscalersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new AutoscalersClient(); + + async function callPatch() { + // Construct request + const request = { + autoscalerResource, + project, + zone, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_Autoscalers_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.update.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.update.js new file mode 100644 index 00000000000..188a66387ab --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/autoscalers.update.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(autoscalerResource, project, zone) { + // [START compute_v1_generated_Autoscalers_Update_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. + */ + /** + * Name of the autoscaler to update. + */ + // const autoscaler = 'abc123' + /** + * The body resource for this request + */ + // const autoscalerResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {AutoscalersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new AutoscalersClient(); + + async function callUpdate() { + // Construct request + const request = { + autoscalerResource, + project, + zone, + }; + + // Run request + const response = await computeClient.update(request); + console.log(response); + } + + callUpdate(); + // [END compute_v1_generated_Autoscalers_Update_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.add_signed_url_key.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.add_signed_url_key.js new file mode 100644 index 00000000000..e165d7c6ed3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.add_signed_url_key.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(backendBucket, project, signedUrlKeyResource) { + // [START compute_v1_generated_BackendBuckets_AddSignedUrlKey_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. + */ + /** + * Name of the BackendBucket resource to which the Signed URL Key should be added. The name should conform to RFC1035. + */ + // const backendBucket = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const signedUrlKeyResource = {} + + // Imports the Compute library + const {BackendBucketsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendBucketsClient(); + + async function callAddSignedUrlKey() { + // Construct request + const request = { + backendBucket, + project, + signedUrlKeyResource, + }; + + // Run request + const response = await computeClient.addSignedUrlKey(request); + console.log(response); + } + + callAddSignedUrlKey(); + // [END compute_v1_generated_BackendBuckets_AddSignedUrlKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.delete.js new file mode 100644 index 00000000000..12739e98e55 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(backendBucket, project) { + // [START compute_v1_generated_BackendBuckets_Delete_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. + */ + /** + * Name of the BackendBucket resource to delete. + */ + // const backendBucket = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {BackendBucketsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendBucketsClient(); + + async function callDelete() { + // Construct request + const request = { + backendBucket, + project, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_BackendBuckets_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.delete_signed_url_key.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.delete_signed_url_key.js new file mode 100644 index 00000000000..f7366948e2b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.delete_signed_url_key.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(backendBucket, keyName, project) { + // [START compute_v1_generated_BackendBuckets_DeleteSignedUrlKey_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. + */ + /** + * Name of the BackendBucket resource to which the Signed URL Key should be added. The name should conform to RFC1035. + */ + // const backendBucket = 'abc123' + /** + * The name of the Signed URL Key to delete. + */ + // const keyName = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {BackendBucketsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendBucketsClient(); + + async function callDeleteSignedUrlKey() { + // Construct request + const request = { + backendBucket, + keyName, + project, + }; + + // Run request + const response = await computeClient.deleteSignedUrlKey(request); + console.log(response); + } + + callDeleteSignedUrlKey(); + // [END compute_v1_generated_BackendBuckets_DeleteSignedUrlKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.get.js new file mode 100644 index 00000000000..7ae9bc04d05 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(backendBucket, project) { + // [START compute_v1_generated_BackendBuckets_Get_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. + */ + /** + * Name of the BackendBucket resource to return. + */ + // const backendBucket = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {BackendBucketsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendBucketsClient(); + + async function callGet() { + // Construct request + const request = { + backendBucket, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_BackendBuckets_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.insert.js new file mode 100644 index 00000000000..f6e11a4ed6c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(backendBucketResource, project) { + // [START compute_v1_generated_BackendBuckets_Insert_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. + */ + /** + * The body resource for this request + */ + // const backendBucketResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {BackendBucketsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendBucketsClient(); + + async function callInsert() { + // Construct request + const request = { + backendBucketResource, + project, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_BackendBuckets_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.list.js new file mode 100644 index 00000000000..658b583122c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_BackendBuckets_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {BackendBucketsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendBucketsClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_BackendBuckets_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.patch.js new file mode 100644 index 00000000000..48c0a5cb4b7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(backendBucket, backendBucketResource, project) { + // [START compute_v1_generated_BackendBuckets_Patch_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. + */ + /** + * Name of the BackendBucket resource to patch. + */ + // const backendBucket = 'abc123' + /** + * The body resource for this request + */ + // const backendBucketResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {BackendBucketsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendBucketsClient(); + + async function callPatch() { + // Construct request + const request = { + backendBucket, + backendBucketResource, + project, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_BackendBuckets_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.set_edge_security_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.set_edge_security_policy.js new file mode 100644 index 00000000000..dbe35aeb75f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.set_edge_security_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(backendBucket, project, securityPolicyReferenceResource) { + // [START compute_v1_generated_BackendBuckets_SetEdgeSecurityPolicy_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. + */ + /** + * Name of the BackendService resource to which the security policy should be set. The name should conform to RFC1035. + */ + // const backendBucket = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const securityPolicyReferenceResource = {} + + // Imports the Compute library + const {BackendBucketsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendBucketsClient(); + + async function callSetEdgeSecurityPolicy() { + // Construct request + const request = { + backendBucket, + project, + securityPolicyReferenceResource, + }; + + // Run request + const response = await computeClient.setEdgeSecurityPolicy(request); + console.log(response); + } + + callSetEdgeSecurityPolicy(); + // [END compute_v1_generated_BackendBuckets_SetEdgeSecurityPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.update.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.update.js new file mode 100644 index 00000000000..4fa149caee0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_buckets.update.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(backendBucket, backendBucketResource, project) { + // [START compute_v1_generated_BackendBuckets_Update_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. + */ + /** + * Name of the BackendBucket resource to update. + */ + // const backendBucket = 'abc123' + /** + * The body resource for this request + */ + // const backendBucketResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {BackendBucketsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendBucketsClient(); + + async function callUpdate() { + // Construct request + const request = { + backendBucket, + backendBucketResource, + project, + }; + + // Run request + const response = await computeClient.update(request); + console.log(response); + } + + callUpdate(); + // [END compute_v1_generated_BackendBuckets_Update_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.add_signed_url_key.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.add_signed_url_key.js new file mode 100644 index 00000000000..e9496847d44 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.add_signed_url_key.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(backendService, project, signedUrlKeyResource) { + // [START compute_v1_generated_BackendServices_AddSignedUrlKey_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. + */ + /** + * Name of the BackendService resource to which the Signed URL Key should be added. The name should conform to RFC1035. + */ + // const backendService = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const signedUrlKeyResource = {} + + // Imports the Compute library + const {BackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendServicesClient(); + + async function callAddSignedUrlKey() { + // Construct request + const request = { + backendService, + project, + signedUrlKeyResource, + }; + + // Run request + const response = await computeClient.addSignedUrlKey(request); + console.log(response); + } + + callAddSignedUrlKey(); + // [END compute_v1_generated_BackendServices_AddSignedUrlKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.aggregated_list.js new file mode 100644 index 00000000000..6667c8277f5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_BackendServices_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Name of the project scoping this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {BackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendServicesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_BackendServices_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.delete.js new file mode 100644 index 00000000000..0831af90036 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(backendService, project) { + // [START compute_v1_generated_BackendServices_Delete_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. + */ + /** + * Name of the BackendService resource to delete. + */ + // const backendService = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {BackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendServicesClient(); + + async function callDelete() { + // Construct request + const request = { + backendService, + project, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_BackendServices_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.delete_signed_url_key.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.delete_signed_url_key.js new file mode 100644 index 00000000000..4d7e1c1a55e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.delete_signed_url_key.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(backendService, keyName, project) { + // [START compute_v1_generated_BackendServices_DeleteSignedUrlKey_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. + */ + /** + * Name of the BackendService resource to which the Signed URL Key should be added. The name should conform to RFC1035. + */ + // const backendService = 'abc123' + /** + * The name of the Signed URL Key to delete. + */ + // const keyName = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {BackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendServicesClient(); + + async function callDeleteSignedUrlKey() { + // Construct request + const request = { + backendService, + keyName, + project, + }; + + // Run request + const response = await computeClient.deleteSignedUrlKey(request); + console.log(response); + } + + callDeleteSignedUrlKey(); + // [END compute_v1_generated_BackendServices_DeleteSignedUrlKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.get.js new file mode 100644 index 00000000000..0b20d8c1402 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(backendService, project) { + // [START compute_v1_generated_BackendServices_Get_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. + */ + /** + * Name of the BackendService resource to return. + */ + // const backendService = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {BackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendServicesClient(); + + async function callGet() { + // Construct request + const request = { + backendService, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_BackendServices_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.get_health.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.get_health.js new file mode 100644 index 00000000000..68e90dd36e6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.get_health.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(backendService, project, resourceGroupReferenceResource) { + // [START compute_v1_generated_BackendServices_GetHealth_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. + */ + /** + * Name of the BackendService resource to which the queried instance belongs. + */ + // const backendService = 'abc123' + /** + */ + // const project = 'my-project' + /** + * The body resource for this request + */ + // const resourceGroupReferenceResource = {} + + // Imports the Compute library + const {BackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendServicesClient(); + + async function callGetHealth() { + // Construct request + const request = { + backendService, + project, + resourceGroupReferenceResource, + }; + + // Run request + const response = await computeClient.getHealth(request); + console.log(response); + } + + callGetHealth(); + // [END compute_v1_generated_BackendServices_GetHealth_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.get_iam_policy.js new file mode 100644 index 00000000000..da5a119e880 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.get_iam_policy.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, resource) { + // [START compute_v1_generated_BackendServices_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {BackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendServicesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + resource, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_BackendServices_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.insert.js new file mode 100644 index 00000000000..2ffbd6a14c7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(backendServiceResource, project) { + // [START compute_v1_generated_BackendServices_Insert_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. + */ + /** + * The body resource for this request + */ + // const backendServiceResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {BackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendServicesClient(); + + async function callInsert() { + // Construct request + const request = { + backendServiceResource, + project, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_BackendServices_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.list.js new file mode 100644 index 00000000000..f6a3f110ca9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_BackendServices_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {BackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendServicesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_BackendServices_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.patch.js new file mode 100644 index 00000000000..588226e94b1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(backendService, backendServiceResource, project) { + // [START compute_v1_generated_BackendServices_Patch_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. + */ + /** + * Name of the BackendService resource to patch. + */ + // const backendService = 'abc123' + /** + * The body resource for this request + */ + // const backendServiceResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {BackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendServicesClient(); + + async function callPatch() { + // Construct request + const request = { + backendService, + backendServiceResource, + project, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_BackendServices_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.set_edge_security_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.set_edge_security_policy.js new file mode 100644 index 00000000000..99f54dfe37b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.set_edge_security_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(backendService, project, securityPolicyReferenceResource) { + // [START compute_v1_generated_BackendServices_SetEdgeSecurityPolicy_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. + */ + /** + * Name of the BackendService resource to which the edge security policy should be set. The name should conform to RFC1035. + */ + // const backendService = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const securityPolicyReferenceResource = {} + + // Imports the Compute library + const {BackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendServicesClient(); + + async function callSetEdgeSecurityPolicy() { + // Construct request + const request = { + backendService, + project, + securityPolicyReferenceResource, + }; + + // Run request + const response = await computeClient.setEdgeSecurityPolicy(request); + console.log(response); + } + + callSetEdgeSecurityPolicy(); + // [END compute_v1_generated_BackendServices_SetEdgeSecurityPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.set_iam_policy.js new file mode 100644 index 00000000000..ddc30a2713d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.set_iam_policy.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(globalSetPolicyRequestResource, project, resource) { + // [START compute_v1_generated_BackendServices_SetIamPolicy_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. + */ + /** + * The body resource for this request + */ + // const globalSetPolicyRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {BackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendServicesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + globalSetPolicyRequestResource, + project, + resource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_BackendServices_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.set_security_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.set_security_policy.js new file mode 100644 index 00000000000..29ff9b5e5ee --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.set_security_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(backendService, project, securityPolicyReferenceResource) { + // [START compute_v1_generated_BackendServices_SetSecurityPolicy_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. + */ + /** + * Name of the BackendService resource to which the security policy should be set. The name should conform to RFC1035. + */ + // const backendService = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const securityPolicyReferenceResource = {} + + // Imports the Compute library + const {BackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendServicesClient(); + + async function callSetSecurityPolicy() { + // Construct request + const request = { + backendService, + project, + securityPolicyReferenceResource, + }; + + // Run request + const response = await computeClient.setSecurityPolicy(request); + console.log(response); + } + + callSetSecurityPolicy(); + // [END compute_v1_generated_BackendServices_SetSecurityPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.update.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.update.js new file mode 100644 index 00000000000..dfe91e06b15 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/backend_services.update.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(backendService, backendServiceResource, project) { + // [START compute_v1_generated_BackendServices_Update_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. + */ + /** + * Name of the BackendService resource to update. + */ + // const backendService = 'abc123' + /** + * The body resource for this request + */ + // const backendServiceResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {BackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new BackendServicesClient(); + + async function callUpdate() { + // Construct request + const request = { + backendService, + backendServiceResource, + project, + }; + + // Run request + const response = await computeClient.update(request); + console.log(response); + } + + callUpdate(); + // [END compute_v1_generated_BackendServices_Update_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disk_types.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disk_types.aggregated_list.js new file mode 100644 index 00000000000..c791d2e7876 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disk_types.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_DiskTypes_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {DiskTypesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DiskTypesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_DiskTypes_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disk_types.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disk_types.get.js new file mode 100644 index 00000000000..67ae8fb1c93 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disk_types.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(diskType, project, zone) { + // [START compute_v1_generated_DiskTypes_Get_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. + */ + /** + * Name of the disk type to return. + */ + // const diskType = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {DiskTypesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DiskTypesClient(); + + async function callGet() { + // Construct request + const request = { + diskType, + project, + zone, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_DiskTypes_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disk_types.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disk_types.list.js new file mode 100644 index 00000000000..3d0b63c9ace --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disk_types.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, zone) { + // [START compute_v1_generated_DiskTypes_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {DiskTypesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DiskTypesClient(); + + async function callList() { + // Construct request + const request = { + project, + zone, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_DiskTypes_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.add_resource_policies.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.add_resource_policies.js new file mode 100644 index 00000000000..fb6b14606ab --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.add_resource_policies.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(disk, disksAddResourcePoliciesRequestResource, project, zone) { + // [START compute_v1_generated_Disks_AddResourcePolicies_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. + */ + /** + * The disk name for this request. + */ + // const disk = 'abc123' + /** + * The body resource for this request + */ + // const disksAddResourcePoliciesRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {DisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DisksClient(); + + async function callAddResourcePolicies() { + // Construct request + const request = { + disk, + disksAddResourcePoliciesRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.addResourcePolicies(request); + console.log(response); + } + + callAddResourcePolicies(); + // [END compute_v1_generated_Disks_AddResourcePolicies_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.aggregated_list.js new file mode 100644 index 00000000000..489aa978f61 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Disks_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {DisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DisksClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_Disks_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.create_snapshot.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.create_snapshot.js new file mode 100644 index 00000000000..88fa8ec8afb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.create_snapshot.js @@ -0,0 +1,84 @@ +// Copyright 2023 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(disk, project, snapshotResource, zone) { + // [START compute_v1_generated_Disks_CreateSnapshot_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. + */ + /** + * Name of the persistent disk to snapshot. + */ + // const disk = 'abc123' + /** + * Input Only Whether to attempt an application consistent snapshot by informing the OS to prepare for the snapshot process. + */ + // const guestFlush = true + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const snapshotResource = {} + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {DisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DisksClient(); + + async function callCreateSnapshot() { + // Construct request + const request = { + disk, + project, + snapshotResource, + zone, + }; + + // Run request + const response = await computeClient.createSnapshot(request); + console.log(response); + } + + callCreateSnapshot(); + // [END compute_v1_generated_Disks_CreateSnapshot_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.delete.js new file mode 100644 index 00000000000..55d229f93a3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(disk, project, zone) { + // [START compute_v1_generated_Disks_Delete_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. + */ + /** + * Name of the persistent disk to delete. + */ + // const disk = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {DisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DisksClient(); + + async function callDelete() { + // Construct request + const request = { + disk, + project, + zone, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_Disks_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.get.js new file mode 100644 index 00000000000..f13bd47ab1d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(disk, project, zone) { + // [START compute_v1_generated_Disks_Get_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. + */ + /** + * Name of the persistent disk to return. + */ + // const disk = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {DisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DisksClient(); + + async function callGet() { + // Construct request + const request = { + disk, + project, + zone, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Disks_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.get_iam_policy.js new file mode 100644 index 00000000000..82a6aa395be --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.get_iam_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, resource, zone) { + // [START compute_v1_generated_Disks_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {DisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DisksClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + resource, + zone, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_Disks_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.insert.js new file mode 100644 index 00000000000..0fba8aa2f9a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.insert.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(diskResource, project, zone) { + // [START compute_v1_generated_Disks_Insert_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. + */ + /** + * The body resource for this request + */ + // const diskResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Source image to restore onto a disk. This field is optional. + */ + // const sourceImage = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {DisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DisksClient(); + + async function callInsert() { + // Construct request + const request = { + diskResource, + project, + zone, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_Disks_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.list.js new file mode 100644 index 00000000000..be19ad4601c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, zone) { + // [START compute_v1_generated_Disks_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {DisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DisksClient(); + + async function callList() { + // Construct request + const request = { + project, + zone, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_Disks_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.remove_resource_policies.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.remove_resource_policies.js new file mode 100644 index 00000000000..87118a50597 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.remove_resource_policies.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(disk, disksRemoveResourcePoliciesRequestResource, project, zone) { + // [START compute_v1_generated_Disks_RemoveResourcePolicies_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. + */ + /** + * The disk name for this request. + */ + // const disk = 'abc123' + /** + * The body resource for this request + */ + // const disksRemoveResourcePoliciesRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {DisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DisksClient(); + + async function callRemoveResourcePolicies() { + // Construct request + const request = { + disk, + disksRemoveResourcePoliciesRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.removeResourcePolicies(request); + console.log(response); + } + + callRemoveResourcePolicies(); + // [END compute_v1_generated_Disks_RemoveResourcePolicies_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.resize.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.resize.js new file mode 100644 index 00000000000..de60ec9bb0e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.resize.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(disk, disksResizeRequestResource, project, zone) { + // [START compute_v1_generated_Disks_Resize_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. + */ + /** + * The name of the persistent disk. + */ + // const disk = 'abc123' + /** + * The body resource for this request + */ + // const disksResizeRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {DisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DisksClient(); + + async function callResize() { + // Construct request + const request = { + disk, + disksResizeRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.resize(request); + console.log(response); + } + + callResize(); + // [END compute_v1_generated_Disks_Resize_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.set_iam_policy.js new file mode 100644 index 00000000000..13d63cd837f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.set_iam_policy.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, resource, zone, zoneSetPolicyRequestResource) { + // [START compute_v1_generated_Disks_SetIamPolicy_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + /** + * The body resource for this request + */ + // const zoneSetPolicyRequestResource = {} + + // Imports the Compute library + const {DisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DisksClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + project, + resource, + zone, + zoneSetPolicyRequestResource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_Disks_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.set_labels.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.set_labels.js new file mode 100644 index 00000000000..09936dfb2b7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.set_labels.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, resource, zone, zoneSetLabelsRequestResource) { + // [START compute_v1_generated_Disks_SetLabels_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + /** + * The body resource for this request + */ + // const zoneSetLabelsRequestResource = {} + + // Imports the Compute library + const {DisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DisksClient(); + + async function callSetLabels() { + // Construct request + const request = { + project, + resource, + zone, + zoneSetLabelsRequestResource, + }; + + // Run request + const response = await computeClient.setLabels(request); + console.log(response); + } + + callSetLabels(); + // [END compute_v1_generated_Disks_SetLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.test_iam_permissions.js new file mode 100644 index 00000000000..22ed8cad11e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.test_iam_permissions.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, resource, testPermissionsRequestResource, zone) { + // [START compute_v1_generated_Disks_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {DisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DisksClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + resource, + testPermissionsRequestResource, + zone, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_Disks_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.update.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.update.js new file mode 100644 index 00000000000..6803fdc582a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/disks.update.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(disk, diskResource, project, zone) { + // [START compute_v1_generated_Disks_Update_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. + */ + /** + * The disk name for this request. + */ + // const disk = 'abc123' + /** + * The body resource for this request + */ + // const diskResource = {} + /** + */ + // const paths = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * update_mask indicates fields to be updated as part of this request. + */ + // const updateMask = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {DisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new DisksClient(); + + async function callUpdate() { + // Construct request + const request = { + disk, + diskResource, + project, + zone, + }; + + // Run request + const response = await computeClient.update(request); + console.log(response); + } + + callUpdate(); + // [END compute_v1_generated_Disks_Update_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.delete.js new file mode 100644 index 00000000000..6405216dd34 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(externalVpnGateway, project) { + // [START compute_v1_generated_ExternalVpnGateways_Delete_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. + */ + /** + * Name of the externalVpnGateways to delete. + */ + // const externalVpnGateway = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ExternalVpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ExternalVpnGatewaysClient(); + + async function callDelete() { + // Construct request + const request = { + externalVpnGateway, + project, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_ExternalVpnGateways_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.get.js new file mode 100644 index 00000000000..72179e32c53 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(externalVpnGateway, project) { + // [START compute_v1_generated_ExternalVpnGateways_Get_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. + */ + /** + * Name of the externalVpnGateway to return. + */ + // const externalVpnGateway = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {ExternalVpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ExternalVpnGatewaysClient(); + + async function callGet() { + // Construct request + const request = { + externalVpnGateway, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_ExternalVpnGateways_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.insert.js new file mode 100644 index 00000000000..9c6eb8ee358 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(externalVpnGatewayResource, project) { + // [START compute_v1_generated_ExternalVpnGateways_Insert_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. + */ + /** + * The body resource for this request + */ + // const externalVpnGatewayResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ExternalVpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ExternalVpnGatewaysClient(); + + async function callInsert() { + // Construct request + const request = { + externalVpnGatewayResource, + project, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_ExternalVpnGateways_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.list.js new file mode 100644 index 00000000000..d9b4289a2fa --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_ExternalVpnGateways_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {ExternalVpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ExternalVpnGatewaysClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_ExternalVpnGateways_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.set_labels.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.set_labels.js new file mode 100644 index 00000000000..effc8d21b17 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.set_labels.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(globalSetLabelsRequestResource, project, resource) { + // [START compute_v1_generated_ExternalVpnGateways_SetLabels_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. + */ + /** + * The body resource for this request + */ + // const globalSetLabelsRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {ExternalVpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ExternalVpnGatewaysClient(); + + async function callSetLabels() { + // Construct request + const request = { + globalSetLabelsRequestResource, + project, + resource, + }; + + // Run request + const response = await computeClient.setLabels(request); + console.log(response); + } + + callSetLabels(); + // [END compute_v1_generated_ExternalVpnGateways_SetLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.test_iam_permissions.js new file mode 100644 index 00000000000..4f1a1e6fbfb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/external_vpn_gateways.test_iam_permissions.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_ExternalVpnGateways_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {ExternalVpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ExternalVpnGatewaysClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_ExternalVpnGateways_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.add_association.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.add_association.js new file mode 100644 index 00000000000..ea7ddcd24da --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.add_association.js @@ -0,0 +1,74 @@ +// Copyright 2023 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(firewallPolicy, firewallPolicyAssociationResource) { + // [START compute_v1_generated_FirewallPolicies_AddAssociation_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * The body resource for this request + */ + // const firewallPolicyAssociationResource = {} + /** + * Indicates whether or not to replace it if an association of the attachment already exists. This is false by default, in which case an error will be returned if an association already exists. + */ + // const replaceExistingAssociation = true + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callAddAssociation() { + // Construct request + const request = { + firewallPolicy, + firewallPolicyAssociationResource, + }; + + // Run request + const response = await computeClient.addAssociation(request); + console.log(response); + } + + callAddAssociation(); + // [END compute_v1_generated_FirewallPolicies_AddAssociation_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.add_rule.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.add_rule.js new file mode 100644 index 00000000000..cb956005881 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.add_rule.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(firewallPolicy, firewallPolicyRuleResource) { + // [START compute_v1_generated_FirewallPolicies_AddRule_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * The body resource for this request + */ + // const firewallPolicyRuleResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callAddRule() { + // Construct request + const request = { + firewallPolicy, + firewallPolicyRuleResource, + }; + + // Run request + const response = await computeClient.addRule(request); + console.log(response); + } + + callAddRule(); + // [END compute_v1_generated_FirewallPolicies_AddRule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.clone_rules.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.clone_rules.js new file mode 100644 index 00000000000..0e54ea18071 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.clone_rules.js @@ -0,0 +1,69 @@ +// Copyright 2023 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(firewallPolicy) { + // [START compute_v1_generated_FirewallPolicies_CloneRules_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The firewall policy from which to copy rules. + */ + // const sourceFirewallPolicy = 'abc123' + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callCloneRules() { + // Construct request + const request = { + firewallPolicy, + }; + + // Run request + const response = await computeClient.cloneRules(request); + console.log(response); + } + + callCloneRules(); + // [END compute_v1_generated_FirewallPolicies_CloneRules_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.delete.js new file mode 100644 index 00000000000..f7633cdedc3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.delete.js @@ -0,0 +1,65 @@ +// Copyright 2023 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(firewallPolicy) { + // [START compute_v1_generated_FirewallPolicies_Delete_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. + */ + /** + * Name of the firewall policy to delete. + */ + // const firewallPolicy = 'abc123' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callDelete() { + // Construct request + const request = { + firewallPolicy, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_FirewallPolicies_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.get.js new file mode 100644 index 00000000000..dfbe39ecaaf --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.get.js @@ -0,0 +1,61 @@ +// Copyright 2023 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(firewallPolicy) { + // [START compute_v1_generated_FirewallPolicies_Get_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. + */ + /** + * Name of the firewall policy to get. + */ + // const firewallPolicy = 'abc123' + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callGet() { + // Construct request + const request = { + firewallPolicy, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_FirewallPolicies_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.get_association.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.get_association.js new file mode 100644 index 00000000000..5d49623a631 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.get_association.js @@ -0,0 +1,65 @@ +// Copyright 2023 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(firewallPolicy) { + // [START compute_v1_generated_FirewallPolicies_GetAssociation_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. + */ + /** + * Name of the firewall policy to which the queried rule belongs. + */ + // const firewallPolicy = 'abc123' + /** + * The name of the association to get from the firewall policy. + */ + // const name = 'abc123' + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callGetAssociation() { + // Construct request + const request = { + firewallPolicy, + }; + + // Run request + const response = await computeClient.getAssociation(request); + console.log(response); + } + + callGetAssociation(); + // [END compute_v1_generated_FirewallPolicies_GetAssociation_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.get_iam_policy.js new file mode 100644 index 00000000000..a4bb9be49fb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.get_iam_policy.js @@ -0,0 +1,65 @@ +// Copyright 2023 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(resource) { + // [START compute_v1_generated_FirewallPolicies_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_FirewallPolicies_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.get_rule.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.get_rule.js new file mode 100644 index 00000000000..d6b69056f84 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.get_rule.js @@ -0,0 +1,65 @@ +// Copyright 2023 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(firewallPolicy) { + // [START compute_v1_generated_FirewallPolicies_GetRule_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. + */ + /** + * Name of the firewall policy to which the queried rule belongs. + */ + // const firewallPolicy = 'abc123' + /** + * The priority of the rule to get from the firewall policy. + */ + // const priority = 1234 + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callGetRule() { + // Construct request + const request = { + firewallPolicy, + }; + + // Run request + const response = await computeClient.getRule(request); + console.log(response); + } + + callGetRule(); + // [END compute_v1_generated_FirewallPolicies_GetRule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.insert.js new file mode 100644 index 00000000000..5a055b5c129 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(firewallPolicyResource, parentId) { + // [START compute_v1_generated_FirewallPolicies_Insert_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. + */ + /** + * The body resource for this request + */ + // const firewallPolicyResource = {} + /** + * Parent ID for this request. The ID can be either be "folders/[FOLDER_ID]" if the parent is a folder or "organizations/[ORGANIZATION_ID]" if the parent is an organization. + */ + // const parentId = 'abc123' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callInsert() { + // Construct request + const request = { + firewallPolicyResource, + parentId, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_FirewallPolicies_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.list.js new file mode 100644 index 00000000000..761c937e2e5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.list.js @@ -0,0 +1,82 @@ +// Copyright 2023 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() { + // [START compute_v1_generated_FirewallPolicies_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Parent ID for this request. The ID can be either be "folders/[FOLDER_ID]" if the parent is a folder or "organizations/[ORGANIZATION_ID]" if the parent is an organization. + */ + // const parentId = 'abc123' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callList() { + // Construct request + const request = { + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_FirewallPolicies_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.list_associations.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.list_associations.js new file mode 100644 index 00000000000..e905309849d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.list_associations.js @@ -0,0 +1,60 @@ +// Copyright 2023 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() { + // [START compute_v1_generated_FirewallPolicies_ListAssociations_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. + */ + /** + * The target resource to list associations. It is an organization, or a folder. + */ + // const targetResource = 'abc123' + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callListAssociations() { + // Construct request + const request = { + }; + + // Run request + const response = await computeClient.listAssociations(request); + console.log(response); + } + + callListAssociations(); + // [END compute_v1_generated_FirewallPolicies_ListAssociations_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.move.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.move.js new file mode 100644 index 00000000000..79be3151011 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.move.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(firewallPolicy, parentId) { + // [START compute_v1_generated_FirewallPolicies_Move_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * The new parent of the firewall policy. The ID can be either be "folders/[FOLDER_ID]" if the parent is a folder or "organizations/[ORGANIZATION_ID]" if the parent is an organization. + */ + // const parentId = 'abc123' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callMove() { + // Construct request + const request = { + firewallPolicy, + parentId, + }; + + // Run request + const response = await computeClient.move(request); + console.log(response); + } + + callMove(); + // [END compute_v1_generated_FirewallPolicies_Move_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.patch.js new file mode 100644 index 00000000000..2642c718983 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.patch.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(firewallPolicy, firewallPolicyResource) { + // [START compute_v1_generated_FirewallPolicies_Patch_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * The body resource for this request + */ + // const firewallPolicyResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callPatch() { + // Construct request + const request = { + firewallPolicy, + firewallPolicyResource, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_FirewallPolicies_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.patch_rule.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.patch_rule.js new file mode 100644 index 00000000000..381dc7e3ea5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.patch_rule.js @@ -0,0 +1,74 @@ +// Copyright 2023 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(firewallPolicy, firewallPolicyRuleResource) { + // [START compute_v1_generated_FirewallPolicies_PatchRule_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * The body resource for this request + */ + // const firewallPolicyRuleResource = {} + /** + * The priority of the rule to patch. + */ + // const priority = 1234 + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callPatchRule() { + // Construct request + const request = { + firewallPolicy, + firewallPolicyRuleResource, + }; + + // Run request + const response = await computeClient.patchRule(request); + console.log(response); + } + + callPatchRule(); + // [END compute_v1_generated_FirewallPolicies_PatchRule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.remove_association.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.remove_association.js new file mode 100644 index 00000000000..4e6229daba5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.remove_association.js @@ -0,0 +1,69 @@ +// Copyright 2023 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(firewallPolicy) { + // [START compute_v1_generated_FirewallPolicies_RemoveAssociation_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * Name for the attachment that will be removed. + */ + // const name = 'abc123' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callRemoveAssociation() { + // Construct request + const request = { + firewallPolicy, + }; + + // Run request + const response = await computeClient.removeAssociation(request); + console.log(response); + } + + callRemoveAssociation(); + // [END compute_v1_generated_FirewallPolicies_RemoveAssociation_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.remove_rule.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.remove_rule.js new file mode 100644 index 00000000000..fec4626f701 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.remove_rule.js @@ -0,0 +1,69 @@ +// Copyright 2023 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(firewallPolicy) { + // [START compute_v1_generated_FirewallPolicies_RemoveRule_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * The priority of the rule to remove from the firewall policy. + */ + // const priority = 1234 + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callRemoveRule() { + // Construct request + const request = { + firewallPolicy, + }; + + // Run request + const response = await computeClient.removeRule(request); + console.log(response); + } + + callRemoveRule(); + // [END compute_v1_generated_FirewallPolicies_RemoveRule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.set_iam_policy.js new file mode 100644 index 00000000000..acd7a29ca0c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.set_iam_policy.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(globalOrganizationSetPolicyRequestResource, resource) { + // [START compute_v1_generated_FirewallPolicies_SetIamPolicy_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. + */ + /** + * The body resource for this request + */ + // const globalOrganizationSetPolicyRequestResource = {} + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + globalOrganizationSetPolicyRequestResource, + resource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_FirewallPolicies_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.test_iam_permissions.js new file mode 100644 index 00000000000..8f9fee2ad7d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewall_policies.test_iam_permissions.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(resource, testPermissionsRequestResource) { + // [START compute_v1_generated_FirewallPolicies_TestIamPermissions_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. + */ + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {FirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallPoliciesClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_FirewallPolicies_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.delete.js new file mode 100644 index 00000000000..ec3eb04127f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(firewall, project) { + // [START compute_v1_generated_Firewalls_Delete_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. + */ + /** + * Name of the firewall rule to delete. + */ + // const firewall = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {FirewallsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallsClient(); + + async function callDelete() { + // Construct request + const request = { + firewall, + project, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_Firewalls_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.get.js new file mode 100644 index 00000000000..ab865112c9c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(firewall, project) { + // [START compute_v1_generated_Firewalls_Get_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. + */ + /** + * Name of the firewall rule to return. + */ + // const firewall = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {FirewallsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallsClient(); + + async function callGet() { + // Construct request + const request = { + firewall, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Firewalls_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.insert.js new file mode 100644 index 00000000000..7e927acf6ee --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(firewallResource, project) { + // [START compute_v1_generated_Firewalls_Insert_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. + */ + /** + * The body resource for this request + */ + // const firewallResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {FirewallsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallsClient(); + + async function callInsert() { + // Construct request + const request = { + firewallResource, + project, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_Firewalls_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.list.js new file mode 100644 index 00000000000..c1a7aab66a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Firewalls_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {FirewallsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallsClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_Firewalls_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.patch.js new file mode 100644 index 00000000000..68a68b6344f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(firewall, firewallResource, project) { + // [START compute_v1_generated_Firewalls_Patch_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. + */ + /** + * Name of the firewall rule to patch. + */ + // const firewall = 'abc123' + /** + * The body resource for this request + */ + // const firewallResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {FirewallsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallsClient(); + + async function callPatch() { + // Construct request + const request = { + firewall, + firewallResource, + project, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_Firewalls_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.update.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.update.js new file mode 100644 index 00000000000..db31dd22f3d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/firewalls.update.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(firewall, firewallResource, project) { + // [START compute_v1_generated_Firewalls_Update_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. + */ + /** + * Name of the firewall rule to update. + */ + // const firewall = 'abc123' + /** + * The body resource for this request + */ + // const firewallResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {FirewallsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new FirewallsClient(); + + async function callUpdate() { + // Construct request + const request = { + firewall, + firewallResource, + project, + }; + + // Run request + const response = await computeClient.update(request); + console.log(response); + } + + callUpdate(); + // [END compute_v1_generated_Firewalls_Update_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.aggregated_list.js new file mode 100644 index 00000000000..1fb19ae7854 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_ForwardingRules_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {ForwardingRulesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ForwardingRulesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_ForwardingRules_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.delete.js new file mode 100644 index 00000000000..390d443a70f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(forwardingRule, project, region) { + // [START compute_v1_generated_ForwardingRules_Delete_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. + */ + /** + * Name of the ForwardingRule resource to delete. + */ + // const forwardingRule = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ForwardingRulesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ForwardingRulesClient(); + + async function callDelete() { + // Construct request + const request = { + forwardingRule, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_ForwardingRules_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.get.js new file mode 100644 index 00000000000..427a0bee014 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(forwardingRule, project, region) { + // [START compute_v1_generated_ForwardingRules_Get_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. + */ + /** + * Name of the ForwardingRule resource to return. + */ + // const forwardingRule = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {ForwardingRulesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ForwardingRulesClient(); + + async function callGet() { + // Construct request + const request = { + forwardingRule, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_ForwardingRules_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.insert.js new file mode 100644 index 00000000000..025234e6063 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(forwardingRuleResource, project, region) { + // [START compute_v1_generated_ForwardingRules_Insert_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. + */ + /** + * The body resource for this request + */ + // const forwardingRuleResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ForwardingRulesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ForwardingRulesClient(); + + async function callInsert() { + // Construct request + const request = { + forwardingRuleResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_ForwardingRules_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.list.js new file mode 100644 index 00000000000..a7ec2cceeea --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_ForwardingRules_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {ForwardingRulesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ForwardingRulesClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_ForwardingRules_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.patch.js new file mode 100644 index 00000000000..294f050c673 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(forwardingRule, forwardingRuleResource, project, region) { + // [START compute_v1_generated_ForwardingRules_Patch_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. + */ + /** + * Name of the ForwardingRule resource to patch. + */ + // const forwardingRule = 'abc123' + /** + * The body resource for this request + */ + // const forwardingRuleResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ForwardingRulesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ForwardingRulesClient(); + + async function callPatch() { + // Construct request + const request = { + forwardingRule, + forwardingRuleResource, + project, + region, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_ForwardingRules_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.set_labels.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.set_labels.js new file mode 100644 index 00000000000..15af701734b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.set_labels.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, regionSetLabelsRequestResource, resource) { + // [START compute_v1_generated_ForwardingRules_SetLabels_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionSetLabelsRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {ForwardingRulesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ForwardingRulesClient(); + + async function callSetLabels() { + // Construct request + const request = { + project, + region, + regionSetLabelsRequestResource, + resource, + }; + + // Run request + const response = await computeClient.setLabels(request); + console.log(response); + } + + callSetLabels(); + // [END compute_v1_generated_ForwardingRules_SetLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.set_target.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.set_target.js new file mode 100644 index 00000000000..30addea7648 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/forwarding_rules.set_target.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(forwardingRule, project, region, targetReferenceResource) { + // [START compute_v1_generated_ForwardingRules_SetTarget_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. + */ + /** + * Name of the ForwardingRule resource in which target is to be set. + */ + // const forwardingRule = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetReferenceResource = {} + + // Imports the Compute library + const {ForwardingRulesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ForwardingRulesClient(); + + async function callSetTarget() { + // Construct request + const request = { + forwardingRule, + project, + region, + targetReferenceResource, + }; + + // Run request + const response = await computeClient.setTarget(request); + console.log(response); + } + + callSetTarget(); + // [END compute_v1_generated_ForwardingRules_SetTarget_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_addresses.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_addresses.delete.js new file mode 100644 index 00000000000..4ee747f303d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_addresses.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(address, project) { + // [START compute_v1_generated_GlobalAddresses_Delete_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. + */ + /** + * Name of the address resource to delete. + */ + // const address = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {GlobalAddressesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalAddressesClient(); + + async function callDelete() { + // Construct request + const request = { + address, + project, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_GlobalAddresses_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_addresses.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_addresses.get.js new file mode 100644 index 00000000000..a3d6c53008e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_addresses.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(address, project) { + // [START compute_v1_generated_GlobalAddresses_Get_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. + */ + /** + * Name of the address resource to return. + */ + // const address = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {GlobalAddressesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalAddressesClient(); + + async function callGet() { + // Construct request + const request = { + address, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_GlobalAddresses_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_addresses.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_addresses.insert.js new file mode 100644 index 00000000000..87d74f1258d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_addresses.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(addressResource, project) { + // [START compute_v1_generated_GlobalAddresses_Insert_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. + */ + /** + * The body resource for this request + */ + // const addressResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {GlobalAddressesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalAddressesClient(); + + async function callInsert() { + // Construct request + const request = { + addressResource, + project, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_GlobalAddresses_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_addresses.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_addresses.list.js new file mode 100644 index 00000000000..2e2e3d367a9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_addresses.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_GlobalAddresses_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {GlobalAddressesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalAddressesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_GlobalAddresses_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_addresses.set_labels.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_addresses.set_labels.js new file mode 100644 index 00000000000..54eabbe4a2a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_addresses.set_labels.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(globalSetLabelsRequestResource, project, resource) { + // [START compute_v1_generated_GlobalAddresses_SetLabels_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. + */ + /** + * The body resource for this request + */ + // const globalSetLabelsRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {GlobalAddressesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalAddressesClient(); + + async function callSetLabels() { + // Construct request + const request = { + globalSetLabelsRequestResource, + project, + resource, + }; + + // Run request + const response = await computeClient.setLabels(request); + console.log(response); + } + + callSetLabels(); + // [END compute_v1_generated_GlobalAddresses_SetLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.delete.js new file mode 100644 index 00000000000..f9726610971 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(forwardingRule, project) { + // [START compute_v1_generated_GlobalForwardingRules_Delete_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. + */ + /** + * Name of the ForwardingRule resource to delete. + */ + // const forwardingRule = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {GlobalForwardingRulesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalForwardingRulesClient(); + + async function callDelete() { + // Construct request + const request = { + forwardingRule, + project, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_GlobalForwardingRules_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.get.js new file mode 100644 index 00000000000..00d292f114d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(forwardingRule, project) { + // [START compute_v1_generated_GlobalForwardingRules_Get_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. + */ + /** + * Name of the ForwardingRule resource to return. + */ + // const forwardingRule = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {GlobalForwardingRulesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalForwardingRulesClient(); + + async function callGet() { + // Construct request + const request = { + forwardingRule, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_GlobalForwardingRules_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.insert.js new file mode 100644 index 00000000000..a3f1024209d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(forwardingRuleResource, project) { + // [START compute_v1_generated_GlobalForwardingRules_Insert_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. + */ + /** + * The body resource for this request + */ + // const forwardingRuleResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {GlobalForwardingRulesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalForwardingRulesClient(); + + async function callInsert() { + // Construct request + const request = { + forwardingRuleResource, + project, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_GlobalForwardingRules_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.list.js new file mode 100644 index 00000000000..b1832424d0d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_GlobalForwardingRules_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {GlobalForwardingRulesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalForwardingRulesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_GlobalForwardingRules_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.patch.js new file mode 100644 index 00000000000..6c57c70fa08 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(forwardingRule, forwardingRuleResource, project) { + // [START compute_v1_generated_GlobalForwardingRules_Patch_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. + */ + /** + * Name of the ForwardingRule resource to patch. + */ + // const forwardingRule = 'abc123' + /** + * The body resource for this request + */ + // const forwardingRuleResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {GlobalForwardingRulesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalForwardingRulesClient(); + + async function callPatch() { + // Construct request + const request = { + forwardingRule, + forwardingRuleResource, + project, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_GlobalForwardingRules_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.set_labels.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.set_labels.js new file mode 100644 index 00000000000..91e66788b27 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.set_labels.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(globalSetLabelsRequestResource, project, resource) { + // [START compute_v1_generated_GlobalForwardingRules_SetLabels_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. + */ + /** + * The body resource for this request + */ + // const globalSetLabelsRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {GlobalForwardingRulesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalForwardingRulesClient(); + + async function callSetLabels() { + // Construct request + const request = { + globalSetLabelsRequestResource, + project, + resource, + }; + + // Run request + const response = await computeClient.setLabels(request); + console.log(response); + } + + callSetLabels(); + // [END compute_v1_generated_GlobalForwardingRules_SetLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.set_target.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.set_target.js new file mode 100644 index 00000000000..336ec755d4c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_forwarding_rules.set_target.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(forwardingRule, project, targetReferenceResource) { + // [START compute_v1_generated_GlobalForwardingRules_SetTarget_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. + */ + /** + * Name of the ForwardingRule resource in which target is to be set. + */ + // const forwardingRule = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetReferenceResource = {} + + // Imports the Compute library + const {GlobalForwardingRulesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalForwardingRulesClient(); + + async function callSetTarget() { + // Construct request + const request = { + forwardingRule, + project, + targetReferenceResource, + }; + + // Run request + const response = await computeClient.setTarget(request); + console.log(response); + } + + callSetTarget(); + // [END compute_v1_generated_GlobalForwardingRules_SetTarget_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.attach_network_endpoints.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.attach_network_endpoints.js new file mode 100644 index 00000000000..65a7111f056 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.attach_network_endpoints.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(globalNetworkEndpointGroupsAttachEndpointsRequestResource, networkEndpointGroup, project) { + // [START compute_v1_generated_GlobalNetworkEndpointGroups_AttachNetworkEndpoints_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. + */ + /** + * The body resource for this request + */ + // const globalNetworkEndpointGroupsAttachEndpointsRequestResource = {} + /** + * The name of the network endpoint group where you are attaching network endpoints to. It should comply with RFC1035. + */ + // const networkEndpointGroup = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {GlobalNetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalNetworkEndpointGroupsClient(); + + async function callAttachNetworkEndpoints() { + // Construct request + const request = { + globalNetworkEndpointGroupsAttachEndpointsRequestResource, + networkEndpointGroup, + project, + }; + + // Run request + const response = await computeClient.attachNetworkEndpoints(request); + console.log(response); + } + + callAttachNetworkEndpoints(); + // [END compute_v1_generated_GlobalNetworkEndpointGroups_AttachNetworkEndpoints_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.delete.js new file mode 100644 index 00000000000..5ad16160009 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(networkEndpointGroup, project) { + // [START compute_v1_generated_GlobalNetworkEndpointGroups_Delete_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. + */ + /** + * The name of the network endpoint group to delete. It should comply with RFC1035. + */ + // const networkEndpointGroup = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {GlobalNetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalNetworkEndpointGroupsClient(); + + async function callDelete() { + // Construct request + const request = { + networkEndpointGroup, + project, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_GlobalNetworkEndpointGroups_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.detach_network_endpoints.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.detach_network_endpoints.js new file mode 100644 index 00000000000..032f3254727 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.detach_network_endpoints.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(globalNetworkEndpointGroupsDetachEndpointsRequestResource, networkEndpointGroup, project) { + // [START compute_v1_generated_GlobalNetworkEndpointGroups_DetachNetworkEndpoints_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. + */ + /** + * The body resource for this request + */ + // const globalNetworkEndpointGroupsDetachEndpointsRequestResource = {} + /** + * The name of the network endpoint group where you are removing network endpoints. It should comply with RFC1035. + */ + // const networkEndpointGroup = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {GlobalNetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalNetworkEndpointGroupsClient(); + + async function callDetachNetworkEndpoints() { + // Construct request + const request = { + globalNetworkEndpointGroupsDetachEndpointsRequestResource, + networkEndpointGroup, + project, + }; + + // Run request + const response = await computeClient.detachNetworkEndpoints(request); + console.log(response); + } + + callDetachNetworkEndpoints(); + // [END compute_v1_generated_GlobalNetworkEndpointGroups_DetachNetworkEndpoints_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.get.js new file mode 100644 index 00000000000..650b6766dc2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(networkEndpointGroup, project) { + // [START compute_v1_generated_GlobalNetworkEndpointGroups_Get_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. + */ + /** + * The name of the network endpoint group. It should comply with RFC1035. + */ + // const networkEndpointGroup = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {GlobalNetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalNetworkEndpointGroupsClient(); + + async function callGet() { + // Construct request + const request = { + networkEndpointGroup, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_GlobalNetworkEndpointGroups_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.insert.js new file mode 100644 index 00000000000..c8ad6ef1fb1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(networkEndpointGroupResource, project) { + // [START compute_v1_generated_GlobalNetworkEndpointGroups_Insert_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. + */ + /** + * The body resource for this request + */ + // const networkEndpointGroupResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {GlobalNetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalNetworkEndpointGroupsClient(); + + async function callInsert() { + // Construct request + const request = { + networkEndpointGroupResource, + project, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_GlobalNetworkEndpointGroups_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.list.js new file mode 100644 index 00000000000..5bfdfa61730 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_GlobalNetworkEndpointGroups_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {GlobalNetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalNetworkEndpointGroupsClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_GlobalNetworkEndpointGroups_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.list_network_endpoints.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.list_network_endpoints.js new file mode 100644 index 00000000000..62406c3ee3e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_network_endpoint_groups.list_network_endpoints.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(networkEndpointGroup, project) { + // [START compute_v1_generated_GlobalNetworkEndpointGroups_ListNetworkEndpoints_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * The name of the network endpoint group from which you want to generate a list of included network endpoints. It should comply with RFC1035. + */ + // const networkEndpointGroup = 'abc123' + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {GlobalNetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalNetworkEndpointGroupsClient(); + + async function callListNetworkEndpoints() { + // Construct request + const request = { + networkEndpointGroup, + project, + }; + + // Run request + const iterable = await computeClient.listNetworkEndpointsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListNetworkEndpoints(); + // [END compute_v1_generated_GlobalNetworkEndpointGroups_ListNetworkEndpoints_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_operations.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_operations.aggregated_list.js new file mode 100644 index 00000000000..5fd792c7cde --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_operations.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_GlobalOperations_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {GlobalOperationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalOperationsClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_GlobalOperations_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_operations.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_operations.delete.js new file mode 100644 index 00000000000..756763f751f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_operations.delete.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(operation, project) { + // [START compute_v1_generated_GlobalOperations_Delete_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. + */ + /** + * Name of the Operations resource to delete. + */ + // const operation = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {GlobalOperationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalOperationsClient(); + + async function callDelete() { + // Construct request + const request = { + operation, + project, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_GlobalOperations_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_operations.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_operations.get.js new file mode 100644 index 00000000000..b623e870688 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_operations.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(operation, project) { + // [START compute_v1_generated_GlobalOperations_Get_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. + */ + /** + * Name of the Operations resource to return. + */ + // const operation = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {GlobalOperationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalOperationsClient(); + + async function callGet() { + // Construct request + const request = { + operation, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_GlobalOperations_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_operations.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_operations.list.js new file mode 100644 index 00000000000..b3939717feb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_operations.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_GlobalOperations_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {GlobalOperationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalOperationsClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_GlobalOperations_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_operations.wait.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_operations.wait.js new file mode 100644 index 00000000000..db1bf5696c2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_operations.wait.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(operation, project) { + // [START compute_v1_generated_GlobalOperations_Wait_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. + */ + /** + * Name of the Operations resource to return. + */ + // const operation = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {GlobalOperationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalOperationsClient(); + + async function callWait() { + // Construct request + const request = { + operation, + project, + }; + + // Run request + const response = await computeClient.wait(request); + console.log(response); + } + + callWait(); + // [END compute_v1_generated_GlobalOperations_Wait_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_organization_operations.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_organization_operations.delete.js new file mode 100644 index 00000000000..03e1902c546 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_organization_operations.delete.js @@ -0,0 +1,65 @@ +// Copyright 2023 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(operation) { + // [START compute_v1_generated_GlobalOrganizationOperations_Delete_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. + */ + /** + * Name of the Operations resource to delete. + */ + // const operation = 'abc123' + /** + * Parent ID for this request. + */ + // const parentId = 'abc123' + + // Imports the Compute library + const {GlobalOrganizationOperationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalOrganizationOperationsClient(); + + async function callDelete() { + // Construct request + const request = { + operation, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_GlobalOrganizationOperations_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_organization_operations.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_organization_operations.get.js new file mode 100644 index 00000000000..4bb8dba8f94 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_organization_operations.get.js @@ -0,0 +1,65 @@ +// Copyright 2023 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(operation) { + // [START compute_v1_generated_GlobalOrganizationOperations_Get_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. + */ + /** + * Name of the Operations resource to return. + */ + // const operation = 'abc123' + /** + * Parent ID for this request. + */ + // const parentId = 'abc123' + + // Imports the Compute library + const {GlobalOrganizationOperationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalOrganizationOperationsClient(); + + async function callGet() { + // Construct request + const request = { + operation, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_GlobalOrganizationOperations_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_organization_operations.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_organization_operations.list.js new file mode 100644 index 00000000000..d824970e320 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_organization_operations.list.js @@ -0,0 +1,82 @@ +// Copyright 2023 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() { + // [START compute_v1_generated_GlobalOrganizationOperations_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Parent ID for this request. + */ + // const parentId = 'abc123' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {GlobalOrganizationOperationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalOrganizationOperationsClient(); + + async function callList() { + // Construct request + const request = { + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_GlobalOrganizationOperations_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_public_delegated_prefixes.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_public_delegated_prefixes.delete.js new file mode 100644 index 00000000000..6d4cde152f1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_public_delegated_prefixes.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, publicDelegatedPrefix) { + // [START compute_v1_generated_GlobalPublicDelegatedPrefixes_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the PublicDelegatedPrefix resource to delete. + */ + // const publicDelegatedPrefix = 'abc123' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {GlobalPublicDelegatedPrefixesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalPublicDelegatedPrefixesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + publicDelegatedPrefix, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_GlobalPublicDelegatedPrefixes_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_public_delegated_prefixes.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_public_delegated_prefixes.get.js new file mode 100644 index 00000000000..ffe8a99579b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_public_delegated_prefixes.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(project, publicDelegatedPrefix) { + // [START compute_v1_generated_GlobalPublicDelegatedPrefixes_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the PublicDelegatedPrefix resource to return. + */ + // const publicDelegatedPrefix = 'abc123' + + // Imports the Compute library + const {GlobalPublicDelegatedPrefixesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalPublicDelegatedPrefixesClient(); + + async function callGet() { + // Construct request + const request = { + project, + publicDelegatedPrefix, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_GlobalPublicDelegatedPrefixes_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_public_delegated_prefixes.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_public_delegated_prefixes.insert.js new file mode 100644 index 00000000000..2d755e9dddb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_public_delegated_prefixes.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, publicDelegatedPrefixResource) { + // [START compute_v1_generated_GlobalPublicDelegatedPrefixes_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The body resource for this request + */ + // const publicDelegatedPrefixResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {GlobalPublicDelegatedPrefixesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalPublicDelegatedPrefixesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + publicDelegatedPrefixResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_GlobalPublicDelegatedPrefixes_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_public_delegated_prefixes.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_public_delegated_prefixes.list.js new file mode 100644 index 00000000000..9bb11600779 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_public_delegated_prefixes.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_GlobalPublicDelegatedPrefixes_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {GlobalPublicDelegatedPrefixesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalPublicDelegatedPrefixesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_GlobalPublicDelegatedPrefixes_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_public_delegated_prefixes.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_public_delegated_prefixes.patch.js new file mode 100644 index 00000000000..39cdd49ace8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/global_public_delegated_prefixes.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, publicDelegatedPrefix, publicDelegatedPrefixResource) { + // [START compute_v1_generated_GlobalPublicDelegatedPrefixes_Patch_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the PublicDelegatedPrefix resource to patch. + */ + // const publicDelegatedPrefix = 'abc123' + /** + * The body resource for this request + */ + // const publicDelegatedPrefixResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {GlobalPublicDelegatedPrefixesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new GlobalPublicDelegatedPrefixesClient(); + + async function callPatch() { + // Construct request + const request = { + project, + publicDelegatedPrefix, + publicDelegatedPrefixResource, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_GlobalPublicDelegatedPrefixes_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.aggregated_list.js new file mode 100644 index 00000000000..e890c8cafcb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_HealthChecks_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Name of the project scoping this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {HealthChecksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new HealthChecksClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_HealthChecks_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.delete.js new file mode 100644 index 00000000000..be2a5f4daec --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(healthCheck, project) { + // [START compute_v1_generated_HealthChecks_Delete_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. + */ + /** + * Name of the HealthCheck resource to delete. + */ + // const healthCheck = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {HealthChecksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new HealthChecksClient(); + + async function callDelete() { + // Construct request + const request = { + healthCheck, + project, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_HealthChecks_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.get.js new file mode 100644 index 00000000000..cda15a0aea3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(healthCheck, project) { + // [START compute_v1_generated_HealthChecks_Get_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. + */ + /** + * Name of the HealthCheck resource to return. + */ + // const healthCheck = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {HealthChecksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new HealthChecksClient(); + + async function callGet() { + // Construct request + const request = { + healthCheck, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_HealthChecks_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.insert.js new file mode 100644 index 00000000000..182d96bfb3c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(healthCheckResource, project) { + // [START compute_v1_generated_HealthChecks_Insert_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. + */ + /** + * The body resource for this request + */ + // const healthCheckResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {HealthChecksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new HealthChecksClient(); + + async function callInsert() { + // Construct request + const request = { + healthCheckResource, + project, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_HealthChecks_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.list.js new file mode 100644 index 00000000000..5a9d827d199 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_HealthChecks_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {HealthChecksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new HealthChecksClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_HealthChecks_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.patch.js new file mode 100644 index 00000000000..ab36923c99c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(healthCheck, healthCheckResource, project) { + // [START compute_v1_generated_HealthChecks_Patch_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. + */ + /** + * Name of the HealthCheck resource to patch. + */ + // const healthCheck = 'abc123' + /** + * The body resource for this request + */ + // const healthCheckResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {HealthChecksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new HealthChecksClient(); + + async function callPatch() { + // Construct request + const request = { + healthCheck, + healthCheckResource, + project, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_HealthChecks_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.update.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.update.js new file mode 100644 index 00000000000..f6a3ee819c3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/health_checks.update.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(healthCheck, healthCheckResource, project) { + // [START compute_v1_generated_HealthChecks_Update_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. + */ + /** + * Name of the HealthCheck resource to update. + */ + // const healthCheck = 'abc123' + /** + * The body resource for this request + */ + // const healthCheckResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {HealthChecksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new HealthChecksClient(); + + async function callUpdate() { + // Construct request + const request = { + healthCheck, + healthCheckResource, + project, + }; + + // Run request + const response = await computeClient.update(request); + console.log(response); + } + + callUpdate(); + // [END compute_v1_generated_HealthChecks_Update_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/image_family_views.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/image_family_views.get.js new file mode 100644 index 00000000000..f39ff9a145d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/image_family_views.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(family, project, zone) { + // [START compute_v1_generated_ImageFamilyViews_Get_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. + */ + /** + * Name of the image family to search for. + */ + // const family = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {ImageFamilyViewsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ImageFamilyViewsClient(); + + async function callGet() { + // Construct request + const request = { + family, + project, + zone, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_ImageFamilyViews_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.delete.js new file mode 100644 index 00000000000..b2d38bff143 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(image, project) { + // [START compute_v1_generated_Images_Delete_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. + */ + /** + * Name of the image resource to delete. + */ + // const image = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ImagesClient(); + + async function callDelete() { + // Construct request + const request = { + image, + project, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_Images_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.deprecate.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.deprecate.js new file mode 100644 index 00000000000..e212cff8805 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.deprecate.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(deprecationStatusResource, image, project) { + // [START compute_v1_generated_Images_Deprecate_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. + */ + /** + * The body resource for this request + */ + // const deprecationStatusResource = {} + /** + * Image name. + */ + // const image = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ImagesClient(); + + async function callDeprecate() { + // Construct request + const request = { + deprecationStatusResource, + image, + project, + }; + + // Run request + const response = await computeClient.deprecate(request); + console.log(response); + } + + callDeprecate(); + // [END compute_v1_generated_Images_Deprecate_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.get.js new file mode 100644 index 00000000000..2ec0a2018db --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(image, project) { + // [START compute_v1_generated_Images_Get_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. + */ + /** + * Name of the image resource to return. + */ + // const image = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {ImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ImagesClient(); + + async function callGet() { + // Construct request + const request = { + image, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Images_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.get_from_family.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.get_from_family.js new file mode 100644 index 00000000000..64d53f3885a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.get_from_family.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(family, project) { + // [START compute_v1_generated_Images_GetFromFamily_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. + */ + /** + * Name of the image family to search for. + */ + // const family = 'abc123' + /** + * The image project that the image belongs to. For example, to get a CentOS image, specify centos-cloud as the image project. + */ + // const project = 'my-project' + + // Imports the Compute library + const {ImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ImagesClient(); + + async function callGetFromFamily() { + // Construct request + const request = { + family, + project, + }; + + // Run request + const response = await computeClient.getFromFamily(request); + console.log(response); + } + + callGetFromFamily(); + // [END compute_v1_generated_Images_GetFromFamily_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.get_iam_policy.js new file mode 100644 index 00000000000..abae7b39a9b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.get_iam_policy.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, resource) { + // [START compute_v1_generated_Images_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {ImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ImagesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + resource, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_Images_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.insert.js new file mode 100644 index 00000000000..903645496f3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.insert.js @@ -0,0 +1,74 @@ +// Copyright 2023 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(imageResource, project) { + // [START compute_v1_generated_Images_Insert_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. + */ + /** + * Force image creation if true. + */ + // const forceCreate = true + /** + * The body resource for this request + */ + // const imageResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ImagesClient(); + + async function callInsert() { + // Construct request + const request = { + imageResource, + project, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_Images_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.list.js new file mode 100644 index 00000000000..9150e423cd0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Images_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {ImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ImagesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_Images_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.patch.js new file mode 100644 index 00000000000..ec74d7718a2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(image, imageResource, project) { + // [START compute_v1_generated_Images_Patch_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. + */ + /** + * Name of the image resource to patch. + */ + // const image = 'abc123' + /** + * The body resource for this request + */ + // const imageResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ImagesClient(); + + async function callPatch() { + // Construct request + const request = { + image, + imageResource, + project, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_Images_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.set_iam_policy.js new file mode 100644 index 00000000000..d611ebf292e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.set_iam_policy.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(globalSetPolicyRequestResource, project, resource) { + // [START compute_v1_generated_Images_SetIamPolicy_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. + */ + /** + * The body resource for this request + */ + // const globalSetPolicyRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {ImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ImagesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + globalSetPolicyRequestResource, + project, + resource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_Images_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.set_labels.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.set_labels.js new file mode 100644 index 00000000000..b76288736bf --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.set_labels.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(globalSetLabelsRequestResource, project, resource) { + // [START compute_v1_generated_Images_SetLabels_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. + */ + /** + * The body resource for this request + */ + // const globalSetLabelsRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {ImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ImagesClient(); + + async function callSetLabels() { + // Construct request + const request = { + globalSetLabelsRequestResource, + project, + resource, + }; + + // Run request + const response = await computeClient.setLabels(request); + console.log(response); + } + + callSetLabels(); + // [END compute_v1_generated_Images_SetLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.test_iam_permissions.js new file mode 100644 index 00000000000..423346906b5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/images.test_iam_permissions.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_Images_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {ImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ImagesClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_Images_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.abandon_instances.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.abandon_instances.js new file mode 100644 index 00000000000..c1a90e3c186 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.abandon_instances.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, instanceGroupManagersAbandonInstancesRequestResource, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_AbandonInstances_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. + */ + /** + * The name of the managed instance group. + */ + // const instanceGroupManager = 'abc123' + /** + * The body resource for this request + */ + // const instanceGroupManagersAbandonInstancesRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where the managed instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callAbandonInstances() { + // Construct request + const request = { + instanceGroupManager, + instanceGroupManagersAbandonInstancesRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.abandonInstances(request); + console.log(response); + } + + callAbandonInstances(); + // [END compute_v1_generated_InstanceGroupManagers_AbandonInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.aggregated_list.js new file mode 100644 index 00000000000..ef329741042 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_InstanceGroupManagers_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_InstanceGroupManagers_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.apply_updates_to_instances.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.apply_updates_to_instances.js new file mode 100644 index 00000000000..c6c52905dd5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.apply_updates_to_instances.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(instanceGroupManager, instanceGroupManagersApplyUpdatesRequestResource, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_ApplyUpdatesToInstances_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. + */ + /** + * The name of the managed instance group, should conform to RFC1035. + */ + // const instanceGroupManager = 'abc123' + /** + * The body resource for this request + */ + // const instanceGroupManagersApplyUpdatesRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone where the managed instance group is located. Should conform to RFC1035. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callApplyUpdatesToInstances() { + // Construct request + const request = { + instanceGroupManager, + instanceGroupManagersApplyUpdatesRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.applyUpdatesToInstances(request); + console.log(response); + } + + callApplyUpdatesToInstances(); + // [END compute_v1_generated_InstanceGroupManagers_ApplyUpdatesToInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.create_instances.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.create_instances.js new file mode 100644 index 00000000000..b258547a4c5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.create_instances.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, instanceGroupManagersCreateInstancesRequestResource, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_CreateInstances_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. + */ + /** + * The name of the managed instance group. It should conform to RFC1035. + */ + // const instanceGroupManager = 'abc123' + /** + * The body resource for this request + */ + // const instanceGroupManagersCreateInstancesRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where the managed instance group is located. It should conform to RFC1035. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callCreateInstances() { + // Construct request + const request = { + instanceGroupManager, + instanceGroupManagersCreateInstancesRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.createInstances(request); + console.log(response); + } + + callCreateInstances(); + // [END compute_v1_generated_InstanceGroupManagers_CreateInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.delete.js new file mode 100644 index 00000000000..488c7052bbd --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(instanceGroupManager, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_Delete_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. + */ + /** + * The name of the managed instance group to delete. + */ + // const instanceGroupManager = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where the managed instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callDelete() { + // Construct request + const request = { + instanceGroupManager, + project, + zone, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_InstanceGroupManagers_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.delete_instances.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.delete_instances.js new file mode 100644 index 00000000000..f8cf6289623 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.delete_instances.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, instanceGroupManagersDeleteInstancesRequestResource, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_DeleteInstances_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. + */ + /** + * The name of the managed instance group. + */ + // const instanceGroupManager = 'abc123' + /** + * The body resource for this request + */ + // const instanceGroupManagersDeleteInstancesRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where the managed instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callDeleteInstances() { + // Construct request + const request = { + instanceGroupManager, + instanceGroupManagersDeleteInstancesRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.deleteInstances(request); + console.log(response); + } + + callDeleteInstances(); + // [END compute_v1_generated_InstanceGroupManagers_DeleteInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.delete_per_instance_configs.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.delete_per_instance_configs.js new file mode 100644 index 00000000000..3fe447bb72d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.delete_per_instance_configs.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(instanceGroupManager, instanceGroupManagersDeletePerInstanceConfigsReqResource, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_DeletePerInstanceConfigs_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. + */ + /** + * The name of the managed instance group. It should conform to RFC1035. + */ + // const instanceGroupManager = 'abc123' + /** + * The body resource for this request + */ + // const instanceGroupManagersDeletePerInstanceConfigsReqResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone where the managed instance group is located. It should conform to RFC1035. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callDeletePerInstanceConfigs() { + // Construct request + const request = { + instanceGroupManager, + instanceGroupManagersDeletePerInstanceConfigsReqResource, + project, + zone, + }; + + // Run request + const response = await computeClient.deletePerInstanceConfigs(request); + console.log(response); + } + + callDeletePerInstanceConfigs(); + // [END compute_v1_generated_InstanceGroupManagers_DeletePerInstanceConfigs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.get.js new file mode 100644 index 00000000000..17bd6f7cf0f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(instanceGroupManager, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_Get_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. + */ + /** + * The name of the managed instance group. + */ + // const instanceGroupManager = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone where the managed instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callGet() { + // Construct request + const request = { + instanceGroupManager, + project, + zone, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_InstanceGroupManagers_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.insert.js new file mode 100644 index 00000000000..fa8efb8391f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(instanceGroupManagerResource, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_Insert_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. + */ + /** + * The body resource for this request + */ + // const instanceGroupManagerResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where you want to create the managed instance group. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callInsert() { + // Construct request + const request = { + instanceGroupManagerResource, + project, + zone, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_InstanceGroupManagers_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.list.js new file mode 100644 index 00000000000..20fb9c651c5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone where the managed instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callList() { + // Construct request + const request = { + project, + zone, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_InstanceGroupManagers_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.list_errors.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.list_errors.js new file mode 100644 index 00000000000..0c365d17385 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.list_errors.js @@ -0,0 +1,93 @@ +// Copyright 2023 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(instanceGroupManager, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_ListErrors_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The name of the managed instance group. It must be a string that meets the requirements in RFC1035, or an unsigned long integer: must match regexp pattern: (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)|1-9{0,19}. + */ + // const instanceGroupManager = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone where the managed instance group is located. It should conform to RFC1035. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callListErrors() { + // Construct request + const request = { + instanceGroupManager, + project, + zone, + }; + + // Run request + const iterable = await computeClient.listErrorsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListErrors(); + // [END compute_v1_generated_InstanceGroupManagers_ListErrors_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.list_managed_instances.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.list_managed_instances.js new file mode 100644 index 00000000000..feda9e13cff --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.list_managed_instances.js @@ -0,0 +1,93 @@ +// Copyright 2023 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(instanceGroupManager, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_ListManagedInstances_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The name of the managed instance group. + */ + // const instanceGroupManager = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone where the managed instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callListManagedInstances() { + // Construct request + const request = { + instanceGroupManager, + project, + zone, + }; + + // Run request + const iterable = await computeClient.listManagedInstancesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListManagedInstances(); + // [END compute_v1_generated_InstanceGroupManagers_ListManagedInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.list_per_instance_configs.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.list_per_instance_configs.js new file mode 100644 index 00000000000..c00b63ec8a8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.list_per_instance_configs.js @@ -0,0 +1,93 @@ +// Copyright 2023 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(instanceGroupManager, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_ListPerInstanceConfigs_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The name of the managed instance group. It should conform to RFC1035. + */ + // const instanceGroupManager = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone where the managed instance group is located. It should conform to RFC1035. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callListPerInstanceConfigs() { + // Construct request + const request = { + instanceGroupManager, + project, + zone, + }; + + // Run request + const iterable = await computeClient.listPerInstanceConfigsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListPerInstanceConfigs(); + // [END compute_v1_generated_InstanceGroupManagers_ListPerInstanceConfigs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.patch.js new file mode 100644 index 00000000000..240eb100b59 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, instanceGroupManagerResource, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_Patch_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. + */ + /** + * The name of the instance group manager. + */ + // const instanceGroupManager = 'abc123' + /** + * The body resource for this request + */ + // const instanceGroupManagerResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where you want to create the managed instance group. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callPatch() { + // Construct request + const request = { + instanceGroupManager, + instanceGroupManagerResource, + project, + zone, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_InstanceGroupManagers_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.patch_per_instance_configs.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.patch_per_instance_configs.js new file mode 100644 index 00000000000..46fcd9bb96e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.patch_per_instance_configs.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, instanceGroupManagersPatchPerInstanceConfigsReqResource, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_PatchPerInstanceConfigs_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. + */ + /** + * The name of the managed instance group. It should conform to RFC1035. + */ + // const instanceGroupManager = 'abc123' + /** + * The body resource for this request + */ + // const instanceGroupManagersPatchPerInstanceConfigsReqResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where the managed instance group is located. It should conform to RFC1035. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callPatchPerInstanceConfigs() { + // Construct request + const request = { + instanceGroupManager, + instanceGroupManagersPatchPerInstanceConfigsReqResource, + project, + zone, + }; + + // Run request + const response = await computeClient.patchPerInstanceConfigs(request); + console.log(response); + } + + callPatchPerInstanceConfigs(); + // [END compute_v1_generated_InstanceGroupManagers_PatchPerInstanceConfigs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.recreate_instances.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.recreate_instances.js new file mode 100644 index 00000000000..0e7daf48cef --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.recreate_instances.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, instanceGroupManagersRecreateInstancesRequestResource, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_RecreateInstances_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. + */ + /** + * The name of the managed instance group. + */ + // const instanceGroupManager = 'abc123' + /** + * The body resource for this request + */ + // const instanceGroupManagersRecreateInstancesRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where the managed instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callRecreateInstances() { + // Construct request + const request = { + instanceGroupManager, + instanceGroupManagersRecreateInstancesRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.recreateInstances(request); + console.log(response); + } + + callRecreateInstances(); + // [END compute_v1_generated_InstanceGroupManagers_RecreateInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.resize.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.resize.js new file mode 100644 index 00000000000..e32b405618c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.resize.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, project, size, zone) { + // [START compute_v1_generated_InstanceGroupManagers_Resize_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. + */ + /** + * The name of the managed instance group. + */ + // const instanceGroupManager = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The number of running instances that the managed instance group should maintain at any given time. The group automatically adds or removes instances to maintain the number of instances specified by this parameter. + */ + // const size = 1234 + /** + * The name of the zone where the managed instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callResize() { + // Construct request + const request = { + instanceGroupManager, + project, + size, + zone, + }; + + // Run request + const response = await computeClient.resize(request); + console.log(response); + } + + callResize(); + // [END compute_v1_generated_InstanceGroupManagers_Resize_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.set_instance_template.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.set_instance_template.js new file mode 100644 index 00000000000..72db0741e41 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.set_instance_template.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, instanceGroupManagersSetInstanceTemplateRequestResource, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_SetInstanceTemplate_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. + */ + /** + * The name of the managed instance group. + */ + // const instanceGroupManager = 'abc123' + /** + * The body resource for this request + */ + // const instanceGroupManagersSetInstanceTemplateRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where the managed instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callSetInstanceTemplate() { + // Construct request + const request = { + instanceGroupManager, + instanceGroupManagersSetInstanceTemplateRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.setInstanceTemplate(request); + console.log(response); + } + + callSetInstanceTemplate(); + // [END compute_v1_generated_InstanceGroupManagers_SetInstanceTemplate_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.set_target_pools.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.set_target_pools.js new file mode 100644 index 00000000000..198d1ed3c82 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.set_target_pools.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, instanceGroupManagersSetTargetPoolsRequestResource, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_SetTargetPools_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. + */ + /** + * The name of the managed instance group. + */ + // const instanceGroupManager = 'abc123' + /** + * The body resource for this request + */ + // const instanceGroupManagersSetTargetPoolsRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where the managed instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callSetTargetPools() { + // Construct request + const request = { + instanceGroupManager, + instanceGroupManagersSetTargetPoolsRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.setTargetPools(request); + console.log(response); + } + + callSetTargetPools(); + // [END compute_v1_generated_InstanceGroupManagers_SetTargetPools_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.update_per_instance_configs.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.update_per_instance_configs.js new file mode 100644 index 00000000000..5f7c3bd12a4 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_group_managers.update_per_instance_configs.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, instanceGroupManagersUpdatePerInstanceConfigsReqResource, project, zone) { + // [START compute_v1_generated_InstanceGroupManagers_UpdatePerInstanceConfigs_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. + */ + /** + * The name of the managed instance group. It should conform to RFC1035. + */ + // const instanceGroupManager = 'abc123' + /** + * The body resource for this request + */ + // const instanceGroupManagersUpdatePerInstanceConfigsReqResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where the managed instance group is located. It should conform to RFC1035. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupManagersClient(); + + async function callUpdatePerInstanceConfigs() { + // Construct request + const request = { + instanceGroupManager, + instanceGroupManagersUpdatePerInstanceConfigsReqResource, + project, + zone, + }; + + // Run request + const response = await computeClient.updatePerInstanceConfigs(request); + console.log(response); + } + + callUpdatePerInstanceConfigs(); + // [END compute_v1_generated_InstanceGroupManagers_UpdatePerInstanceConfigs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.add_instances.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.add_instances.js new file mode 100644 index 00000000000..4001c587fe4 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.add_instances.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroup, instanceGroupsAddInstancesRequestResource, project, zone) { + // [START compute_v1_generated_InstanceGroups_AddInstances_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. + */ + /** + * The name of the instance group where you are adding instances. + */ + // const instanceGroup = 'abc123' + /** + * The body resource for this request + */ + // const instanceGroupsAddInstancesRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where the instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupsClient(); + + async function callAddInstances() { + // Construct request + const request = { + instanceGroup, + instanceGroupsAddInstancesRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.addInstances(request); + console.log(response); + } + + callAddInstances(); + // [END compute_v1_generated_InstanceGroups_AddInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.aggregated_list.js new file mode 100644 index 00000000000..65141d83f65 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_InstanceGroups_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {InstanceGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupsClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_InstanceGroups_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.delete.js new file mode 100644 index 00000000000..5276d5d6334 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(instanceGroup, project, zone) { + // [START compute_v1_generated_InstanceGroups_Delete_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. + */ + /** + * The name of the instance group to delete. + */ + // const instanceGroup = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where the instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupsClient(); + + async function callDelete() { + // Construct request + const request = { + instanceGroup, + project, + zone, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_InstanceGroups_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.get.js new file mode 100644 index 00000000000..ae16d1d33b5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(instanceGroup, project, zone) { + // [START compute_v1_generated_InstanceGroups_Get_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. + */ + /** + * The name of the instance group. + */ + // const instanceGroup = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone where the instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupsClient(); + + async function callGet() { + // Construct request + const request = { + instanceGroup, + project, + zone, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_InstanceGroups_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.insert.js new file mode 100644 index 00000000000..300b78e07c3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(instanceGroupResource, project, zone) { + // [START compute_v1_generated_InstanceGroups_Insert_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. + */ + /** + * The body resource for this request + */ + // const instanceGroupResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where you want to create the instance group. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupsClient(); + + async function callInsert() { + // Construct request + const request = { + instanceGroupResource, + project, + zone, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_InstanceGroups_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.list.js new file mode 100644 index 00000000000..ea28501c3da --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, zone) { + // [START compute_v1_generated_InstanceGroups_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone where the instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupsClient(); + + async function callList() { + // Construct request + const request = { + project, + zone, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_InstanceGroups_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.list_instances.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.list_instances.js new file mode 100644 index 00000000000..b6a88b84bbe --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.list_instances.js @@ -0,0 +1,98 @@ +// Copyright 2023 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(instanceGroup, instanceGroupsListInstancesRequestResource, project, zone) { + // [START compute_v1_generated_InstanceGroups_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The name of the instance group from which you want to generate a list of included instances. + */ + // const instanceGroup = 'abc123' + /** + * The body resource for this request + */ + // const instanceGroupsListInstancesRequestResource = {} + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone where the instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupsClient(); + + async function callListInstances() { + // Construct request + const request = { + instanceGroup, + instanceGroupsListInstancesRequestResource, + project, + zone, + }; + + // Run request + const iterable = await computeClient.listInstancesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListInstances(); + // [END compute_v1_generated_InstanceGroups_ListInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.remove_instances.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.remove_instances.js new file mode 100644 index 00000000000..509254ee0c1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.remove_instances.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroup, instanceGroupsRemoveInstancesRequestResource, project, zone) { + // [START compute_v1_generated_InstanceGroups_RemoveInstances_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. + */ + /** + * The name of the instance group where the specified instances will be removed. + */ + // const instanceGroup = 'abc123' + /** + * The body resource for this request + */ + // const instanceGroupsRemoveInstancesRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where the instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupsClient(); + + async function callRemoveInstances() { + // Construct request + const request = { + instanceGroup, + instanceGroupsRemoveInstancesRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.removeInstances(request); + console.log(response); + } + + callRemoveInstances(); + // [END compute_v1_generated_InstanceGroups_RemoveInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.set_named_ports.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.set_named_ports.js new file mode 100644 index 00000000000..16ca20de57a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_groups.set_named_ports.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroup, instanceGroupsSetNamedPortsRequestResource, project, zone) { + // [START compute_v1_generated_InstanceGroups_SetNamedPorts_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. + */ + /** + * The name of the instance group where the named ports are updated. + */ + // const instanceGroup = 'abc123' + /** + * The body resource for this request + */ + // const instanceGroupsSetNamedPortsRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where the instance group is located. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstanceGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceGroupsClient(); + + async function callSetNamedPorts() { + // Construct request + const request = { + instanceGroup, + instanceGroupsSetNamedPortsRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.setNamedPorts(request); + console.log(response); + } + + callSetNamedPorts(); + // [END compute_v1_generated_InstanceGroups_SetNamedPorts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.aggregated_list.js new file mode 100644 index 00000000000..d10b9139652 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_InstanceTemplates_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Name of the project scoping this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {InstanceTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceTemplatesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_InstanceTemplates_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.delete.js new file mode 100644 index 00000000000..fb13518a83d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(instanceTemplate, project) { + // [START compute_v1_generated_InstanceTemplates_Delete_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. + */ + /** + * The name of the instance template to delete. + */ + // const instanceTemplate = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {InstanceTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceTemplatesClient(); + + async function callDelete() { + // Construct request + const request = { + instanceTemplate, + project, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_InstanceTemplates_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.get.js new file mode 100644 index 00000000000..428bf98d849 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(instanceTemplate, project) { + // [START compute_v1_generated_InstanceTemplates_Get_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. + */ + /** + * The name of the instance template. + */ + // const instanceTemplate = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {InstanceTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceTemplatesClient(); + + async function callGet() { + // Construct request + const request = { + instanceTemplate, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_InstanceTemplates_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.get_iam_policy.js new file mode 100644 index 00000000000..f119823c735 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.get_iam_policy.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, resource) { + // [START compute_v1_generated_InstanceTemplates_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {InstanceTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceTemplatesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + resource, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_InstanceTemplates_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.insert.js new file mode 100644 index 00000000000..b2d6e3f78ad --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(instanceTemplateResource, project) { + // [START compute_v1_generated_InstanceTemplates_Insert_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. + */ + /** + * The body resource for this request + */ + // const instanceTemplateResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {InstanceTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceTemplatesClient(); + + async function callInsert() { + // Construct request + const request = { + instanceTemplateResource, + project, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_InstanceTemplates_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.list.js new file mode 100644 index 00000000000..bf4dc1b48b2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_InstanceTemplates_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {InstanceTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceTemplatesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_InstanceTemplates_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.set_iam_policy.js new file mode 100644 index 00000000000..d492583b360 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.set_iam_policy.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(globalSetPolicyRequestResource, project, resource) { + // [START compute_v1_generated_InstanceTemplates_SetIamPolicy_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. + */ + /** + * The body resource for this request + */ + // const globalSetPolicyRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {InstanceTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceTemplatesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + globalSetPolicyRequestResource, + project, + resource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_InstanceTemplates_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.test_iam_permissions.js new file mode 100644 index 00000000000..e12ba6ee37b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instance_templates.test_iam_permissions.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_InstanceTemplates_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {InstanceTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstanceTemplatesClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_InstanceTemplates_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.add_access_config.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.add_access_config.js new file mode 100644 index 00000000000..bf6393e1869 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.add_access_config.js @@ -0,0 +1,85 @@ +// Copyright 2023 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(accessConfigResource, instance, networkInterface, project, zone) { + // [START compute_v1_generated_Instances_AddAccessConfig_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. + */ + /** + * The body resource for this request + */ + // const accessConfigResource = {} + /** + * The instance name for this request. + */ + // const instance = 'abc123' + /** + * The name of the network interface to add to this instance. + */ + // const networkInterface = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callAddAccessConfig() { + // Construct request + const request = { + accessConfigResource, + instance, + networkInterface, + project, + zone, + }; + + // Run request + const response = await computeClient.addAccessConfig(request); + console.log(response); + } + + callAddAccessConfig(); + // [END compute_v1_generated_Instances_AddAccessConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.add_resource_policies.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.add_resource_policies.js new file mode 100644 index 00000000000..eed36e89d37 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.add_resource_policies.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instance, instancesAddResourcePoliciesRequestResource, project, zone) { + // [START compute_v1_generated_Instances_AddResourcePolicies_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. + */ + /** + * The instance name for this request. + */ + // const instance = 'abc123' + /** + * The body resource for this request + */ + // const instancesAddResourcePoliciesRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callAddResourcePolicies() { + // Construct request + const request = { + instance, + instancesAddResourcePoliciesRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.addResourcePolicies(request); + console.log(response); + } + + callAddResourcePolicies(); + // [END compute_v1_generated_Instances_AddResourcePolicies_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.aggregated_list.js new file mode 100644 index 00000000000..9fb77725671 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Instances_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_Instances_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.attach_disk.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.attach_disk.js new file mode 100644 index 00000000000..804e74305bb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.attach_disk.js @@ -0,0 +1,84 @@ +// Copyright 2023 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(attachedDiskResource, instance, project, zone) { + // [START compute_v1_generated_Instances_AttachDisk_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. + */ + /** + * The body resource for this request + */ + // const attachedDiskResource = {} + /** + * Whether to force attach the regional disk even if it's currently attached to another instance. If you try to force attach a zonal disk to an instance, you will receive an error. + */ + // const forceAttach = true + /** + * The instance name for this request. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callAttachDisk() { + // Construct request + const request = { + attachedDiskResource, + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.attachDisk(request); + console.log(response); + } + + callAttachDisk(); + // [END compute_v1_generated_Instances_AttachDisk_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.bulk_insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.bulk_insert.js new file mode 100644 index 00000000000..86abbe8b94b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.bulk_insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(bulkInsertInstanceResourceResource, project, zone) { + // [START compute_v1_generated_Instances_BulkInsert_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. + */ + /** + * The body resource for this request + */ + // const bulkInsertInstanceResourceResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callBulkInsert() { + // Construct request + const request = { + bulkInsertInstanceResourceResource, + project, + zone, + }; + + // Run request + const response = await computeClient.bulkInsert(request); + console.log(response); + } + + callBulkInsert(); + // [END compute_v1_generated_Instances_BulkInsert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.delete.js new file mode 100644 index 00000000000..db3e2af2abd --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(instance, project, zone) { + // [START compute_v1_generated_Instances_Delete_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. + */ + /** + * Name of the instance resource to delete. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callDelete() { + // Construct request + const request = { + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_Instances_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.delete_access_config.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.delete_access_config.js new file mode 100644 index 00000000000..a073dc201f9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.delete_access_config.js @@ -0,0 +1,85 @@ +// Copyright 2023 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(accessConfig, instance, networkInterface, project, zone) { + // [START compute_v1_generated_Instances_DeleteAccessConfig_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. + */ + /** + * The name of the access config to delete. + */ + // const accessConfig = 'abc123' + /** + * The instance name for this request. + */ + // const instance = 'abc123' + /** + * The name of the network interface. + */ + // const networkInterface = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callDeleteAccessConfig() { + // Construct request + const request = { + accessConfig, + instance, + networkInterface, + project, + zone, + }; + + // Run request + const response = await computeClient.deleteAccessConfig(request); + console.log(response); + } + + callDeleteAccessConfig(); + // [END compute_v1_generated_Instances_DeleteAccessConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.detach_disk.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.detach_disk.js new file mode 100644 index 00000000000..937cd9e606e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.detach_disk.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(deviceName, instance, project, zone) { + // [START compute_v1_generated_Instances_DetachDisk_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. + */ + /** + * The device name of the disk to detach. Make a get() request on the instance to view currently attached disks and device names. + */ + // const deviceName = 'abc123' + /** + * Instance name for this request. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callDetachDisk() { + // Construct request + const request = { + deviceName, + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.detachDisk(request); + console.log(response); + } + + callDetachDisk(); + // [END compute_v1_generated_Instances_DetachDisk_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get.js new file mode 100644 index 00000000000..c14c9a39b4f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(instance, project, zone) { + // [START compute_v1_generated_Instances_Get_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. + */ + /** + * Name of the instance resource to return. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callGet() { + // Construct request + const request = { + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Instances_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_effective_firewalls.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_effective_firewalls.js new file mode 100644 index 00000000000..abb5824008a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_effective_firewalls.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(instance, networkInterface, project, zone) { + // [START compute_v1_generated_Instances_GetEffectiveFirewalls_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. + */ + /** + * Name of the instance scoping this request. + */ + // const instance = 'abc123' + /** + * The name of the network interface to get the effective firewalls. + */ + // const networkInterface = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callGetEffectiveFirewalls() { + // Construct request + const request = { + instance, + networkInterface, + project, + zone, + }; + + // Run request + const response = await computeClient.getEffectiveFirewalls(request); + console.log(response); + } + + callGetEffectiveFirewalls(); + // [END compute_v1_generated_Instances_GetEffectiveFirewalls_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_guest_attributes.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_guest_attributes.js new file mode 100644 index 00000000000..5eb30a20fc0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_guest_attributes.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(instance, project, zone) { + // [START compute_v1_generated_Instances_GetGuestAttributes_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. + */ + /** + * Name of the instance scoping this request. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Specifies the guest attributes path to be queried. + */ + // const queryPath = 'abc123' + /** + * Specifies the key for the guest attributes entry. + */ + // const variableKey = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callGetGuestAttributes() { + // Construct request + const request = { + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.getGuestAttributes(request); + console.log(response); + } + + callGetGuestAttributes(); + // [END compute_v1_generated_Instances_GetGuestAttributes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_iam_policy.js new file mode 100644 index 00000000000..833360d9071 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_iam_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, resource, zone) { + // [START compute_v1_generated_Instances_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + resource, + zone, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_Instances_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_screenshot.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_screenshot.js new file mode 100644 index 00000000000..91c6f41f78f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_screenshot.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(instance, project, zone) { + // [START compute_v1_generated_Instances_GetScreenshot_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. + */ + /** + * Name of the instance scoping this request. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callGetScreenshot() { + // Construct request + const request = { + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.getScreenshot(request); + console.log(response); + } + + callGetScreenshot(); + // [END compute_v1_generated_Instances_GetScreenshot_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_serial_port_output.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_serial_port_output.js new file mode 100644 index 00000000000..5b87ffd1950 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_serial_port_output.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(instance, project, zone) { + // [START compute_v1_generated_Instances_GetSerialPortOutput_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. + */ + /** + * Name of the instance for this request. + */ + // const instance = 'abc123' + /** + * Specifies which COM or serial port to retrieve data from. + */ + // const port = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Specifies the starting byte position of the output to return. To start with the first byte of output to the specified port, omit this field or set it to `0`. If the output for that byte position is available, this field matches the `start` parameter sent with the request. If the amount of serial console output exceeds the size of the buffer (1 MB), the oldest output is discarded and is no longer available. If the requested start position refers to discarded output, the start position is adjusted to the oldest output still available, and the adjusted start position is returned as the `start` property value. You can also provide a negative start position, which translates to the most recent number of bytes written to the serial port. For example, -3 is interpreted as the most recent 3 bytes written to the serial console. + */ + // const start = 1234 + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callGetSerialPortOutput() { + // Construct request + const request = { + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.getSerialPortOutput(request); + console.log(response); + } + + callGetSerialPortOutput(); + // [END compute_v1_generated_Instances_GetSerialPortOutput_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_shielded_instance_identity.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_shielded_instance_identity.js new file mode 100644 index 00000000000..c317e1ce33a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.get_shielded_instance_identity.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(instance, project, zone) { + // [START compute_v1_generated_Instances_GetShieldedInstanceIdentity_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. + */ + /** + * Name or id of the instance scoping this request. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callGetShieldedInstanceIdentity() { + // Construct request + const request = { + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.getShieldedInstanceIdentity(request); + console.log(response); + } + + callGetShieldedInstanceIdentity(); + // [END compute_v1_generated_Instances_GetShieldedInstanceIdentity_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.insert.js new file mode 100644 index 00000000000..960ada229da --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.insert.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(instanceResource, project, zone) { + // [START compute_v1_generated_Instances_Insert_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. + */ + /** + * The body resource for this request + */ + // const instanceResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Specifies instance template to create the instance. This field is optional. It can be a full or partial URL. For example, the following are all valid URLs to an instance template: - https://www.googleapis.com/compute/v1/projects/project /global/instanceTemplates/instanceTemplate - projects/project/global/instanceTemplates/instanceTemplate - global/instanceTemplates/instanceTemplate + */ + // const sourceInstanceTemplate = 'abc123' + /** + * Specifies the machine image to use to create the instance. This field is optional. It can be a full or partial URL. For example, the following are all valid URLs to a machine image: - https://www.googleapis.com/compute/v1/projects/project/global/global /machineImages/machineImage - projects/project/global/global/machineImages/machineImage - global/machineImages/machineImage + */ + // const sourceMachineImage = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callInsert() { + // Construct request + const request = { + instanceResource, + project, + zone, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_Instances_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.list.js new file mode 100644 index 00000000000..4e78a127835 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, zone) { + // [START compute_v1_generated_Instances_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callList() { + // Construct request + const request = { + project, + zone, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_Instances_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.list_referrers.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.list_referrers.js new file mode 100644 index 00000000000..85984227fb4 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.list_referrers.js @@ -0,0 +1,93 @@ +// Copyright 2023 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(instance, project, zone) { + // [START compute_v1_generated_Instances_ListReferrers_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Name of the target instance scoping this request, or '-' if the request should span over all instances in the container. + */ + // const instance = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callListReferrers() { + // Construct request + const request = { + instance, + project, + zone, + }; + + // Run request + const iterable = await computeClient.listReferrersAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListReferrers(); + // [END compute_v1_generated_Instances_ListReferrers_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.remove_resource_policies.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.remove_resource_policies.js new file mode 100644 index 00000000000..95693dc8c7e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.remove_resource_policies.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instance, instancesRemoveResourcePoliciesRequestResource, project, zone) { + // [START compute_v1_generated_Instances_RemoveResourcePolicies_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. + */ + /** + * The instance name for this request. + */ + // const instance = 'abc123' + /** + * The body resource for this request + */ + // const instancesRemoveResourcePoliciesRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callRemoveResourcePolicies() { + // Construct request + const request = { + instance, + instancesRemoveResourcePoliciesRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.removeResourcePolicies(request); + console.log(response); + } + + callRemoveResourcePolicies(); + // [END compute_v1_generated_Instances_RemoveResourcePolicies_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.reset.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.reset.js new file mode 100644 index 00000000000..179881ffafd --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.reset.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(instance, project, zone) { + // [START compute_v1_generated_Instances_Reset_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. + */ + /** + * Name of the instance scoping this request. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callReset() { + // Construct request + const request = { + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.reset(request); + console.log(response); + } + + callReset(); + // [END compute_v1_generated_Instances_Reset_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.resume.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.resume.js new file mode 100644 index 00000000000..f481476f1af --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.resume.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(instance, project, zone) { + // [START compute_v1_generated_Instances_Resume_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. + */ + /** + * Name of the instance resource to resume. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callResume() { + // Construct request + const request = { + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.resume(request); + console.log(response); + } + + callResume(); + // [END compute_v1_generated_Instances_Resume_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.send_diagnostic_interrupt.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.send_diagnostic_interrupt.js new file mode 100644 index 00000000000..a14607dcd24 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.send_diagnostic_interrupt.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(instance, project, zone) { + // [START compute_v1_generated_Instances_SendDiagnosticInterrupt_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. + */ + /** + * Name of the instance scoping this request. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callSendDiagnosticInterrupt() { + // Construct request + const request = { + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.sendDiagnosticInterrupt(request); + console.log(response); + } + + callSendDiagnosticInterrupt(); + // [END compute_v1_generated_Instances_SendDiagnosticInterrupt_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_deletion_protection.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_deletion_protection.js new file mode 100644 index 00000000000..7c9d0a2f388 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_deletion_protection.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(project, resource, zone) { + // [START compute_v1_generated_Instances_SetDeletionProtection_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. + */ + /** + * Whether the resource should be protected against deletion. + */ + // const deletionProtection = true + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callSetDeletionProtection() { + // Construct request + const request = { + project, + resource, + zone, + }; + + // Run request + const response = await computeClient.setDeletionProtection(request); + console.log(response); + } + + callSetDeletionProtection(); + // [END compute_v1_generated_Instances_SetDeletionProtection_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_disk_auto_delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_disk_auto_delete.js new file mode 100644 index 00000000000..66b6068ce98 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_disk_auto_delete.js @@ -0,0 +1,85 @@ +// Copyright 2023 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(autoDelete, deviceName, instance, project, zone) { + // [START compute_v1_generated_Instances_SetDiskAutoDelete_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. + */ + /** + * Whether to auto-delete the disk when the instance is deleted. + */ + // const autoDelete = true + /** + * The device name of the disk to modify. Make a get() request on the instance to view currently attached disks and device names. + */ + // const deviceName = 'abc123' + /** + * The instance name for this request. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callSetDiskAutoDelete() { + // Construct request + const request = { + autoDelete, + deviceName, + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.setDiskAutoDelete(request); + console.log(response); + } + + callSetDiskAutoDelete(); + // [END compute_v1_generated_Instances_SetDiskAutoDelete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_iam_policy.js new file mode 100644 index 00000000000..9f446cf8cf7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_iam_policy.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, resource, zone, zoneSetPolicyRequestResource) { + // [START compute_v1_generated_Instances_SetIamPolicy_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + /** + * The body resource for this request + */ + // const zoneSetPolicyRequestResource = {} + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + project, + resource, + zone, + zoneSetPolicyRequestResource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_Instances_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_labels.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_labels.js new file mode 100644 index 00000000000..b38e3f6dd5a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_labels.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instance, instancesSetLabelsRequestResource, project, zone) { + // [START compute_v1_generated_Instances_SetLabels_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. + */ + /** + * Name of the instance scoping this request. + */ + // const instance = 'abc123' + /** + * The body resource for this request + */ + // const instancesSetLabelsRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callSetLabels() { + // Construct request + const request = { + instance, + instancesSetLabelsRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.setLabels(request); + console.log(response); + } + + callSetLabels(); + // [END compute_v1_generated_Instances_SetLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_machine_resources.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_machine_resources.js new file mode 100644 index 00000000000..d84c57bfeb7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_machine_resources.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instance, instancesSetMachineResourcesRequestResource, project, zone) { + // [START compute_v1_generated_Instances_SetMachineResources_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. + */ + /** + * Name of the instance scoping this request. + */ + // const instance = 'abc123' + /** + * The body resource for this request + */ + // const instancesSetMachineResourcesRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callSetMachineResources() { + // Construct request + const request = { + instance, + instancesSetMachineResourcesRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.setMachineResources(request); + console.log(response); + } + + callSetMachineResources(); + // [END compute_v1_generated_Instances_SetMachineResources_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_machine_type.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_machine_type.js new file mode 100644 index 00000000000..e6645b93634 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_machine_type.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instance, instancesSetMachineTypeRequestResource, project, zone) { + // [START compute_v1_generated_Instances_SetMachineType_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. + */ + /** + * Name of the instance scoping this request. + */ + // const instance = 'abc123' + /** + * The body resource for this request + */ + // const instancesSetMachineTypeRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callSetMachineType() { + // Construct request + const request = { + instance, + instancesSetMachineTypeRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.setMachineType(request); + console.log(response); + } + + callSetMachineType(); + // [END compute_v1_generated_Instances_SetMachineType_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_metadata.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_metadata.js new file mode 100644 index 00000000000..e93985cc494 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_metadata.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instance, metadataResource, project, zone) { + // [START compute_v1_generated_Instances_SetMetadata_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. + */ + /** + * Name of the instance scoping this request. + */ + // const instance = 'abc123' + /** + * The body resource for this request + */ + // const metadataResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callSetMetadata() { + // Construct request + const request = { + instance, + metadataResource, + project, + zone, + }; + + // Run request + const response = await computeClient.setMetadata(request); + console.log(response); + } + + callSetMetadata(); + // [END compute_v1_generated_Instances_SetMetadata_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_min_cpu_platform.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_min_cpu_platform.js new file mode 100644 index 00000000000..dc8a2bd9bc7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_min_cpu_platform.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instance, instancesSetMinCpuPlatformRequestResource, project, zone) { + // [START compute_v1_generated_Instances_SetMinCpuPlatform_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. + */ + /** + * Name of the instance scoping this request. + */ + // const instance = 'abc123' + /** + * The body resource for this request + */ + // const instancesSetMinCpuPlatformRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callSetMinCpuPlatform() { + // Construct request + const request = { + instance, + instancesSetMinCpuPlatformRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.setMinCpuPlatform(request); + console.log(response); + } + + callSetMinCpuPlatform(); + // [END compute_v1_generated_Instances_SetMinCpuPlatform_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_name.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_name.js new file mode 100644 index 00000000000..17ddc1db9cd --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_name.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instance, instancesSetNameRequestResource, project, zone) { + // [START compute_v1_generated_Instances_SetName_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. + */ + /** + * The instance name for this request. + */ + // const instance = 'abc123' + /** + * The body resource for this request + */ + // const instancesSetNameRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callSetName() { + // Construct request + const request = { + instance, + instancesSetNameRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.setName(request); + console.log(response); + } + + callSetName(); + // [END compute_v1_generated_Instances_SetName_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_scheduling.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_scheduling.js new file mode 100644 index 00000000000..fed026acb42 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_scheduling.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instance, project, schedulingResource, zone) { + // [START compute_v1_generated_Instances_SetScheduling_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. + */ + /** + * Instance name for this request. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const schedulingResource = {} + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callSetScheduling() { + // Construct request + const request = { + instance, + project, + schedulingResource, + zone, + }; + + // Run request + const response = await computeClient.setScheduling(request); + console.log(response); + } + + callSetScheduling(); + // [END compute_v1_generated_Instances_SetScheduling_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_service_account.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_service_account.js new file mode 100644 index 00000000000..7875cbc707e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_service_account.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instance, instancesSetServiceAccountRequestResource, project, zone) { + // [START compute_v1_generated_Instances_SetServiceAccount_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. + */ + /** + * Name of the instance resource to start. + */ + // const instance = 'abc123' + /** + * The body resource for this request + */ + // const instancesSetServiceAccountRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callSetServiceAccount() { + // Construct request + const request = { + instance, + instancesSetServiceAccountRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.setServiceAccount(request); + console.log(response); + } + + callSetServiceAccount(); + // [END compute_v1_generated_Instances_SetServiceAccount_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_shielded_instance_integrity_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_shielded_instance_integrity_policy.js new file mode 100644 index 00000000000..1469eb5b35a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_shielded_instance_integrity_policy.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instance, project, shieldedInstanceIntegrityPolicyResource, zone) { + // [START compute_v1_generated_Instances_SetShieldedInstanceIntegrityPolicy_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. + */ + /** + * Name or id of the instance scoping this request. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const shieldedInstanceIntegrityPolicyResource = {} + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callSetShieldedInstanceIntegrityPolicy() { + // Construct request + const request = { + instance, + project, + shieldedInstanceIntegrityPolicyResource, + zone, + }; + + // Run request + const response = await computeClient.setShieldedInstanceIntegrityPolicy(request); + console.log(response); + } + + callSetShieldedInstanceIntegrityPolicy(); + // [END compute_v1_generated_Instances_SetShieldedInstanceIntegrityPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_tags.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_tags.js new file mode 100644 index 00000000000..22e0e60285e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.set_tags.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instance, project, tagsResource, zone) { + // [START compute_v1_generated_Instances_SetTags_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. + */ + /** + * Name of the instance scoping this request. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const tagsResource = {} + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callSetTags() { + // Construct request + const request = { + instance, + project, + tagsResource, + zone, + }; + + // Run request + const response = await computeClient.setTags(request); + console.log(response); + } + + callSetTags(); + // [END compute_v1_generated_Instances_SetTags_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.simulate_maintenance_event.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.simulate_maintenance_event.js new file mode 100644 index 00000000000..e65ec56eb1f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.simulate_maintenance_event.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(instance, project, zone) { + // [START compute_v1_generated_Instances_SimulateMaintenanceEvent_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. + */ + /** + * Name of the instance scoping this request. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callSimulateMaintenanceEvent() { + // Construct request + const request = { + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.simulateMaintenanceEvent(request); + console.log(response); + } + + callSimulateMaintenanceEvent(); + // [END compute_v1_generated_Instances_SimulateMaintenanceEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.start.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.start.js new file mode 100644 index 00000000000..dda4f33173f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.start.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(instance, project, zone) { + // [START compute_v1_generated_Instances_Start_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. + */ + /** + * Name of the instance resource to start. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callStart() { + // Construct request + const request = { + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.start(request); + console.log(response); + } + + callStart(); + // [END compute_v1_generated_Instances_Start_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.start_with_encryption_key.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.start_with_encryption_key.js new file mode 100644 index 00000000000..19b95ba1948 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.start_with_encryption_key.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instance, instancesStartWithEncryptionKeyRequestResource, project, zone) { + // [START compute_v1_generated_Instances_StartWithEncryptionKey_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. + */ + /** + * Name of the instance resource to start. + */ + // const instance = 'abc123' + /** + * The body resource for this request + */ + // const instancesStartWithEncryptionKeyRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callStartWithEncryptionKey() { + // Construct request + const request = { + instance, + instancesStartWithEncryptionKeyRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.startWithEncryptionKey(request); + console.log(response); + } + + callStartWithEncryptionKey(); + // [END compute_v1_generated_Instances_StartWithEncryptionKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.stop.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.stop.js new file mode 100644 index 00000000000..efabc488739 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.stop.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(instance, project, zone) { + // [START compute_v1_generated_Instances_Stop_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. + */ + /** + * If true, discard the contents of any attached localSSD partitions. Default value is false. + */ + // const discardLocalSsd = true + /** + * Name of the instance resource to stop. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callStop() { + // Construct request + const request = { + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.stop(request); + console.log(response); + } + + callStop(); + // [END compute_v1_generated_Instances_Stop_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.suspend.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.suspend.js new file mode 100644 index 00000000000..60747f3e6bf --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.suspend.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(instance, project, zone) { + // [START compute_v1_generated_Instances_Suspend_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. + */ + /** + * If true, discard the contents of any attached localSSD partitions. Default value is false. + */ + // const discardLocalSsd = true + /** + * Name of the instance resource to suspend. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callSuspend() { + // Construct request + const request = { + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.suspend(request); + console.log(response); + } + + callSuspend(); + // [END compute_v1_generated_Instances_Suspend_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.test_iam_permissions.js new file mode 100644 index 00000000000..97329abdb0c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.test_iam_permissions.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, resource, testPermissionsRequestResource, zone) { + // [START compute_v1_generated_Instances_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + resource, + testPermissionsRequestResource, + zone, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_Instances_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.update.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.update.js new file mode 100644 index 00000000000..a1bb9a478d8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.update.js @@ -0,0 +1,90 @@ +// Copyright 2023 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(instance, instanceResource, project, zone) { + // [START compute_v1_generated_Instances_Update_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. + */ + /** + * Name of the instance resource to update. + */ + // const instance = 'abc123' + /** + * The body resource for this request + */ + // const instanceResource = {} + /** + * Specifies the action to take when updating an instance even if the updated properties do not require it. If not specified, then Compute Engine acts based on the minimum action that the updated properties require. + * Check the MinimalAction enum for the list of possible values. + */ + // const minimalAction = 'abc123' + /** + * Specifies the most disruptive action that can be taken on the instance as part of the update. Compute Engine returns an error if the instance properties require a more disruptive action as part of the instance update. Valid options from lowest to highest are NO_EFFECT, REFRESH, and RESTART. + * Check the MostDisruptiveAllowedAction enum for the list of possible values. + */ + // const mostDisruptiveAllowedAction = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callUpdate() { + // Construct request + const request = { + instance, + instanceResource, + project, + zone, + }; + + // Run request + const response = await computeClient.update(request); + console.log(response); + } + + callUpdate(); + // [END compute_v1_generated_Instances_Update_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.update_access_config.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.update_access_config.js new file mode 100644 index 00000000000..8240d96699c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.update_access_config.js @@ -0,0 +1,85 @@ +// Copyright 2023 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(accessConfigResource, instance, networkInterface, project, zone) { + // [START compute_v1_generated_Instances_UpdateAccessConfig_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. + */ + /** + * The body resource for this request + */ + // const accessConfigResource = {} + /** + * The instance name for this request. + */ + // const instance = 'abc123' + /** + * The name of the network interface where the access config is attached. + */ + // const networkInterface = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callUpdateAccessConfig() { + // Construct request + const request = { + accessConfigResource, + instance, + networkInterface, + project, + zone, + }; + + // Run request + const response = await computeClient.updateAccessConfig(request); + console.log(response); + } + + callUpdateAccessConfig(); + // [END compute_v1_generated_Instances_UpdateAccessConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.update_display_device.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.update_display_device.js new file mode 100644 index 00000000000..83065fca29c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.update_display_device.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(displayDeviceResource, instance, project, zone) { + // [START compute_v1_generated_Instances_UpdateDisplayDevice_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. + */ + /** + * The body resource for this request + */ + // const displayDeviceResource = {} + /** + * Name of the instance scoping this request. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callUpdateDisplayDevice() { + // Construct request + const request = { + displayDeviceResource, + instance, + project, + zone, + }; + + // Run request + const response = await computeClient.updateDisplayDevice(request); + console.log(response); + } + + callUpdateDisplayDevice(); + // [END compute_v1_generated_Instances_UpdateDisplayDevice_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.update_network_interface.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.update_network_interface.js new file mode 100644 index 00000000000..fb34ecdc627 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.update_network_interface.js @@ -0,0 +1,85 @@ +// Copyright 2023 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(instance, networkInterface, networkInterfaceResource, project, zone) { + // [START compute_v1_generated_Instances_UpdateNetworkInterface_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. + */ + /** + * The instance name for this request. + */ + // const instance = 'abc123' + /** + * The name of the network interface to update. + */ + // const networkInterface = 'abc123' + /** + * The body resource for this request + */ + // const networkInterfaceResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callUpdateNetworkInterface() { + // Construct request + const request = { + instance, + networkInterface, + networkInterfaceResource, + project, + zone, + }; + + // Run request + const response = await computeClient.updateNetworkInterface(request); + console.log(response); + } + + callUpdateNetworkInterface(); + // [END compute_v1_generated_Instances_UpdateNetworkInterface_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.update_shielded_instance_config.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.update_shielded_instance_config.js new file mode 100644 index 00000000000..b3ec736502d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/instances.update_shielded_instance_config.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instance, project, shieldedInstanceConfigResource, zone) { + // [START compute_v1_generated_Instances_UpdateShieldedInstanceConfig_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. + */ + /** + * Name or id of the instance scoping this request. + */ + // const instance = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const shieldedInstanceConfigResource = {} + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {InstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InstancesClient(); + + async function callUpdateShieldedInstanceConfig() { + // Construct request + const request = { + instance, + project, + shieldedInstanceConfigResource, + zone, + }; + + // Run request + const response = await computeClient.updateShieldedInstanceConfig(request); + console.log(response); + } + + callUpdateShieldedInstanceConfig(); + // [END compute_v1_generated_Instances_UpdateShieldedInstanceConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.aggregated_list.js new file mode 100644 index 00000000000..39beeafcc16 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_InterconnectAttachments_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {InterconnectAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InterconnectAttachmentsClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_InterconnectAttachments_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.delete.js new file mode 100644 index 00000000000..f292125104b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(interconnectAttachment, project, region) { + // [START compute_v1_generated_InterconnectAttachments_Delete_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. + */ + /** + * Name of the interconnect attachment to delete. + */ + // const interconnectAttachment = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {InterconnectAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InterconnectAttachmentsClient(); + + async function callDelete() { + // Construct request + const request = { + interconnectAttachment, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_InterconnectAttachments_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.get.js new file mode 100644 index 00000000000..cdfc2763c1e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(interconnectAttachment, project, region) { + // [START compute_v1_generated_InterconnectAttachments_Get_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. + */ + /** + * Name of the interconnect attachment to return. + */ + // const interconnectAttachment = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {InterconnectAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InterconnectAttachmentsClient(); + + async function callGet() { + // Construct request + const request = { + interconnectAttachment, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_InterconnectAttachments_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.insert.js new file mode 100644 index 00000000000..5e916cfc65d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.insert.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(interconnectAttachmentResource, project, region) { + // [START compute_v1_generated_InterconnectAttachments_Insert_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. + */ + /** + * The body resource for this request + */ + // const interconnectAttachmentResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * If true, the request will not be committed. + */ + // const validateOnly = true + + // Imports the Compute library + const {InterconnectAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InterconnectAttachmentsClient(); + + async function callInsert() { + // Construct request + const request = { + interconnectAttachmentResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_InterconnectAttachments_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.list.js new file mode 100644 index 00000000000..c568bcce22c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_InterconnectAttachments_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {InterconnectAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InterconnectAttachmentsClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_InterconnectAttachments_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.patch.js new file mode 100644 index 00000000000..76a5f47a300 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(interconnectAttachment, interconnectAttachmentResource, project, region) { + // [START compute_v1_generated_InterconnectAttachments_Patch_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. + */ + /** + * Name of the interconnect attachment to patch. + */ + // const interconnectAttachment = 'abc123' + /** + * The body resource for this request + */ + // const interconnectAttachmentResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {InterconnectAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InterconnectAttachmentsClient(); + + async function callPatch() { + // Construct request + const request = { + interconnectAttachment, + interconnectAttachmentResource, + project, + region, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_InterconnectAttachments_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.set_labels.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.set_labels.js new file mode 100644 index 00000000000..d1a019c9976 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_attachments.set_labels.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, regionSetLabelsRequestResource, resource) { + // [START compute_v1_generated_InterconnectAttachments_SetLabels_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionSetLabelsRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {InterconnectAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InterconnectAttachmentsClient(); + + async function callSetLabels() { + // Construct request + const request = { + project, + region, + regionSetLabelsRequestResource, + resource, + }; + + // Run request + const response = await computeClient.setLabels(request); + console.log(response); + } + + callSetLabels(); + // [END compute_v1_generated_InterconnectAttachments_SetLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_locations.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_locations.get.js new file mode 100644 index 00000000000..0443f8a6797 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_locations.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(interconnectLocation, project) { + // [START compute_v1_generated_InterconnectLocations_Get_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. + */ + /** + * Name of the interconnect location to return. + */ + // const interconnectLocation = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {InterconnectLocationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InterconnectLocationsClient(); + + async function callGet() { + // Construct request + const request = { + interconnectLocation, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_InterconnectLocations_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_locations.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_locations.list.js new file mode 100644 index 00000000000..f731879d7ff --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnect_locations.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_InterconnectLocations_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {InterconnectLocationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InterconnectLocationsClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_InterconnectLocations_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.delete.js new file mode 100644 index 00000000000..69dd3dc40ca --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(interconnect, project) { + // [START compute_v1_generated_Interconnects_Delete_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. + */ + /** + * Name of the interconnect to delete. + */ + // const interconnect = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {InterconnectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InterconnectsClient(); + + async function callDelete() { + // Construct request + const request = { + interconnect, + project, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_Interconnects_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.get.js new file mode 100644 index 00000000000..629f5e677dc --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(interconnect, project) { + // [START compute_v1_generated_Interconnects_Get_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. + */ + /** + * Name of the interconnect to return. + */ + // const interconnect = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {InterconnectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InterconnectsClient(); + + async function callGet() { + // Construct request + const request = { + interconnect, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Interconnects_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.get_diagnostics.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.get_diagnostics.js new file mode 100644 index 00000000000..6a410ab82f1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.get_diagnostics.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(interconnect, project) { + // [START compute_v1_generated_Interconnects_GetDiagnostics_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. + */ + /** + * Name of the interconnect resource to query. + */ + // const interconnect = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {InterconnectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InterconnectsClient(); + + async function callGetDiagnostics() { + // Construct request + const request = { + interconnect, + project, + }; + + // Run request + const response = await computeClient.getDiagnostics(request); + console.log(response); + } + + callGetDiagnostics(); + // [END compute_v1_generated_Interconnects_GetDiagnostics_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.insert.js new file mode 100644 index 00000000000..8bf64960eb1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(interconnectResource, project) { + // [START compute_v1_generated_Interconnects_Insert_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. + */ + /** + * The body resource for this request + */ + // const interconnectResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {InterconnectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InterconnectsClient(); + + async function callInsert() { + // Construct request + const request = { + interconnectResource, + project, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_Interconnects_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.list.js new file mode 100644 index 00000000000..4e622068c98 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Interconnects_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {InterconnectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InterconnectsClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_Interconnects_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.patch.js new file mode 100644 index 00000000000..f2a500a5983 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(interconnect, interconnectResource, project) { + // [START compute_v1_generated_Interconnects_Patch_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. + */ + /** + * Name of the interconnect to update. + */ + // const interconnect = 'abc123' + /** + * The body resource for this request + */ + // const interconnectResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {InterconnectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InterconnectsClient(); + + async function callPatch() { + // Construct request + const request = { + interconnect, + interconnectResource, + project, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_Interconnects_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.set_labels.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.set_labels.js new file mode 100644 index 00000000000..125356ee1fd --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/interconnects.set_labels.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(globalSetLabelsRequestResource, project, resource) { + // [START compute_v1_generated_Interconnects_SetLabels_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. + */ + /** + * The body resource for this request + */ + // const globalSetLabelsRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {InterconnectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new InterconnectsClient(); + + async function callSetLabels() { + // Construct request + const request = { + globalSetLabelsRequestResource, + project, + resource, + }; + + // Run request + const response = await computeClient.setLabels(request); + console.log(response); + } + + callSetLabels(); + // [END compute_v1_generated_Interconnects_SetLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/license_codes.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/license_codes.get.js new file mode 100644 index 00000000000..c50f51c87d3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/license_codes.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(licenseCode, project) { + // [START compute_v1_generated_LicenseCodes_Get_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. + */ + /** + * Number corresponding to the License code resource to return. + */ + // const licenseCode = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {LicenseCodesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new LicenseCodesClient(); + + async function callGet() { + // Construct request + const request = { + licenseCode, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_LicenseCodes_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/license_codes.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/license_codes.test_iam_permissions.js new file mode 100644 index 00000000000..4d55ca03e0c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/license_codes.test_iam_permissions.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_LicenseCodes_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {LicenseCodesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new LicenseCodesClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_LicenseCodes_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.delete.js new file mode 100644 index 00000000000..7398fc1d5ef --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(license, project) { + // [START compute_v1_generated_Licenses_Delete_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. + */ + /** + * Name of the license resource to delete. + */ + // const license = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {LicensesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new LicensesClient(); + + async function callDelete() { + // Construct request + const request = { + license, + project, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_Licenses_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.get.js new file mode 100644 index 00000000000..73cdbc66c4f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(license, project) { + // [START compute_v1_generated_Licenses_Get_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. + */ + /** + * Name of the License resource to return. + */ + // const license = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {LicensesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new LicensesClient(); + + async function callGet() { + // Construct request + const request = { + license, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Licenses_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.get_iam_policy.js new file mode 100644 index 00000000000..5f91e7e8ce2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.get_iam_policy.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, resource) { + // [START compute_v1_generated_Licenses_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {LicensesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new LicensesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + resource, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_Licenses_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.insert.js new file mode 100644 index 00000000000..01a47fbad08 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(licenseResource, project) { + // [START compute_v1_generated_Licenses_Insert_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. + */ + /** + * The body resource for this request + */ + // const licenseResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {LicensesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new LicensesClient(); + + async function callInsert() { + // Construct request + const request = { + licenseResource, + project, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_Licenses_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.list.js new file mode 100644 index 00000000000..38542b1feca --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Licenses_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {LicensesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new LicensesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_Licenses_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.set_iam_policy.js new file mode 100644 index 00000000000..7de335aedbe --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.set_iam_policy.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(globalSetPolicyRequestResource, project, resource) { + // [START compute_v1_generated_Licenses_SetIamPolicy_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. + */ + /** + * The body resource for this request + */ + // const globalSetPolicyRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {LicensesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new LicensesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + globalSetPolicyRequestResource, + project, + resource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_Licenses_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.test_iam_permissions.js new file mode 100644 index 00000000000..a236c524aef --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/licenses.test_iam_permissions.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_Licenses_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {LicensesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new LicensesClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_Licenses_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.delete.js new file mode 100644 index 00000000000..6e69910c848 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(machineImage, project) { + // [START compute_v1_generated_MachineImages_Delete_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. + */ + /** + * The name of the machine image to delete. + */ + // const machineImage = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {MachineImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new MachineImagesClient(); + + async function callDelete() { + // Construct request + const request = { + machineImage, + project, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_MachineImages_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.get.js new file mode 100644 index 00000000000..8a96fcd0305 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(machineImage, project) { + // [START compute_v1_generated_MachineImages_Get_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. + */ + /** + * The name of the machine image. + */ + // const machineImage = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {MachineImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new MachineImagesClient(); + + async function callGet() { + // Construct request + const request = { + machineImage, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_MachineImages_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.get_iam_policy.js new file mode 100644 index 00000000000..da483cf4918 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.get_iam_policy.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, resource) { + // [START compute_v1_generated_MachineImages_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {MachineImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new MachineImagesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + resource, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_MachineImages_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.insert.js new file mode 100644 index 00000000000..53c664d8901 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.insert.js @@ -0,0 +1,74 @@ +// Copyright 2023 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(machineImageResource, project) { + // [START compute_v1_generated_MachineImages_Insert_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. + */ + /** + * The body resource for this request + */ + // const machineImageResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Required. Source instance that is used to create the machine image from. + */ + // const sourceInstance = 'abc123' + + // Imports the Compute library + const {MachineImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new MachineImagesClient(); + + async function callInsert() { + // Construct request + const request = { + machineImageResource, + project, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_MachineImages_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.list.js new file mode 100644 index 00000000000..a049224bb76 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_MachineImages_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {MachineImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new MachineImagesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_MachineImages_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.set_iam_policy.js new file mode 100644 index 00000000000..baed5ef441e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.set_iam_policy.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(globalSetPolicyRequestResource, project, resource) { + // [START compute_v1_generated_MachineImages_SetIamPolicy_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. + */ + /** + * The body resource for this request + */ + // const globalSetPolicyRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {MachineImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new MachineImagesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + globalSetPolicyRequestResource, + project, + resource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_MachineImages_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.test_iam_permissions.js new file mode 100644 index 00000000000..4dc29d72570 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_images.test_iam_permissions.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_MachineImages_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {MachineImagesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new MachineImagesClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_MachineImages_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_types.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_types.aggregated_list.js new file mode 100644 index 00000000000..53d440ad249 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_types.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_MachineTypes_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {MachineTypesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new MachineTypesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_MachineTypes_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_types.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_types.get.js new file mode 100644 index 00000000000..25e262a214f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_types.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(machineType, project, zone) { + // [START compute_v1_generated_MachineTypes_Get_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. + */ + /** + * Name of the machine type to return. + */ + // const machineType = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {MachineTypesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new MachineTypesClient(); + + async function callGet() { + // Construct request + const request = { + machineType, + project, + zone, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_MachineTypes_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_types.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_types.list.js new file mode 100644 index 00000000000..7cb248947aa --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/machine_types.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, zone) { + // [START compute_v1_generated_MachineTypes_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {MachineTypesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new MachineTypesClient(); + + async function callList() { + // Construct request + const request = { + project, + zone, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_MachineTypes_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.aggregated_list.js new file mode 100644 index 00000000000..1b382428a14 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_NetworkAttachments_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {NetworkAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkAttachmentsClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_NetworkAttachments_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.delete.js new file mode 100644 index 00000000000..7819451cfcb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(networkAttachment, project, region) { + // [START compute_v1_generated_NetworkAttachments_Delete_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. + */ + /** + * Name of the NetworkAttachment resource to delete. + */ + // const networkAttachment = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region of this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). end_interface: MixerMutationRequestBuilder + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworkAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkAttachmentsClient(); + + async function callDelete() { + // Construct request + const request = { + networkAttachment, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_NetworkAttachments_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.get.js new file mode 100644 index 00000000000..a283d9ce2ef --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(networkAttachment, project, region) { + // [START compute_v1_generated_NetworkAttachments_Get_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. + */ + /** + * Name of the NetworkAttachment resource to return. + */ + // const networkAttachment = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region of this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {NetworkAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkAttachmentsClient(); + + async function callGet() { + // Construct request + const request = { + networkAttachment, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_NetworkAttachments_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.get_iam_policy.js new file mode 100644 index 00000000000..68c27604c7d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.get_iam_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, resource) { + // [START compute_v1_generated_NetworkAttachments_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {NetworkAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkAttachmentsClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + region, + resource, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_NetworkAttachments_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.insert.js new file mode 100644 index 00000000000..7e0a811f7db --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(networkAttachmentResource, project, region) { + // [START compute_v1_generated_NetworkAttachments_Insert_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. + */ + /** + * The body resource for this request + */ + // const networkAttachmentResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region of this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). end_interface: MixerMutationRequestBuilder + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworkAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkAttachmentsClient(); + + async function callInsert() { + // Construct request + const request = { + networkAttachmentResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_NetworkAttachments_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.list.js new file mode 100644 index 00000000000..b1dd9d0c068 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_NetworkAttachments_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region of this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {NetworkAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkAttachmentsClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_NetworkAttachments_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.set_iam_policy.js new file mode 100644 index 00000000000..24d4339061e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.set_iam_policy.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, regionSetPolicyRequestResource, resource) { + // [START compute_v1_generated_NetworkAttachments_SetIamPolicy_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionSetPolicyRequestResource = {} + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {NetworkAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkAttachmentsClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + project, + region, + regionSetPolicyRequestResource, + resource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_NetworkAttachments_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.test_iam_permissions.js new file mode 100644 index 00000000000..9a49b4fc4a9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_attachments.test_iam_permissions.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_NetworkAttachments_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {NetworkAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkAttachmentsClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + region, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_NetworkAttachments_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_edge_security_services.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_edge_security_services.aggregated_list.js new file mode 100644 index 00000000000..d2ce10d0fa1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_edge_security_services.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_NetworkEdgeSecurityServices_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Name of the project scoping this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {NetworkEdgeSecurityServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkEdgeSecurityServicesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_NetworkEdgeSecurityServices_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_edge_security_services.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_edge_security_services.delete.js new file mode 100644 index 00000000000..6391b2fa7fc --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_edge_security_services.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(networkEdgeSecurityService, project, region) { + // [START compute_v1_generated_NetworkEdgeSecurityServices_Delete_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. + */ + /** + * Name of the network edge security service to delete. + */ + // const networkEdgeSecurityService = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworkEdgeSecurityServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkEdgeSecurityServicesClient(); + + async function callDelete() { + // Construct request + const request = { + networkEdgeSecurityService, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_NetworkEdgeSecurityServices_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_edge_security_services.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_edge_security_services.get.js new file mode 100644 index 00000000000..806d33c1e83 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_edge_security_services.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(networkEdgeSecurityService, project, region) { + // [START compute_v1_generated_NetworkEdgeSecurityServices_Get_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. + */ + /** + * Name of the network edge security service to get. + */ + // const networkEdgeSecurityService = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {NetworkEdgeSecurityServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkEdgeSecurityServicesClient(); + + async function callGet() { + // Construct request + const request = { + networkEdgeSecurityService, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_NetworkEdgeSecurityServices_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_edge_security_services.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_edge_security_services.insert.js new file mode 100644 index 00000000000..1223215acd1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_edge_security_services.insert.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(networkEdgeSecurityServiceResource, project, region) { + // [START compute_v1_generated_NetworkEdgeSecurityServices_Insert_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. + */ + /** + * The body resource for this request + */ + // const networkEdgeSecurityServiceResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * If true, the request will not be committed. + */ + // const validateOnly = true + + // Imports the Compute library + const {NetworkEdgeSecurityServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkEdgeSecurityServicesClient(); + + async function callInsert() { + // Construct request + const request = { + networkEdgeSecurityServiceResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_NetworkEdgeSecurityServices_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_edge_security_services.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_edge_security_services.patch.js new file mode 100644 index 00000000000..fbd80c6cb57 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_edge_security_services.patch.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(networkEdgeSecurityService, networkEdgeSecurityServiceResource, project, region) { + // [START compute_v1_generated_NetworkEdgeSecurityServices_Patch_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. + */ + /** + * Name of the network edge security service to update. + */ + // const networkEdgeSecurityService = 'abc123' + /** + * The body resource for this request + */ + // const networkEdgeSecurityServiceResource = {} + /** + */ + // const paths = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Indicates fields to be updated as part of this request. + */ + // const updateMask = 'abc123' + + // Imports the Compute library + const {NetworkEdgeSecurityServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkEdgeSecurityServicesClient(); + + async function callPatch() { + // Construct request + const request = { + networkEdgeSecurityService, + networkEdgeSecurityServiceResource, + project, + region, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_NetworkEdgeSecurityServices_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.aggregated_list.js new file mode 100644 index 00000000000..c7d468163fd --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_NetworkEndpointGroups_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {NetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkEndpointGroupsClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_NetworkEndpointGroups_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.attach_network_endpoints.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.attach_network_endpoints.js new file mode 100644 index 00000000000..7d18e81a674 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.attach_network_endpoints.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(networkEndpointGroup, networkEndpointGroupsAttachEndpointsRequestResource, project, zone) { + // [START compute_v1_generated_NetworkEndpointGroups_AttachNetworkEndpoints_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. + */ + /** + * The name of the network endpoint group where you are attaching network endpoints to. It should comply with RFC1035. + */ + // const networkEndpointGroup = 'abc123' + /** + * The body resource for this request + */ + // const networkEndpointGroupsAttachEndpointsRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where the network endpoint group is located. It should comply with RFC1035. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkEndpointGroupsClient(); + + async function callAttachNetworkEndpoints() { + // Construct request + const request = { + networkEndpointGroup, + networkEndpointGroupsAttachEndpointsRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.attachNetworkEndpoints(request); + console.log(response); + } + + callAttachNetworkEndpoints(); + // [END compute_v1_generated_NetworkEndpointGroups_AttachNetworkEndpoints_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.delete.js new file mode 100644 index 00000000000..9126c0cfc6e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(networkEndpointGroup, project, zone) { + // [START compute_v1_generated_NetworkEndpointGroups_Delete_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. + */ + /** + * The name of the network endpoint group to delete. It should comply with RFC1035. + */ + // const networkEndpointGroup = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where the network endpoint group is located. It should comply with RFC1035. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkEndpointGroupsClient(); + + async function callDelete() { + // Construct request + const request = { + networkEndpointGroup, + project, + zone, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_NetworkEndpointGroups_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.detach_network_endpoints.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.detach_network_endpoints.js new file mode 100644 index 00000000000..2bd0de4fec7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.detach_network_endpoints.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(networkEndpointGroup, networkEndpointGroupsDetachEndpointsRequestResource, project, zone) { + // [START compute_v1_generated_NetworkEndpointGroups_DetachNetworkEndpoints_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. + */ + /** + * The name of the network endpoint group where you are removing network endpoints. It should comply with RFC1035. + */ + // const networkEndpointGroup = 'abc123' + /** + * The body resource for this request + */ + // const networkEndpointGroupsDetachEndpointsRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where the network endpoint group is located. It should comply with RFC1035. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkEndpointGroupsClient(); + + async function callDetachNetworkEndpoints() { + // Construct request + const request = { + networkEndpointGroup, + networkEndpointGroupsDetachEndpointsRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.detachNetworkEndpoints(request); + console.log(response); + } + + callDetachNetworkEndpoints(); + // [END compute_v1_generated_NetworkEndpointGroups_DetachNetworkEndpoints_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.get.js new file mode 100644 index 00000000000..56f990510de --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(networkEndpointGroup, project, zone) { + // [START compute_v1_generated_NetworkEndpointGroups_Get_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. + */ + /** + * The name of the network endpoint group. It should comply with RFC1035. + */ + // const networkEndpointGroup = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone where the network endpoint group is located. It should comply with RFC1035. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkEndpointGroupsClient(); + + async function callGet() { + // Construct request + const request = { + networkEndpointGroup, + project, + zone, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_NetworkEndpointGroups_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.insert.js new file mode 100644 index 00000000000..3fd49095b25 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(networkEndpointGroupResource, project, zone) { + // [START compute_v1_generated_NetworkEndpointGroups_Insert_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. + */ + /** + * The body resource for this request + */ + // const networkEndpointGroupResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone where you want to create the network endpoint group. It should comply with RFC1035. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkEndpointGroupsClient(); + + async function callInsert() { + // Construct request + const request = { + networkEndpointGroupResource, + project, + zone, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_NetworkEndpointGroups_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.list.js new file mode 100644 index 00000000000..8f6b3712e19 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, zone) { + // [START compute_v1_generated_NetworkEndpointGroups_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone where the network endpoint group is located. It should comply with RFC1035. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkEndpointGroupsClient(); + + async function callList() { + // Construct request + const request = { + project, + zone, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_NetworkEndpointGroups_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.list_network_endpoints.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.list_network_endpoints.js new file mode 100644 index 00000000000..200f09e3b7f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.list_network_endpoints.js @@ -0,0 +1,98 @@ +// Copyright 2023 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(networkEndpointGroup, networkEndpointGroupsListEndpointsRequestResource, project, zone) { + // [START compute_v1_generated_NetworkEndpointGroups_ListNetworkEndpoints_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * The name of the network endpoint group from which you want to generate a list of included network endpoints. It should comply with RFC1035. + */ + // const networkEndpointGroup = 'abc123' + /** + * The body resource for this request + */ + // const networkEndpointGroupsListEndpointsRequestResource = {} + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone where the network endpoint group is located. It should comply with RFC1035. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkEndpointGroupsClient(); + + async function callListNetworkEndpoints() { + // Construct request + const request = { + networkEndpointGroup, + networkEndpointGroupsListEndpointsRequestResource, + project, + zone, + }; + + // Run request + const iterable = await computeClient.listNetworkEndpointsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListNetworkEndpoints(); + // [END compute_v1_generated_NetworkEndpointGroups_ListNetworkEndpoints_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.test_iam_permissions.js new file mode 100644 index 00000000000..0315d9e73a8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_endpoint_groups.test_iam_permissions.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, resource, testPermissionsRequestResource, zone) { + // [START compute_v1_generated_NetworkEndpointGroups_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkEndpointGroupsClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + resource, + testPermissionsRequestResource, + zone, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_NetworkEndpointGroups_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.add_association.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.add_association.js new file mode 100644 index 00000000000..cf7fb421a72 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.add_association.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(firewallPolicy, firewallPolicyAssociationResource, project) { + // [START compute_v1_generated_NetworkFirewallPolicies_AddAssociation_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * The body resource for this request + */ + // const firewallPolicyAssociationResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Indicates whether or not to replace it if an association of the attachment already exists. This is false by default, in which case an error will be returned if an association already exists. + */ + // const replaceExistingAssociation = true + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkFirewallPoliciesClient(); + + async function callAddAssociation() { + // Construct request + const request = { + firewallPolicy, + firewallPolicyAssociationResource, + project, + }; + + // Run request + const response = await computeClient.addAssociation(request); + console.log(response); + } + + callAddAssociation(); + // [END compute_v1_generated_NetworkFirewallPolicies_AddAssociation_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.add_rule.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.add_rule.js new file mode 100644 index 00000000000..bca685672b8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.add_rule.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(firewallPolicy, firewallPolicyRuleResource, project) { + // [START compute_v1_generated_NetworkFirewallPolicies_AddRule_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * The body resource for this request + */ + // const firewallPolicyRuleResource = {} + /** + * When rule.priority is not specified, auto choose a unused priority between minPriority and maxPriority>. This field is exclusive with rule.priority. + */ + // const maxPriority = 1234 + /** + * When rule.priority is not specified, auto choose a unused priority between minPriority and maxPriority>. This field is exclusive with rule.priority. + */ + // const minPriority = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkFirewallPoliciesClient(); + + async function callAddRule() { + // Construct request + const request = { + firewallPolicy, + firewallPolicyRuleResource, + project, + }; + + // Run request + const response = await computeClient.addRule(request); + console.log(response); + } + + callAddRule(); + // [END compute_v1_generated_NetworkFirewallPolicies_AddRule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.clone_rules.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.clone_rules.js new file mode 100644 index 00000000000..5176a7ca005 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.clone_rules.js @@ -0,0 +1,74 @@ +// Copyright 2023 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(firewallPolicy, project) { + // [START compute_v1_generated_NetworkFirewallPolicies_CloneRules_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The firewall policy from which to copy rules. + */ + // const sourceFirewallPolicy = 'abc123' + + // Imports the Compute library + const {NetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkFirewallPoliciesClient(); + + async function callCloneRules() { + // Construct request + const request = { + firewallPolicy, + project, + }; + + // Run request + const response = await computeClient.cloneRules(request); + console.log(response); + } + + callCloneRules(); + // [END compute_v1_generated_NetworkFirewallPolicies_CloneRules_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.delete.js new file mode 100644 index 00000000000..4586dbcd1a4 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(firewallPolicy, project) { + // [START compute_v1_generated_NetworkFirewallPolicies_Delete_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. + */ + /** + * Name of the firewall policy to delete. + */ + // const firewallPolicy = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkFirewallPoliciesClient(); + + async function callDelete() { + // Construct request + const request = { + firewallPolicy, + project, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_NetworkFirewallPolicies_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.get.js new file mode 100644 index 00000000000..20d68575fdc --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(firewallPolicy, project) { + // [START compute_v1_generated_NetworkFirewallPolicies_Get_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. + */ + /** + * Name of the firewall policy to get. + */ + // const firewallPolicy = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {NetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkFirewallPoliciesClient(); + + async function callGet() { + // Construct request + const request = { + firewallPolicy, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_NetworkFirewallPolicies_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.get_association.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.get_association.js new file mode 100644 index 00000000000..09c52db254d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.get_association.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(firewallPolicy, project) { + // [START compute_v1_generated_NetworkFirewallPolicies_GetAssociation_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. + */ + /** + * Name of the firewall policy to which the queried association belongs. + */ + // const firewallPolicy = 'abc123' + /** + * The name of the association to get from the firewall policy. + */ + // const name = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {NetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkFirewallPoliciesClient(); + + async function callGetAssociation() { + // Construct request + const request = { + firewallPolicy, + project, + }; + + // Run request + const response = await computeClient.getAssociation(request); + console.log(response); + } + + callGetAssociation(); + // [END compute_v1_generated_NetworkFirewallPolicies_GetAssociation_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.get_iam_policy.js new file mode 100644 index 00000000000..74a41a6f3b0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.get_iam_policy.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, resource) { + // [START compute_v1_generated_NetworkFirewallPolicies_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {NetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkFirewallPoliciesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + resource, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_NetworkFirewallPolicies_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.get_rule.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.get_rule.js new file mode 100644 index 00000000000..2889975f9f3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.get_rule.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(firewallPolicy, project) { + // [START compute_v1_generated_NetworkFirewallPolicies_GetRule_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. + */ + /** + * Name of the firewall policy to which the queried rule belongs. + */ + // const firewallPolicy = 'abc123' + /** + * The priority of the rule to get from the firewall policy. + */ + // const priority = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {NetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkFirewallPoliciesClient(); + + async function callGetRule() { + // Construct request + const request = { + firewallPolicy, + project, + }; + + // Run request + const response = await computeClient.getRule(request); + console.log(response); + } + + callGetRule(); + // [END compute_v1_generated_NetworkFirewallPolicies_GetRule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.insert.js new file mode 100644 index 00000000000..4b6d0f424fc --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(firewallPolicyResource, project) { + // [START compute_v1_generated_NetworkFirewallPolicies_Insert_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. + */ + /** + * The body resource for this request + */ + // const firewallPolicyResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkFirewallPoliciesClient(); + + async function callInsert() { + // Construct request + const request = { + firewallPolicyResource, + project, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_NetworkFirewallPolicies_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.list.js new file mode 100644 index 00000000000..94321227905 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_NetworkFirewallPolicies_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {NetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkFirewallPoliciesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_NetworkFirewallPolicies_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.patch.js new file mode 100644 index 00000000000..7c2382bfe2b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(firewallPolicy, firewallPolicyResource, project) { + // [START compute_v1_generated_NetworkFirewallPolicies_Patch_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * The body resource for this request + */ + // const firewallPolicyResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkFirewallPoliciesClient(); + + async function callPatch() { + // Construct request + const request = { + firewallPolicy, + firewallPolicyResource, + project, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_NetworkFirewallPolicies_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.patch_rule.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.patch_rule.js new file mode 100644 index 00000000000..5bfe6df5f7f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.patch_rule.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(firewallPolicy, firewallPolicyRuleResource, project) { + // [START compute_v1_generated_NetworkFirewallPolicies_PatchRule_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * The body resource for this request + */ + // const firewallPolicyRuleResource = {} + /** + * The priority of the rule to patch. + */ + // const priority = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkFirewallPoliciesClient(); + + async function callPatchRule() { + // Construct request + const request = { + firewallPolicy, + firewallPolicyRuleResource, + project, + }; + + // Run request + const response = await computeClient.patchRule(request); + console.log(response); + } + + callPatchRule(); + // [END compute_v1_generated_NetworkFirewallPolicies_PatchRule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.remove_association.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.remove_association.js new file mode 100644 index 00000000000..dd631bee4a7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.remove_association.js @@ -0,0 +1,74 @@ +// Copyright 2023 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(firewallPolicy, project) { + // [START compute_v1_generated_NetworkFirewallPolicies_RemoveAssociation_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * Name for the attachment that will be removed. + */ + // const name = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkFirewallPoliciesClient(); + + async function callRemoveAssociation() { + // Construct request + const request = { + firewallPolicy, + project, + }; + + // Run request + const response = await computeClient.removeAssociation(request); + console.log(response); + } + + callRemoveAssociation(); + // [END compute_v1_generated_NetworkFirewallPolicies_RemoveAssociation_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.remove_rule.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.remove_rule.js new file mode 100644 index 00000000000..0495506c536 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.remove_rule.js @@ -0,0 +1,74 @@ +// Copyright 2023 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(firewallPolicy, project) { + // [START compute_v1_generated_NetworkFirewallPolicies_RemoveRule_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * The priority of the rule to remove from the firewall policy. + */ + // const priority = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkFirewallPoliciesClient(); + + async function callRemoveRule() { + // Construct request + const request = { + firewallPolicy, + project, + }; + + // Run request + const response = await computeClient.removeRule(request); + console.log(response); + } + + callRemoveRule(); + // [END compute_v1_generated_NetworkFirewallPolicies_RemoveRule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.set_iam_policy.js new file mode 100644 index 00000000000..4255710ad3f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.set_iam_policy.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(globalSetPolicyRequestResource, project, resource) { + // [START compute_v1_generated_NetworkFirewallPolicies_SetIamPolicy_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. + */ + /** + * The body resource for this request + */ + // const globalSetPolicyRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {NetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkFirewallPoliciesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + globalSetPolicyRequestResource, + project, + resource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_NetworkFirewallPolicies_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.test_iam_permissions.js new file mode 100644 index 00000000000..5b09a48a2db --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/network_firewall_policies.test_iam_permissions.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_NetworkFirewallPolicies_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {NetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworkFirewallPoliciesClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_NetworkFirewallPolicies_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.add_peering.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.add_peering.js new file mode 100644 index 00000000000..67df1b02d42 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.add_peering.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(network, networksAddPeeringRequestResource, project) { + // [START compute_v1_generated_Networks_AddPeering_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. + */ + /** + * Name of the network resource to add peering to. + */ + // const network = 'abc123' + /** + * The body resource for this request + */ + // const networksAddPeeringRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworksClient(); + + async function callAddPeering() { + // Construct request + const request = { + network, + networksAddPeeringRequestResource, + project, + }; + + // Run request + const response = await computeClient.addPeering(request); + console.log(response); + } + + callAddPeering(); + // [END compute_v1_generated_Networks_AddPeering_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.delete.js new file mode 100644 index 00000000000..49ed84bcd65 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(network, project) { + // [START compute_v1_generated_Networks_Delete_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. + */ + /** + * Name of the network to delete. + */ + // const network = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworksClient(); + + async function callDelete() { + // Construct request + const request = { + network, + project, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_Networks_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.get.js new file mode 100644 index 00000000000..be5c7b183a3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(network, project) { + // [START compute_v1_generated_Networks_Get_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. + */ + /** + * Name of the network to return. + */ + // const network = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {NetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworksClient(); + + async function callGet() { + // Construct request + const request = { + network, + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Networks_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.get_effective_firewalls.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.get_effective_firewalls.js new file mode 100644 index 00000000000..e9fa19d514d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.get_effective_firewalls.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(network, project) { + // [START compute_v1_generated_Networks_GetEffectiveFirewalls_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. + */ + /** + * Name of the network for this request. + */ + // const network = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {NetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworksClient(); + + async function callGetEffectiveFirewalls() { + // Construct request + const request = { + network, + project, + }; + + // Run request + const response = await computeClient.getEffectiveFirewalls(request); + console.log(response); + } + + callGetEffectiveFirewalls(); + // [END compute_v1_generated_Networks_GetEffectiveFirewalls_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.insert.js new file mode 100644 index 00000000000..9934236c168 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(networkResource, project) { + // [START compute_v1_generated_Networks_Insert_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. + */ + /** + * The body resource for this request + */ + // const networkResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworksClient(); + + async function callInsert() { + // Construct request + const request = { + networkResource, + project, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_Networks_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.list.js new file mode 100644 index 00000000000..134613c21ab --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Networks_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {NetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworksClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_Networks_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.list_peering_routes.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.list_peering_routes.js new file mode 100644 index 00000000000..f08f392c9d6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.list_peering_routes.js @@ -0,0 +1,101 @@ +// Copyright 2023 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(network, project) { + // [START compute_v1_generated_Networks_ListPeeringRoutes_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. + */ + /** + * The direction of the exchanged routes. + * Check the Direction enum for the list of possible values. + */ + // const direction = 'abc123' + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Name of the network for this request. + */ + // const network = 'abc123' + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * The response will show routes exchanged over the given peering connection. + */ + // const peeringName = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The region of the request. The response will include all subnet routes, static routes and dynamic routes in the region. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {NetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworksClient(); + + async function callListPeeringRoutes() { + // Construct request + const request = { + network, + project, + }; + + // Run request + const iterable = await computeClient.listPeeringRoutesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListPeeringRoutes(); + // [END compute_v1_generated_Networks_ListPeeringRoutes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.patch.js new file mode 100644 index 00000000000..67c80816fb9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(network, networkResource, project) { + // [START compute_v1_generated_Networks_Patch_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. + */ + /** + * Name of the network to update. + */ + // const network = 'abc123' + /** + * The body resource for this request + */ + // const networkResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworksClient(); + + async function callPatch() { + // Construct request + const request = { + network, + networkResource, + project, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_Networks_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.remove_peering.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.remove_peering.js new file mode 100644 index 00000000000..077857a7ec5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.remove_peering.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(network, networksRemovePeeringRequestResource, project) { + // [START compute_v1_generated_Networks_RemovePeering_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. + */ + /** + * Name of the network resource to remove peering from. + */ + // const network = 'abc123' + /** + * The body resource for this request + */ + // const networksRemovePeeringRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworksClient(); + + async function callRemovePeering() { + // Construct request + const request = { + network, + networksRemovePeeringRequestResource, + project, + }; + + // Run request + const response = await computeClient.removePeering(request); + console.log(response); + } + + callRemovePeering(); + // [END compute_v1_generated_Networks_RemovePeering_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.switch_to_custom_mode.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.switch_to_custom_mode.js new file mode 100644 index 00000000000..d037594a481 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.switch_to_custom_mode.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(network, project) { + // [START compute_v1_generated_Networks_SwitchToCustomMode_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. + */ + /** + * Name of the network to be updated. + */ + // const network = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworksClient(); + + async function callSwitchToCustomMode() { + // Construct request + const request = { + network, + project, + }; + + // Run request + const response = await computeClient.switchToCustomMode(request); + console.log(response); + } + + callSwitchToCustomMode(); + // [END compute_v1_generated_Networks_SwitchToCustomMode_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.update_peering.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.update_peering.js new file mode 100644 index 00000000000..22bc3052ddb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/networks.update_peering.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(network, networksUpdatePeeringRequestResource, project) { + // [START compute_v1_generated_Networks_UpdatePeering_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. + */ + /** + * Name of the network resource which the updated peering is belonging to. + */ + // const network = 'abc123' + /** + * The body resource for this request + */ + // const networksUpdatePeeringRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NetworksClient(); + + async function callUpdatePeering() { + // Construct request + const request = { + network, + networksUpdatePeeringRequestResource, + project, + }; + + // Run request + const response = await computeClient.updatePeering(request); + console.log(response); + } + + callUpdatePeering(); + // [END compute_v1_generated_Networks_UpdatePeering_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.add_nodes.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.add_nodes.js new file mode 100644 index 00000000000..11f1fa7c8c7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.add_nodes.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(nodeGroup, nodeGroupsAddNodesRequestResource, project, zone) { + // [START compute_v1_generated_NodeGroups_AddNodes_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. + */ + /** + * Name of the NodeGroup resource. + */ + // const nodeGroup = 'abc123' + /** + * The body resource for this request + */ + // const nodeGroupsAddNodesRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NodeGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeGroupsClient(); + + async function callAddNodes() { + // Construct request + const request = { + nodeGroup, + nodeGroupsAddNodesRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.addNodes(request); + console.log(response); + } + + callAddNodes(); + // [END compute_v1_generated_NodeGroups_AddNodes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.aggregated_list.js new file mode 100644 index 00000000000..0df994fcd17 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_NodeGroups_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {NodeGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeGroupsClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_NodeGroups_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.delete.js new file mode 100644 index 00000000000..e014e34c59e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(nodeGroup, project, zone) { + // [START compute_v1_generated_NodeGroups_Delete_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. + */ + /** + * Name of the NodeGroup resource to delete. + */ + // const nodeGroup = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NodeGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeGroupsClient(); + + async function callDelete() { + // Construct request + const request = { + nodeGroup, + project, + zone, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_NodeGroups_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.delete_nodes.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.delete_nodes.js new file mode 100644 index 00000000000..9bd959a974b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.delete_nodes.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(nodeGroup, nodeGroupsDeleteNodesRequestResource, project, zone) { + // [START compute_v1_generated_NodeGroups_DeleteNodes_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. + */ + /** + * Name of the NodeGroup resource whose nodes will be deleted. + */ + // const nodeGroup = 'abc123' + /** + * The body resource for this request + */ + // const nodeGroupsDeleteNodesRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NodeGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeGroupsClient(); + + async function callDeleteNodes() { + // Construct request + const request = { + nodeGroup, + nodeGroupsDeleteNodesRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.deleteNodes(request); + console.log(response); + } + + callDeleteNodes(); + // [END compute_v1_generated_NodeGroups_DeleteNodes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.get.js new file mode 100644 index 00000000000..910336b5a97 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(nodeGroup, project, zone) { + // [START compute_v1_generated_NodeGroups_Get_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. + */ + /** + * Name of the node group to return. + */ + // const nodeGroup = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NodeGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeGroupsClient(); + + async function callGet() { + // Construct request + const request = { + nodeGroup, + project, + zone, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_NodeGroups_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.get_iam_policy.js new file mode 100644 index 00000000000..d73f4018e5c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.get_iam_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, resource, zone) { + // [START compute_v1_generated_NodeGroups_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NodeGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeGroupsClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + resource, + zone, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_NodeGroups_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.insert.js new file mode 100644 index 00000000000..2e940e81cc2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.insert.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(initialNodeCount, nodeGroupResource, project, zone) { + // [START compute_v1_generated_NodeGroups_Insert_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. + */ + /** + * Initial count of nodes in the node group. + */ + // const initialNodeCount = 1234 + /** + * The body resource for this request + */ + // const nodeGroupResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NodeGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeGroupsClient(); + + async function callInsert() { + // Construct request + const request = { + initialNodeCount, + nodeGroupResource, + project, + zone, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_NodeGroups_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.list.js new file mode 100644 index 00000000000..df1dc7b3d0c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, zone) { + // [START compute_v1_generated_NodeGroups_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NodeGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeGroupsClient(); + + async function callList() { + // Construct request + const request = { + project, + zone, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_NodeGroups_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.list_nodes.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.list_nodes.js new file mode 100644 index 00000000000..60bbc5223df --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.list_nodes.js @@ -0,0 +1,93 @@ +// Copyright 2023 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(nodeGroup, project, zone) { + // [START compute_v1_generated_NodeGroups_ListNodes_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Name of the NodeGroup resource whose nodes you want to list. + */ + // const nodeGroup = 'abc123' + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NodeGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeGroupsClient(); + + async function callListNodes() { + // Construct request + const request = { + nodeGroup, + project, + zone, + }; + + // Run request + const iterable = await computeClient.listNodesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListNodes(); + // [END compute_v1_generated_NodeGroups_ListNodes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.patch.js new file mode 100644 index 00000000000..67195c67bca --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(nodeGroup, nodeGroupResource, project, zone) { + // [START compute_v1_generated_NodeGroups_Patch_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. + */ + /** + * Name of the NodeGroup resource to update. + */ + // const nodeGroup = 'abc123' + /** + * The body resource for this request + */ + // const nodeGroupResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NodeGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeGroupsClient(); + + async function callPatch() { + // Construct request + const request = { + nodeGroup, + nodeGroupResource, + project, + zone, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_NodeGroups_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.set_iam_policy.js new file mode 100644 index 00000000000..373d70e75d6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.set_iam_policy.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, resource, zone, zoneSetPolicyRequestResource) { + // [START compute_v1_generated_NodeGroups_SetIamPolicy_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + /** + * The body resource for this request + */ + // const zoneSetPolicyRequestResource = {} + + // Imports the Compute library + const {NodeGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeGroupsClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + project, + resource, + zone, + zoneSetPolicyRequestResource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_NodeGroups_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.set_node_template.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.set_node_template.js new file mode 100644 index 00000000000..8e8e3b949bb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.set_node_template.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(nodeGroup, nodeGroupsSetNodeTemplateRequestResource, project, zone) { + // [START compute_v1_generated_NodeGroups_SetNodeTemplate_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. + */ + /** + * Name of the NodeGroup resource to update. + */ + // const nodeGroup = 'abc123' + /** + * The body resource for this request + */ + // const nodeGroupsSetNodeTemplateRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NodeGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeGroupsClient(); + + async function callSetNodeTemplate() { + // Construct request + const request = { + nodeGroup, + nodeGroupsSetNodeTemplateRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.setNodeTemplate(request); + console.log(response); + } + + callSetNodeTemplate(); + // [END compute_v1_generated_NodeGroups_SetNodeTemplate_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.simulate_maintenance_event.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.simulate_maintenance_event.js new file mode 100644 index 00000000000..b7323b4e366 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.simulate_maintenance_event.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(nodeGroup, nodeGroupsSimulateMaintenanceEventRequestResource, project, zone) { + // [START compute_v1_generated_NodeGroups_SimulateMaintenanceEvent_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. + */ + /** + * Name of the NodeGroup resource whose nodes will go under maintenance simulation. + */ + // const nodeGroup = 'abc123' + /** + * The body resource for this request + */ + // const nodeGroupsSimulateMaintenanceEventRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NodeGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeGroupsClient(); + + async function callSimulateMaintenanceEvent() { + // Construct request + const request = { + nodeGroup, + nodeGroupsSimulateMaintenanceEventRequestResource, + project, + zone, + }; + + // Run request + const response = await computeClient.simulateMaintenanceEvent(request); + console.log(response); + } + + callSimulateMaintenanceEvent(); + // [END compute_v1_generated_NodeGroups_SimulateMaintenanceEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.test_iam_permissions.js new file mode 100644 index 00000000000..d548dec50e8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_groups.test_iam_permissions.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, resource, testPermissionsRequestResource, zone) { + // [START compute_v1_generated_NodeGroups_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NodeGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeGroupsClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + resource, + testPermissionsRequestResource, + zone, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_NodeGroups_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.aggregated_list.js new file mode 100644 index 00000000000..e01429cb55d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_NodeTemplates_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {NodeTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeTemplatesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_NodeTemplates_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.delete.js new file mode 100644 index 00000000000..62b732f580b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(nodeTemplate, project, region) { + // [START compute_v1_generated_NodeTemplates_Delete_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. + */ + /** + * Name of the NodeTemplate resource to delete. + */ + // const nodeTemplate = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NodeTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeTemplatesClient(); + + async function callDelete() { + // Construct request + const request = { + nodeTemplate, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_NodeTemplates_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.get.js new file mode 100644 index 00000000000..81968cbbd11 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(nodeTemplate, project, region) { + // [START compute_v1_generated_NodeTemplates_Get_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. + */ + /** + * Name of the node template to return. + */ + // const nodeTemplate = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {NodeTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeTemplatesClient(); + + async function callGet() { + // Construct request + const request = { + nodeTemplate, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_NodeTemplates_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.get_iam_policy.js new file mode 100644 index 00000000000..cd5f8a513b6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.get_iam_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, resource) { + // [START compute_v1_generated_NodeTemplates_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {NodeTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeTemplatesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + region, + resource, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_NodeTemplates_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.insert.js new file mode 100644 index 00000000000..0acb3d89996 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(nodeTemplateResource, project, region) { + // [START compute_v1_generated_NodeTemplates_Insert_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. + */ + /** + * The body resource for this request + */ + // const nodeTemplateResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {NodeTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeTemplatesClient(); + + async function callInsert() { + // Construct request + const request = { + nodeTemplateResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_NodeTemplates_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.list.js new file mode 100644 index 00000000000..60c3543bc71 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_NodeTemplates_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {NodeTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeTemplatesClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_NodeTemplates_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.set_iam_policy.js new file mode 100644 index 00000000000..2633a270f35 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.set_iam_policy.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, regionSetPolicyRequestResource, resource) { + // [START compute_v1_generated_NodeTemplates_SetIamPolicy_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionSetPolicyRequestResource = {} + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {NodeTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeTemplatesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + project, + region, + regionSetPolicyRequestResource, + resource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_NodeTemplates_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.test_iam_permissions.js new file mode 100644 index 00000000000..044393e2bdf --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_templates.test_iam_permissions.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_NodeTemplates_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {NodeTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeTemplatesClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + region, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_NodeTemplates_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_types.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_types.aggregated_list.js new file mode 100644 index 00000000000..121a53f6519 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_types.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_NodeTypes_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {NodeTypesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeTypesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_NodeTypes_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_types.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_types.get.js new file mode 100644 index 00000000000..08a2e9f83d4 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_types.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(nodeType, project, zone) { + // [START compute_v1_generated_NodeTypes_Get_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. + */ + /** + * Name of the node type to return. + */ + // const nodeType = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NodeTypesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeTypesClient(); + + async function callGet() { + // Construct request + const request = { + nodeType, + project, + zone, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_NodeTypes_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_types.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_types.list.js new file mode 100644 index 00000000000..f3ba321c35e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/node_types.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, zone) { + // [START compute_v1_generated_NodeTypes_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {NodeTypesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new NodeTypesClient(); + + async function callList() { + // Construct request + const request = { + project, + zone, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_NodeTypes_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.aggregated_list.js new file mode 100644 index 00000000000..3533b4903e2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_PacketMirrorings_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {PacketMirroringsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PacketMirroringsClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_PacketMirrorings_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.delete.js new file mode 100644 index 00000000000..51bec39d06f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(packetMirroring, project, region) { + // [START compute_v1_generated_PacketMirrorings_Delete_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. + */ + /** + * Name of the PacketMirroring resource to delete. + */ + // const packetMirroring = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {PacketMirroringsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PacketMirroringsClient(); + + async function callDelete() { + // Construct request + const request = { + packetMirroring, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_PacketMirrorings_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.get.js new file mode 100644 index 00000000000..54b978979a6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(packetMirroring, project, region) { + // [START compute_v1_generated_PacketMirrorings_Get_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. + */ + /** + * Name of the PacketMirroring resource to return. + */ + // const packetMirroring = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {PacketMirroringsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PacketMirroringsClient(); + + async function callGet() { + // Construct request + const request = { + packetMirroring, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_PacketMirrorings_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.insert.js new file mode 100644 index 00000000000..b70ff414ed3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(packetMirroringResource, project, region) { + // [START compute_v1_generated_PacketMirrorings_Insert_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. + */ + /** + * The body resource for this request + */ + // const packetMirroringResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {PacketMirroringsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PacketMirroringsClient(); + + async function callInsert() { + // Construct request + const request = { + packetMirroringResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_PacketMirrorings_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.list.js new file mode 100644 index 00000000000..8af5065f35d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_PacketMirrorings_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {PacketMirroringsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PacketMirroringsClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_PacketMirrorings_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.patch.js new file mode 100644 index 00000000000..442379f9178 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(packetMirroring, packetMirroringResource, project, region) { + // [START compute_v1_generated_PacketMirrorings_Patch_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. + */ + /** + * Name of the PacketMirroring resource to patch. + */ + // const packetMirroring = 'abc123' + /** + * The body resource for this request + */ + // const packetMirroringResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {PacketMirroringsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PacketMirroringsClient(); + + async function callPatch() { + // Construct request + const request = { + packetMirroring, + packetMirroringResource, + project, + region, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_PacketMirrorings_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.test_iam_permissions.js new file mode 100644 index 00000000000..a587cacecf2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/packet_mirrorings.test_iam_permissions.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_PacketMirrorings_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {PacketMirroringsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PacketMirroringsClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + region, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_PacketMirrorings_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.disable_xpn_host.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.disable_xpn_host.js new file mode 100644 index 00000000000..44e5e10befe --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.disable_xpn_host.js @@ -0,0 +1,65 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Projects_DisableXpnHost_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ProjectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ProjectsClient(); + + async function callDisableXpnHost() { + // Construct request + const request = { + project, + }; + + // Run request + const response = await computeClient.disableXpnHost(request); + console.log(response); + } + + callDisableXpnHost(); + // [END compute_v1_generated_Projects_DisableXpnHost_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.disable_xpn_resource.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.disable_xpn_resource.js new file mode 100644 index 00000000000..93c559128c3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.disable_xpn_resource.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, projectsDisableXpnResourceRequestResource) { + // [START compute_v1_generated_Projects_DisableXpnResource_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The body resource for this request + */ + // const projectsDisableXpnResourceRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ProjectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ProjectsClient(); + + async function callDisableXpnResource() { + // Construct request + const request = { + project, + projectsDisableXpnResourceRequestResource, + }; + + // Run request + const response = await computeClient.disableXpnResource(request); + console.log(response); + } + + callDisableXpnResource(); + // [END compute_v1_generated_Projects_DisableXpnResource_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.enable_xpn_host.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.enable_xpn_host.js new file mode 100644 index 00000000000..e155b09aac0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.enable_xpn_host.js @@ -0,0 +1,65 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Projects_EnableXpnHost_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ProjectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ProjectsClient(); + + async function callEnableXpnHost() { + // Construct request + const request = { + project, + }; + + // Run request + const response = await computeClient.enableXpnHost(request); + console.log(response); + } + + callEnableXpnHost(); + // [END compute_v1_generated_Projects_EnableXpnHost_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.enable_xpn_resource.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.enable_xpn_resource.js new file mode 100644 index 00000000000..d0b791dbd20 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.enable_xpn_resource.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, projectsEnableXpnResourceRequestResource) { + // [START compute_v1_generated_Projects_EnableXpnResource_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The body resource for this request + */ + // const projectsEnableXpnResourceRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ProjectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ProjectsClient(); + + async function callEnableXpnResource() { + // Construct request + const request = { + project, + projectsEnableXpnResourceRequestResource, + }; + + // Run request + const response = await computeClient.enableXpnResource(request); + console.log(response); + } + + callEnableXpnResource(); + // [END compute_v1_generated_Projects_EnableXpnResource_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.get.js new file mode 100644 index 00000000000..b754c5d7387 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.get.js @@ -0,0 +1,61 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Projects_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {ProjectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ProjectsClient(); + + async function callGet() { + // Construct request + const request = { + project, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Projects_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.get_xpn_host.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.get_xpn_host.js new file mode 100644 index 00000000000..2c8c8e2f4ce --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.get_xpn_host.js @@ -0,0 +1,61 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Projects_GetXpnHost_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {ProjectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ProjectsClient(); + + async function callGetXpnHost() { + // Construct request + const request = { + project, + }; + + // Run request + const response = await computeClient.getXpnHost(request); + console.log(response); + } + + callGetXpnHost(); + // [END compute_v1_generated_Projects_GetXpnHost_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.get_xpn_resources.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.get_xpn_resources.js new file mode 100644 index 00000000000..1c50f5d628d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.get_xpn_resources.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Projects_GetXpnResources_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {ProjectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ProjectsClient(); + + async function callGetXpnResources() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.getXpnResourcesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callGetXpnResources(); + // [END compute_v1_generated_Projects_GetXpnResources_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.list_xpn_hosts.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.list_xpn_hosts.js new file mode 100644 index 00000000000..b539454e2db --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.list_xpn_hosts.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, projectsListXpnHostsRequestResource) { + // [START compute_v1_generated_Projects_ListXpnHosts_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The body resource for this request + */ + // const projectsListXpnHostsRequestResource = {} + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {ProjectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ProjectsClient(); + + async function callListXpnHosts() { + // Construct request + const request = { + project, + projectsListXpnHostsRequestResource, + }; + + // Run request + const iterable = await computeClient.listXpnHostsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListXpnHosts(); + // [END compute_v1_generated_Projects_ListXpnHosts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.move_disk.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.move_disk.js new file mode 100644 index 00000000000..2342171ed63 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.move_disk.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(diskMoveRequestResource, project) { + // [START compute_v1_generated_Projects_MoveDisk_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. + */ + /** + * The body resource for this request + */ + // const diskMoveRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ProjectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ProjectsClient(); + + async function callMoveDisk() { + // Construct request + const request = { + diskMoveRequestResource, + project, + }; + + // Run request + const response = await computeClient.moveDisk(request); + console.log(response); + } + + callMoveDisk(); + // [END compute_v1_generated_Projects_MoveDisk_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.move_instance.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.move_instance.js new file mode 100644 index 00000000000..2ee9178e145 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.move_instance.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(instanceMoveRequestResource, project) { + // [START compute_v1_generated_Projects_MoveInstance_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. + */ + /** + * The body resource for this request + */ + // const instanceMoveRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ProjectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ProjectsClient(); + + async function callMoveInstance() { + // Construct request + const request = { + instanceMoveRequestResource, + project, + }; + + // Run request + const response = await computeClient.moveInstance(request); + console.log(response); + } + + callMoveInstance(); + // [END compute_v1_generated_Projects_MoveInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.set_common_instance_metadata.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.set_common_instance_metadata.js new file mode 100644 index 00000000000..2071245f3a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.set_common_instance_metadata.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(metadataResource, project) { + // [START compute_v1_generated_Projects_SetCommonInstanceMetadata_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. + */ + /** + * The body resource for this request + */ + // const metadataResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ProjectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ProjectsClient(); + + async function callSetCommonInstanceMetadata() { + // Construct request + const request = { + metadataResource, + project, + }; + + // Run request + const response = await computeClient.setCommonInstanceMetadata(request); + console.log(response); + } + + callSetCommonInstanceMetadata(); + // [END compute_v1_generated_Projects_SetCommonInstanceMetadata_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.set_default_network_tier.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.set_default_network_tier.js new file mode 100644 index 00000000000..025ad07fd70 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.set_default_network_tier.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, projectsSetDefaultNetworkTierRequestResource) { + // [START compute_v1_generated_Projects_SetDefaultNetworkTier_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The body resource for this request + */ + // const projectsSetDefaultNetworkTierRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {ProjectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ProjectsClient(); + + async function callSetDefaultNetworkTier() { + // Construct request + const request = { + project, + projectsSetDefaultNetworkTierRequestResource, + }; + + // Run request + const response = await computeClient.setDefaultNetworkTier(request); + console.log(response); + } + + callSetDefaultNetworkTier(); + // [END compute_v1_generated_Projects_SetDefaultNetworkTier_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.set_usage_export_bucket.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.set_usage_export_bucket.js new file mode 100644 index 00000000000..0eae72cac01 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/projects.set_usage_export_bucket.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, usageExportLocationResource) { + // [START compute_v1_generated_Projects_SetUsageExportBucket_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const usageExportLocationResource = {} + + // Imports the Compute library + const {ProjectsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ProjectsClient(); + + async function callSetUsageExportBucket() { + // Construct request + const request = { + project, + usageExportLocationResource, + }; + + // Run request + const response = await computeClient.setUsageExportBucket(request); + console.log(response); + } + + callSetUsageExportBucket(); + // [END compute_v1_generated_Projects_SetUsageExportBucket_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_advertised_prefixes.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_advertised_prefixes.delete.js new file mode 100644 index 00000000000..9789c883573 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_advertised_prefixes.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, publicAdvertisedPrefix) { + // [START compute_v1_generated_PublicAdvertisedPrefixes_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the PublicAdvertisedPrefix resource to delete. + */ + // const publicAdvertisedPrefix = 'abc123' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {PublicAdvertisedPrefixesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PublicAdvertisedPrefixesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + publicAdvertisedPrefix, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_PublicAdvertisedPrefixes_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_advertised_prefixes.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_advertised_prefixes.get.js new file mode 100644 index 00000000000..9b9968abe11 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_advertised_prefixes.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(project, publicAdvertisedPrefix) { + // [START compute_v1_generated_PublicAdvertisedPrefixes_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the PublicAdvertisedPrefix resource to return. + */ + // const publicAdvertisedPrefix = 'abc123' + + // Imports the Compute library + const {PublicAdvertisedPrefixesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PublicAdvertisedPrefixesClient(); + + async function callGet() { + // Construct request + const request = { + project, + publicAdvertisedPrefix, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_PublicAdvertisedPrefixes_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_advertised_prefixes.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_advertised_prefixes.insert.js new file mode 100644 index 00000000000..425a8e192b7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_advertised_prefixes.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, publicAdvertisedPrefixResource) { + // [START compute_v1_generated_PublicAdvertisedPrefixes_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The body resource for this request + */ + // const publicAdvertisedPrefixResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {PublicAdvertisedPrefixesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PublicAdvertisedPrefixesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + publicAdvertisedPrefixResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_PublicAdvertisedPrefixes_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_advertised_prefixes.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_advertised_prefixes.list.js new file mode 100644 index 00000000000..e0a211ae99a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_advertised_prefixes.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_PublicAdvertisedPrefixes_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {PublicAdvertisedPrefixesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PublicAdvertisedPrefixesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_PublicAdvertisedPrefixes_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_advertised_prefixes.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_advertised_prefixes.patch.js new file mode 100644 index 00000000000..f9d320bf1b9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_advertised_prefixes.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, publicAdvertisedPrefix, publicAdvertisedPrefixResource) { + // [START compute_v1_generated_PublicAdvertisedPrefixes_Patch_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the PublicAdvertisedPrefix resource to patch. + */ + // const publicAdvertisedPrefix = 'abc123' + /** + * The body resource for this request + */ + // const publicAdvertisedPrefixResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {PublicAdvertisedPrefixesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PublicAdvertisedPrefixesClient(); + + async function callPatch() { + // Construct request + const request = { + project, + publicAdvertisedPrefix, + publicAdvertisedPrefixResource, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_PublicAdvertisedPrefixes_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.aggregated_list.js new file mode 100644 index 00000000000..c4839dac05a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_PublicDelegatedPrefixes_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Name of the project scoping this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {PublicDelegatedPrefixesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PublicDelegatedPrefixesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_PublicDelegatedPrefixes_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.delete.js new file mode 100644 index 00000000000..1461c988ef3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, publicDelegatedPrefix, region) { + // [START compute_v1_generated_PublicDelegatedPrefixes_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the PublicDelegatedPrefix resource to delete. + */ + // const publicDelegatedPrefix = 'abc123' + /** + * Name of the region of this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {PublicDelegatedPrefixesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PublicDelegatedPrefixesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + publicDelegatedPrefix, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_PublicDelegatedPrefixes_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.get.js new file mode 100644 index 00000000000..a73874b2780 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, publicDelegatedPrefix, region) { + // [START compute_v1_generated_PublicDelegatedPrefixes_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the PublicDelegatedPrefix resource to return. + */ + // const publicDelegatedPrefix = 'abc123' + /** + * Name of the region of this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {PublicDelegatedPrefixesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PublicDelegatedPrefixesClient(); + + async function callGet() { + // Construct request + const request = { + project, + publicDelegatedPrefix, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_PublicDelegatedPrefixes_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.insert.js new file mode 100644 index 00000000000..8be3dfa3532 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, publicDelegatedPrefixResource, region) { + // [START compute_v1_generated_PublicDelegatedPrefixes_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The body resource for this request + */ + // const publicDelegatedPrefixResource = {} + /** + * Name of the region of this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {PublicDelegatedPrefixesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PublicDelegatedPrefixesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + publicDelegatedPrefixResource, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_PublicDelegatedPrefixes_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.list.js new file mode 100644 index 00000000000..8ec91366a41 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_PublicDelegatedPrefixes_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region of this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {PublicDelegatedPrefixesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PublicDelegatedPrefixesClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_PublicDelegatedPrefixes_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.patch.js new file mode 100644 index 00000000000..1a47fbde847 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/public_delegated_prefixes.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, publicDelegatedPrefix, publicDelegatedPrefixResource, region) { + // [START compute_v1_generated_PublicDelegatedPrefixes_Patch_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the PublicDelegatedPrefix resource to patch. + */ + // const publicDelegatedPrefix = 'abc123' + /** + * The body resource for this request + */ + // const publicDelegatedPrefixResource = {} + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {PublicDelegatedPrefixesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new PublicDelegatedPrefixesClient(); + + async function callPatch() { + // Construct request + const request = { + project, + publicDelegatedPrefix, + publicDelegatedPrefixResource, + region, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_PublicDelegatedPrefixes_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.delete.js new file mode 100644 index 00000000000..0b2b2bceb72 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(autoscaler, project, region) { + // [START compute_v1_generated_RegionAutoscalers_Delete_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. + */ + /** + * Name of the autoscaler to delete. + */ + // const autoscaler = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionAutoscalersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionAutoscalersClient(); + + async function callDelete() { + // Construct request + const request = { + autoscaler, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionAutoscalers_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.get.js new file mode 100644 index 00000000000..baff8acda42 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(autoscaler, project, region) { + // [START compute_v1_generated_RegionAutoscalers_Get_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. + */ + /** + * Name of the autoscaler to return. + */ + // const autoscaler = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionAutoscalersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionAutoscalersClient(); + + async function callGet() { + // Construct request + const request = { + autoscaler, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionAutoscalers_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.insert.js new file mode 100644 index 00000000000..e998749f248 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(autoscalerResource, project, region) { + // [START compute_v1_generated_RegionAutoscalers_Insert_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. + */ + /** + * The body resource for this request + */ + // const autoscalerResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionAutoscalersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionAutoscalersClient(); + + async function callInsert() { + // Construct request + const request = { + autoscalerResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionAutoscalers_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.list.js new file mode 100644 index 00000000000..fd201f2a7ea --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionAutoscalers_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionAutoscalersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionAutoscalersClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionAutoscalers_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.patch.js new file mode 100644 index 00000000000..e28fdfdcd14 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.patch.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(autoscalerResource, project, region) { + // [START compute_v1_generated_RegionAutoscalers_Patch_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. + */ + /** + * Name of the autoscaler to patch. + */ + // const autoscaler = 'abc123' + /** + * The body resource for this request + */ + // const autoscalerResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionAutoscalersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionAutoscalersClient(); + + async function callPatch() { + // Construct request + const request = { + autoscalerResource, + project, + region, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_RegionAutoscalers_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.update.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.update.js new file mode 100644 index 00000000000..de23267db70 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_autoscalers.update.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(autoscalerResource, project, region) { + // [START compute_v1_generated_RegionAutoscalers_Update_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. + */ + /** + * Name of the autoscaler to update. + */ + // const autoscaler = 'abc123' + /** + * The body resource for this request + */ + // const autoscalerResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionAutoscalersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionAutoscalersClient(); + + async function callUpdate() { + // Construct request + const request = { + autoscalerResource, + project, + region, + }; + + // Run request + const response = await computeClient.update(request); + console.log(response); + } + + callUpdate(); + // [END compute_v1_generated_RegionAutoscalers_Update_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.delete.js new file mode 100644 index 00000000000..8a721a44c9b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(backendService, project, region) { + // [START compute_v1_generated_RegionBackendServices_Delete_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. + */ + /** + * Name of the BackendService resource to delete. + */ + // const backendService = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionBackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionBackendServicesClient(); + + async function callDelete() { + // Construct request + const request = { + backendService, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionBackendServices_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.get.js new file mode 100644 index 00000000000..e50ec9b1dd9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(backendService, project, region) { + // [START compute_v1_generated_RegionBackendServices_Get_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. + */ + /** + * Name of the BackendService resource to return. + */ + // const backendService = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionBackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionBackendServicesClient(); + + async function callGet() { + // Construct request + const request = { + backendService, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionBackendServices_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.get_health.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.get_health.js new file mode 100644 index 00000000000..ef1639c39bc --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.get_health.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(backendService, project, region, resourceGroupReferenceResource) { + // [START compute_v1_generated_RegionBackendServices_GetHealth_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. + */ + /** + * Name of the BackendService resource for which to get health. + */ + // const backendService = 'abc123' + /** + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const resourceGroupReferenceResource = {} + + // Imports the Compute library + const {RegionBackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionBackendServicesClient(); + + async function callGetHealth() { + // Construct request + const request = { + backendService, + project, + region, + resourceGroupReferenceResource, + }; + + // Run request + const response = await computeClient.getHealth(request); + console.log(response); + } + + callGetHealth(); + // [END compute_v1_generated_RegionBackendServices_GetHealth_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.get_iam_policy.js new file mode 100644 index 00000000000..f8835822c68 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.get_iam_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, resource) { + // [START compute_v1_generated_RegionBackendServices_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {RegionBackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionBackendServicesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + region, + resource, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_RegionBackendServices_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.insert.js new file mode 100644 index 00000000000..a70811108d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(backendServiceResource, project, region) { + // [START compute_v1_generated_RegionBackendServices_Insert_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. + */ + /** + * The body resource for this request + */ + // const backendServiceResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionBackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionBackendServicesClient(); + + async function callInsert() { + // Construct request + const request = { + backendServiceResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionBackendServices_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.list.js new file mode 100644 index 00000000000..4b4477abe8c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionBackendServices_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionBackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionBackendServicesClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionBackendServices_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.patch.js new file mode 100644 index 00000000000..03e31f0501e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(backendService, backendServiceResource, project, region) { + // [START compute_v1_generated_RegionBackendServices_Patch_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. + */ + /** + * Name of the BackendService resource to patch. + */ + // const backendService = 'abc123' + /** + * The body resource for this request + */ + // const backendServiceResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionBackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionBackendServicesClient(); + + async function callPatch() { + // Construct request + const request = { + backendService, + backendServiceResource, + project, + region, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_RegionBackendServices_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.set_iam_policy.js new file mode 100644 index 00000000000..53bad9f829e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.set_iam_policy.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, regionSetPolicyRequestResource, resource) { + // [START compute_v1_generated_RegionBackendServices_SetIamPolicy_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionSetPolicyRequestResource = {} + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {RegionBackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionBackendServicesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + project, + region, + regionSetPolicyRequestResource, + resource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_RegionBackendServices_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.update.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.update.js new file mode 100644 index 00000000000..e0c07fc6baa --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_backend_services.update.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(backendService, backendServiceResource, project, region) { + // [START compute_v1_generated_RegionBackendServices_Update_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. + */ + /** + * Name of the BackendService resource to update. + */ + // const backendService = 'abc123' + /** + * The body resource for this request + */ + // const backendServiceResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionBackendServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionBackendServicesClient(); + + async function callUpdate() { + // Construct request + const request = { + backendService, + backendServiceResource, + project, + region, + }; + + // Run request + const response = await computeClient.update(request); + console.log(response); + } + + callUpdate(); + // [END compute_v1_generated_RegionBackendServices_Update_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_commitments.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_commitments.aggregated_list.js new file mode 100644 index 00000000000..5b4b390637a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_commitments.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_RegionCommitments_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionCommitmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionCommitmentsClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_RegionCommitments_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_commitments.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_commitments.get.js new file mode 100644 index 00000000000..6b1546834cb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_commitments.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(commitment, project, region) { + // [START compute_v1_generated_RegionCommitments_Get_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. + */ + /** + * Name of the commitment to return. + */ + // const commitment = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionCommitmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionCommitmentsClient(); + + async function callGet() { + // Construct request + const request = { + commitment, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionCommitments_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_commitments.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_commitments.insert.js new file mode 100644 index 00000000000..191ba7c8683 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_commitments.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(commitmentResource, project, region) { + // [START compute_v1_generated_RegionCommitments_Insert_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. + */ + /** + * The body resource for this request + */ + // const commitmentResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionCommitmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionCommitmentsClient(); + + async function callInsert() { + // Construct request + const request = { + commitmentResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionCommitments_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_commitments.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_commitments.list.js new file mode 100644 index 00000000000..01374e4f077 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_commitments.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionCommitments_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionCommitmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionCommitmentsClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionCommitments_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_commitments.update.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_commitments.update.js new file mode 100644 index 00000000000..8335d050a9d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_commitments.update.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(commitment, commitmentResource, project, region) { + // [START compute_v1_generated_RegionCommitments_Update_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. + */ + /** + * Name of the commitment for which auto renew is being updated. + */ + // const commitment = 'abc123' + /** + * The body resource for this request + */ + // const commitmentResource = {} + /** + */ + // const paths = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * update_mask indicates fields to be updated as part of this request. + */ + // const updateMask = 'abc123' + + // Imports the Compute library + const {RegionCommitmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionCommitmentsClient(); + + async function callUpdate() { + // Construct request + const request = { + commitment, + commitmentResource, + project, + region, + }; + + // Run request + const response = await computeClient.update(request); + console.log(response); + } + + callUpdate(); + // [END compute_v1_generated_RegionCommitments_Update_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disk_types.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disk_types.get.js new file mode 100644 index 00000000000..f2968a7f0c0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disk_types.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(diskType, project, region) { + // [START compute_v1_generated_RegionDiskTypes_Get_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. + */ + /** + * Name of the disk type to return. + */ + // const diskType = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionDiskTypesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionDiskTypesClient(); + + async function callGet() { + // Construct request + const request = { + diskType, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionDiskTypes_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disk_types.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disk_types.list.js new file mode 100644 index 00000000000..9a53bc92b48 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disk_types.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionDiskTypes_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionDiskTypesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionDiskTypesClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionDiskTypes_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.add_resource_policies.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.add_resource_policies.js new file mode 100644 index 00000000000..d40780b42e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.add_resource_policies.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(disk, project, region, regionDisksAddResourcePoliciesRequestResource) { + // [START compute_v1_generated_RegionDisks_AddResourcePolicies_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. + */ + /** + * The disk name for this request. + */ + // const disk = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionDisksAddResourcePoliciesRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionDisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionDisksClient(); + + async function callAddResourcePolicies() { + // Construct request + const request = { + disk, + project, + region, + regionDisksAddResourcePoliciesRequestResource, + }; + + // Run request + const response = await computeClient.addResourcePolicies(request); + console.log(response); + } + + callAddResourcePolicies(); + // [END compute_v1_generated_RegionDisks_AddResourcePolicies_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.create_snapshot.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.create_snapshot.js new file mode 100644 index 00000000000..745ea41815b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.create_snapshot.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(disk, project, region, snapshotResource) { + // [START compute_v1_generated_RegionDisks_CreateSnapshot_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. + */ + /** + * Name of the regional persistent disk to snapshot. + */ + // const disk = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const snapshotResource = {} + + // Imports the Compute library + const {RegionDisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionDisksClient(); + + async function callCreateSnapshot() { + // Construct request + const request = { + disk, + project, + region, + snapshotResource, + }; + + // Run request + const response = await computeClient.createSnapshot(request); + console.log(response); + } + + callCreateSnapshot(); + // [END compute_v1_generated_RegionDisks_CreateSnapshot_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.delete.js new file mode 100644 index 00000000000..bcb480dd4f5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(disk, project, region) { + // [START compute_v1_generated_RegionDisks_Delete_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. + */ + /** + * Name of the regional persistent disk to delete. + */ + // const disk = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionDisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionDisksClient(); + + async function callDelete() { + // Construct request + const request = { + disk, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionDisks_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.get.js new file mode 100644 index 00000000000..d5e5edea67b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(disk, project, region) { + // [START compute_v1_generated_RegionDisks_Get_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. + */ + /** + * Name of the regional persistent disk to return. + */ + // const disk = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionDisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionDisksClient(); + + async function callGet() { + // Construct request + const request = { + disk, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionDisks_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.get_iam_policy.js new file mode 100644 index 00000000000..496f3d84a94 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.get_iam_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, resource) { + // [START compute_v1_generated_RegionDisks_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {RegionDisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionDisksClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + region, + resource, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_RegionDisks_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.insert.js new file mode 100644 index 00000000000..62120e59735 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.insert.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(diskResource, project, region) { + // [START compute_v1_generated_RegionDisks_Insert_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. + */ + /** + * The body resource for this request + */ + // const diskResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Source image to restore onto a disk. This field is optional. + */ + // const sourceImage = 'abc123' + + // Imports the Compute library + const {RegionDisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionDisksClient(); + + async function callInsert() { + // Construct request + const request = { + diskResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionDisks_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.list.js new file mode 100644 index 00000000000..456e20ae398 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionDisks_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionDisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionDisksClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionDisks_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.remove_resource_policies.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.remove_resource_policies.js new file mode 100644 index 00000000000..549bc9a7175 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.remove_resource_policies.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(disk, project, region, regionDisksRemoveResourcePoliciesRequestResource) { + // [START compute_v1_generated_RegionDisks_RemoveResourcePolicies_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. + */ + /** + * The disk name for this request. + */ + // const disk = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionDisksRemoveResourcePoliciesRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionDisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionDisksClient(); + + async function callRemoveResourcePolicies() { + // Construct request + const request = { + disk, + project, + region, + regionDisksRemoveResourcePoliciesRequestResource, + }; + + // Run request + const response = await computeClient.removeResourcePolicies(request); + console.log(response); + } + + callRemoveResourcePolicies(); + // [END compute_v1_generated_RegionDisks_RemoveResourcePolicies_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.resize.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.resize.js new file mode 100644 index 00000000000..3671aa4b339 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.resize.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(disk, project, region, regionDisksResizeRequestResource) { + // [START compute_v1_generated_RegionDisks_Resize_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. + */ + /** + * Name of the regional persistent disk. + */ + // const disk = 'abc123' + /** + * The project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionDisksResizeRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionDisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionDisksClient(); + + async function callResize() { + // Construct request + const request = { + disk, + project, + region, + regionDisksResizeRequestResource, + }; + + // Run request + const response = await computeClient.resize(request); + console.log(response); + } + + callResize(); + // [END compute_v1_generated_RegionDisks_Resize_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.set_iam_policy.js new file mode 100644 index 00000000000..6f27e005d88 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.set_iam_policy.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, regionSetPolicyRequestResource, resource) { + // [START compute_v1_generated_RegionDisks_SetIamPolicy_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionSetPolicyRequestResource = {} + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {RegionDisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionDisksClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + project, + region, + regionSetPolicyRequestResource, + resource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_RegionDisks_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.set_labels.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.set_labels.js new file mode 100644 index 00000000000..9686216fe79 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.set_labels.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, regionSetLabelsRequestResource, resource) { + // [START compute_v1_generated_RegionDisks_SetLabels_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionSetLabelsRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {RegionDisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionDisksClient(); + + async function callSetLabels() { + // Construct request + const request = { + project, + region, + regionSetLabelsRequestResource, + resource, + }; + + // Run request + const response = await computeClient.setLabels(request); + console.log(response); + } + + callSetLabels(); + // [END compute_v1_generated_RegionDisks_SetLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.test_iam_permissions.js new file mode 100644 index 00000000000..668021586f3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.test_iam_permissions.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_RegionDisks_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {RegionDisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionDisksClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + region, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_RegionDisks_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.update.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.update.js new file mode 100644 index 00000000000..e2eb95347b9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_disks.update.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(disk, diskResource, project, region) { + // [START compute_v1_generated_RegionDisks_Update_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. + */ + /** + * The disk name for this request. + */ + // const disk = 'abc123' + /** + * The body resource for this request + */ + // const diskResource = {} + /** + */ + // const paths = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * update_mask indicates fields to be updated as part of this request. + */ + // const updateMask = 'abc123' + + // Imports the Compute library + const {RegionDisksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionDisksClient(); + + async function callUpdate() { + // Construct request + const request = { + disk, + diskResource, + project, + region, + }; + + // Run request + const response = await computeClient.update(request); + console.log(response); + } + + callUpdate(); + // [END compute_v1_generated_RegionDisks_Update_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_check_services.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_check_services.delete.js new file mode 100644 index 00000000000..cbcb907cd29 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_check_services.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(healthCheckService, project, region) { + // [START compute_v1_generated_RegionHealthCheckServices_Delete_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. + */ + /** + * Name of the HealthCheckService to delete. The name must be 1-63 characters long, and comply with RFC1035. + */ + // const healthCheckService = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionHealthCheckServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionHealthCheckServicesClient(); + + async function callDelete() { + // Construct request + const request = { + healthCheckService, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionHealthCheckServices_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_check_services.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_check_services.get.js new file mode 100644 index 00000000000..f6699eefecc --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_check_services.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(healthCheckService, project, region) { + // [START compute_v1_generated_RegionHealthCheckServices_Get_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. + */ + /** + * Name of the HealthCheckService to update. The name must be 1-63 characters long, and comply with RFC1035. + */ + // const healthCheckService = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionHealthCheckServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionHealthCheckServicesClient(); + + async function callGet() { + // Construct request + const request = { + healthCheckService, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionHealthCheckServices_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_check_services.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_check_services.insert.js new file mode 100644 index 00000000000..448b23fef10 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_check_services.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(healthCheckServiceResource, project, region) { + // [START compute_v1_generated_RegionHealthCheckServices_Insert_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. + */ + /** + * The body resource for this request + */ + // const healthCheckServiceResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionHealthCheckServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionHealthCheckServicesClient(); + + async function callInsert() { + // Construct request + const request = { + healthCheckServiceResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionHealthCheckServices_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_check_services.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_check_services.list.js new file mode 100644 index 00000000000..09fb672015b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_check_services.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionHealthCheckServices_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionHealthCheckServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionHealthCheckServicesClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionHealthCheckServices_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_check_services.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_check_services.patch.js new file mode 100644 index 00000000000..c09553e91a3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_check_services.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(healthCheckService, healthCheckServiceResource, project, region) { + // [START compute_v1_generated_RegionHealthCheckServices_Patch_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. + */ + /** + * Name of the HealthCheckService to update. The name must be 1-63 characters long, and comply with RFC1035. + */ + // const healthCheckService = 'abc123' + /** + * The body resource for this request + */ + // const healthCheckServiceResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionHealthCheckServicesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionHealthCheckServicesClient(); + + async function callPatch() { + // Construct request + const request = { + healthCheckService, + healthCheckServiceResource, + project, + region, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_RegionHealthCheckServices_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.delete.js new file mode 100644 index 00000000000..29c80c86876 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(healthCheck, project, region) { + // [START compute_v1_generated_RegionHealthChecks_Delete_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. + */ + /** + * Name of the HealthCheck resource to delete. + */ + // const healthCheck = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionHealthChecksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionHealthChecksClient(); + + async function callDelete() { + // Construct request + const request = { + healthCheck, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionHealthChecks_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.get.js new file mode 100644 index 00000000000..c64a8b8b5e0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(healthCheck, project, region) { + // [START compute_v1_generated_RegionHealthChecks_Get_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. + */ + /** + * Name of the HealthCheck resource to return. + */ + // const healthCheck = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionHealthChecksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionHealthChecksClient(); + + async function callGet() { + // Construct request + const request = { + healthCheck, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionHealthChecks_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.insert.js new file mode 100644 index 00000000000..7616cf15991 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(healthCheckResource, project, region) { + // [START compute_v1_generated_RegionHealthChecks_Insert_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. + */ + /** + * The body resource for this request + */ + // const healthCheckResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionHealthChecksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionHealthChecksClient(); + + async function callInsert() { + // Construct request + const request = { + healthCheckResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionHealthChecks_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.list.js new file mode 100644 index 00000000000..f060c10a210 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionHealthChecks_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionHealthChecksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionHealthChecksClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionHealthChecks_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.patch.js new file mode 100644 index 00000000000..e5e9523a4eb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(healthCheck, healthCheckResource, project, region) { + // [START compute_v1_generated_RegionHealthChecks_Patch_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. + */ + /** + * Name of the HealthCheck resource to patch. + */ + // const healthCheck = 'abc123' + /** + * The body resource for this request + */ + // const healthCheckResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionHealthChecksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionHealthChecksClient(); + + async function callPatch() { + // Construct request + const request = { + healthCheck, + healthCheckResource, + project, + region, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_RegionHealthChecks_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.update.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.update.js new file mode 100644 index 00000000000..4974092d799 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_health_checks.update.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(healthCheck, healthCheckResource, project, region) { + // [START compute_v1_generated_RegionHealthChecks_Update_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. + */ + /** + * Name of the HealthCheck resource to update. + */ + // const healthCheck = 'abc123' + /** + * The body resource for this request + */ + // const healthCheckResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionHealthChecksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionHealthChecksClient(); + + async function callUpdate() { + // Construct request + const request = { + healthCheck, + healthCheckResource, + project, + region, + }; + + // Run request + const response = await computeClient.update(request); + console.log(response); + } + + callUpdate(); + // [END compute_v1_generated_RegionHealthChecks_Update_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.abandon_instances.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.abandon_instances.js new file mode 100644 index 00000000000..9430d3fd55f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.abandon_instances.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, project, region, regionInstanceGroupManagersAbandonInstancesRequestResource) { + // [START compute_v1_generated_RegionInstanceGroupManagers_AbandonInstances_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. + */ + /** + * Name of the managed instance group. + */ + // const instanceGroupManager = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionInstanceGroupManagersAbandonInstancesRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callAbandonInstances() { + // Construct request + const request = { + instanceGroupManager, + project, + region, + regionInstanceGroupManagersAbandonInstancesRequestResource, + }; + + // Run request + const response = await computeClient.abandonInstances(request); + console.log(response); + } + + callAbandonInstances(); + // [END compute_v1_generated_RegionInstanceGroupManagers_AbandonInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.apply_updates_to_instances.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.apply_updates_to_instances.js new file mode 100644 index 00000000000..bbbbc76666e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.apply_updates_to_instances.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(instanceGroupManager, project, region, regionInstanceGroupManagersApplyUpdatesRequestResource) { + // [START compute_v1_generated_RegionInstanceGroupManagers_ApplyUpdatesToInstances_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. + */ + /** + * The name of the managed instance group, should conform to RFC1035. + */ + // const instanceGroupManager = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request, should conform to RFC1035. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionInstanceGroupManagersApplyUpdatesRequestResource = {} + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callApplyUpdatesToInstances() { + // Construct request + const request = { + instanceGroupManager, + project, + region, + regionInstanceGroupManagersApplyUpdatesRequestResource, + }; + + // Run request + const response = await computeClient.applyUpdatesToInstances(request); + console.log(response); + } + + callApplyUpdatesToInstances(); + // [END compute_v1_generated_RegionInstanceGroupManagers_ApplyUpdatesToInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.create_instances.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.create_instances.js new file mode 100644 index 00000000000..458b444bbff --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.create_instances.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, project, region, regionInstanceGroupManagersCreateInstancesRequestResource) { + // [START compute_v1_generated_RegionInstanceGroupManagers_CreateInstances_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. + */ + /** + * The name of the managed instance group. It should conform to RFC1035. + */ + // const instanceGroupManager = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region where the managed instance group is located. It should conform to RFC1035. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionInstanceGroupManagersCreateInstancesRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callCreateInstances() { + // Construct request + const request = { + instanceGroupManager, + project, + region, + regionInstanceGroupManagersCreateInstancesRequestResource, + }; + + // Run request + const response = await computeClient.createInstances(request); + console.log(response); + } + + callCreateInstances(); + // [END compute_v1_generated_RegionInstanceGroupManagers_CreateInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.delete.js new file mode 100644 index 00000000000..5e986f31a63 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(instanceGroupManager, project, region) { + // [START compute_v1_generated_RegionInstanceGroupManagers_Delete_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. + */ + /** + * Name of the managed instance group to delete. + */ + // const instanceGroupManager = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callDelete() { + // Construct request + const request = { + instanceGroupManager, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionInstanceGroupManagers_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.delete_instances.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.delete_instances.js new file mode 100644 index 00000000000..2dd282918c0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.delete_instances.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, project, region, regionInstanceGroupManagersDeleteInstancesRequestResource) { + // [START compute_v1_generated_RegionInstanceGroupManagers_DeleteInstances_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. + */ + /** + * Name of the managed instance group. + */ + // const instanceGroupManager = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionInstanceGroupManagersDeleteInstancesRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callDeleteInstances() { + // Construct request + const request = { + instanceGroupManager, + project, + region, + regionInstanceGroupManagersDeleteInstancesRequestResource, + }; + + // Run request + const response = await computeClient.deleteInstances(request); + console.log(response); + } + + callDeleteInstances(); + // [END compute_v1_generated_RegionInstanceGroupManagers_DeleteInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.delete_per_instance_configs.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.delete_per_instance_configs.js new file mode 100644 index 00000000000..a401bde0dda --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.delete_per_instance_configs.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(instanceGroupManager, project, region, regionInstanceGroupManagerDeleteInstanceConfigReqResource) { + // [START compute_v1_generated_RegionInstanceGroupManagers_DeletePerInstanceConfigs_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. + */ + /** + * The name of the managed instance group. It should conform to RFC1035. + */ + // const instanceGroupManager = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request, should conform to RFC1035. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionInstanceGroupManagerDeleteInstanceConfigReqResource = {} + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callDeletePerInstanceConfigs() { + // Construct request + const request = { + instanceGroupManager, + project, + region, + regionInstanceGroupManagerDeleteInstanceConfigReqResource, + }; + + // Run request + const response = await computeClient.deletePerInstanceConfigs(request); + console.log(response); + } + + callDeletePerInstanceConfigs(); + // [END compute_v1_generated_RegionInstanceGroupManagers_DeletePerInstanceConfigs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.get.js new file mode 100644 index 00000000000..c9aafbacf12 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(instanceGroupManager, project, region) { + // [START compute_v1_generated_RegionInstanceGroupManagers_Get_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. + */ + /** + * Name of the managed instance group to return. + */ + // const instanceGroupManager = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callGet() { + // Construct request + const request = { + instanceGroupManager, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionInstanceGroupManagers_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.insert.js new file mode 100644 index 00000000000..a104f8beec1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(instanceGroupManagerResource, project, region) { + // [START compute_v1_generated_RegionInstanceGroupManagers_Insert_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. + */ + /** + * The body resource for this request + */ + // const instanceGroupManagerResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callInsert() { + // Construct request + const request = { + instanceGroupManagerResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionInstanceGroupManagers_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.list.js new file mode 100644 index 00000000000..46f04989eb6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionInstanceGroupManagers_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionInstanceGroupManagers_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.list_errors.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.list_errors.js new file mode 100644 index 00000000000..5a249cb171c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.list_errors.js @@ -0,0 +1,93 @@ +// Copyright 2023 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(instanceGroupManager, project, region) { + // [START compute_v1_generated_RegionInstanceGroupManagers_ListErrors_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The name of the managed instance group. It must be a string that meets the requirements in RFC1035, or an unsigned long integer: must match regexp pattern: (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)|1-9{0,19}. + */ + // const instanceGroupManager = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. This should conform to RFC1035. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callListErrors() { + // Construct request + const request = { + instanceGroupManager, + project, + region, + }; + + // Run request + const iterable = await computeClient.listErrorsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListErrors(); + // [END compute_v1_generated_RegionInstanceGroupManagers_ListErrors_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.list_managed_instances.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.list_managed_instances.js new file mode 100644 index 00000000000..4faf7826dd5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.list_managed_instances.js @@ -0,0 +1,93 @@ +// Copyright 2023 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(instanceGroupManager, project, region) { + // [START compute_v1_generated_RegionInstanceGroupManagers_ListManagedInstances_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The name of the managed instance group. + */ + // const instanceGroupManager = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callListManagedInstances() { + // Construct request + const request = { + instanceGroupManager, + project, + region, + }; + + // Run request + const iterable = await computeClient.listManagedInstancesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListManagedInstances(); + // [END compute_v1_generated_RegionInstanceGroupManagers_ListManagedInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.list_per_instance_configs.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.list_per_instance_configs.js new file mode 100644 index 00000000000..bd785e35975 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.list_per_instance_configs.js @@ -0,0 +1,93 @@ +// Copyright 2023 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(instanceGroupManager, project, region) { + // [START compute_v1_generated_RegionInstanceGroupManagers_ListPerInstanceConfigs_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The name of the managed instance group. It should conform to RFC1035. + */ + // const instanceGroupManager = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request, should conform to RFC1035. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callListPerInstanceConfigs() { + // Construct request + const request = { + instanceGroupManager, + project, + region, + }; + + // Run request + const iterable = await computeClient.listPerInstanceConfigsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListPerInstanceConfigs(); + // [END compute_v1_generated_RegionInstanceGroupManagers_ListPerInstanceConfigs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.patch.js new file mode 100644 index 00000000000..09cd9863ca8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, instanceGroupManagerResource, project, region) { + // [START compute_v1_generated_RegionInstanceGroupManagers_Patch_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. + */ + /** + * The name of the instance group manager. + */ + // const instanceGroupManager = 'abc123' + /** + * The body resource for this request + */ + // const instanceGroupManagerResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callPatch() { + // Construct request + const request = { + instanceGroupManager, + instanceGroupManagerResource, + project, + region, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_RegionInstanceGroupManagers_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.patch_per_instance_configs.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.patch_per_instance_configs.js new file mode 100644 index 00000000000..054463939cb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.patch_per_instance_configs.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, project, region, regionInstanceGroupManagerPatchInstanceConfigReqResource) { + // [START compute_v1_generated_RegionInstanceGroupManagers_PatchPerInstanceConfigs_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. + */ + /** + * The name of the managed instance group. It should conform to RFC1035. + */ + // const instanceGroupManager = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request, should conform to RFC1035. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionInstanceGroupManagerPatchInstanceConfigReqResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callPatchPerInstanceConfigs() { + // Construct request + const request = { + instanceGroupManager, + project, + region, + regionInstanceGroupManagerPatchInstanceConfigReqResource, + }; + + // Run request + const response = await computeClient.patchPerInstanceConfigs(request); + console.log(response); + } + + callPatchPerInstanceConfigs(); + // [END compute_v1_generated_RegionInstanceGroupManagers_PatchPerInstanceConfigs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.recreate_instances.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.recreate_instances.js new file mode 100644 index 00000000000..42a3c7675b2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.recreate_instances.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, project, region, regionInstanceGroupManagersRecreateRequestResource) { + // [START compute_v1_generated_RegionInstanceGroupManagers_RecreateInstances_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. + */ + /** + * Name of the managed instance group. + */ + // const instanceGroupManager = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionInstanceGroupManagersRecreateRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callRecreateInstances() { + // Construct request + const request = { + instanceGroupManager, + project, + region, + regionInstanceGroupManagersRecreateRequestResource, + }; + + // Run request + const response = await computeClient.recreateInstances(request); + console.log(response); + } + + callRecreateInstances(); + // [END compute_v1_generated_RegionInstanceGroupManagers_RecreateInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.resize.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.resize.js new file mode 100644 index 00000000000..9eabea8fc36 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.resize.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, project, region, size) { + // [START compute_v1_generated_RegionInstanceGroupManagers_Resize_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. + */ + /** + * Name of the managed instance group. + */ + // const instanceGroupManager = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Number of instances that should exist in this instance group manager. + */ + // const size = 1234 + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callResize() { + // Construct request + const request = { + instanceGroupManager, + project, + region, + size, + }; + + // Run request + const response = await computeClient.resize(request); + console.log(response); + } + + callResize(); + // [END compute_v1_generated_RegionInstanceGroupManagers_Resize_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.set_instance_template.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.set_instance_template.js new file mode 100644 index 00000000000..146f4cbdb9d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.set_instance_template.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, project, region, regionInstanceGroupManagersSetTemplateRequestResource) { + // [START compute_v1_generated_RegionInstanceGroupManagers_SetInstanceTemplate_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. + */ + /** + * The name of the managed instance group. + */ + // const instanceGroupManager = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionInstanceGroupManagersSetTemplateRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callSetInstanceTemplate() { + // Construct request + const request = { + instanceGroupManager, + project, + region, + regionInstanceGroupManagersSetTemplateRequestResource, + }; + + // Run request + const response = await computeClient.setInstanceTemplate(request); + console.log(response); + } + + callSetInstanceTemplate(); + // [END compute_v1_generated_RegionInstanceGroupManagers_SetInstanceTemplate_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.set_target_pools.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.set_target_pools.js new file mode 100644 index 00000000000..36fbae03209 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.set_target_pools.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, project, region, regionInstanceGroupManagersSetTargetPoolsRequestResource) { + // [START compute_v1_generated_RegionInstanceGroupManagers_SetTargetPools_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. + */ + /** + * Name of the managed instance group. + */ + // const instanceGroupManager = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionInstanceGroupManagersSetTargetPoolsRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callSetTargetPools() { + // Construct request + const request = { + instanceGroupManager, + project, + region, + regionInstanceGroupManagersSetTargetPoolsRequestResource, + }; + + // Run request + const response = await computeClient.setTargetPools(request); + console.log(response); + } + + callSetTargetPools(); + // [END compute_v1_generated_RegionInstanceGroupManagers_SetTargetPools_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.update_per_instance_configs.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.update_per_instance_configs.js new file mode 100644 index 00000000000..b01ac52ab27 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_group_managers.update_per_instance_configs.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroupManager, project, region, regionInstanceGroupManagerUpdateInstanceConfigReqResource) { + // [START compute_v1_generated_RegionInstanceGroupManagers_UpdatePerInstanceConfigs_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. + */ + /** + * The name of the managed instance group. It should conform to RFC1035. + */ + // const instanceGroupManager = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request, should conform to RFC1035. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionInstanceGroupManagerUpdateInstanceConfigReqResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionInstanceGroupManagersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupManagersClient(); + + async function callUpdatePerInstanceConfigs() { + // Construct request + const request = { + instanceGroupManager, + project, + region, + regionInstanceGroupManagerUpdateInstanceConfigReqResource, + }; + + // Run request + const response = await computeClient.updatePerInstanceConfigs(request); + console.log(response); + } + + callUpdatePerInstanceConfigs(); + // [END compute_v1_generated_RegionInstanceGroupManagers_UpdatePerInstanceConfigs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_groups.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_groups.get.js new file mode 100644 index 00000000000..397f20df970 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_groups.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(instanceGroup, project, region) { + // [START compute_v1_generated_RegionInstanceGroups_Get_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. + */ + /** + * Name of the instance group resource to return. + */ + // const instanceGroup = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionInstanceGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupsClient(); + + async function callGet() { + // Construct request + const request = { + instanceGroup, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionInstanceGroups_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_groups.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_groups.list.js new file mode 100644 index 00000000000..0bf90fe5c96 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_groups.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionInstanceGroups_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionInstanceGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupsClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionInstanceGroups_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_groups.list_instances.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_groups.list_instances.js new file mode 100644 index 00000000000..e966c7da3a7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_groups.list_instances.js @@ -0,0 +1,98 @@ +// Copyright 2023 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(instanceGroup, project, region, regionInstanceGroupsListInstancesRequestResource) { + // [START compute_v1_generated_RegionInstanceGroups_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Name of the regional instance group for which we want to list the instances. + */ + // const instanceGroup = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionInstanceGroupsListInstancesRequestResource = {} + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionInstanceGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupsClient(); + + async function callListInstances() { + // Construct request + const request = { + instanceGroup, + project, + region, + regionInstanceGroupsListInstancesRequestResource, + }; + + // Run request + const iterable = await computeClient.listInstancesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListInstances(); + // [END compute_v1_generated_RegionInstanceGroups_ListInstances_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_groups.set_named_ports.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_groups.set_named_ports.js new file mode 100644 index 00000000000..0ec0d9104cb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_groups.set_named_ports.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(instanceGroup, project, region, regionInstanceGroupsSetNamedPortsRequestResource) { + // [START compute_v1_generated_RegionInstanceGroups_SetNamedPorts_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. + */ + /** + * The name of the regional instance group where the named ports are updated. + */ + // const instanceGroup = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionInstanceGroupsSetNamedPortsRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionInstanceGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceGroupsClient(); + + async function callSetNamedPorts() { + // Construct request + const request = { + instanceGroup, + project, + region, + regionInstanceGroupsSetNamedPortsRequestResource, + }; + + // Run request + const response = await computeClient.setNamedPorts(request); + console.log(response); + } + + callSetNamedPorts(); + // [END compute_v1_generated_RegionInstanceGroups_SetNamedPorts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_templates.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_templates.delete.js new file mode 100644 index 00000000000..414a3798511 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_templates.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(instanceTemplate, project, region) { + // [START compute_v1_generated_RegionInstanceTemplates_Delete_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. + */ + /** + * The name of the instance template to delete. + */ + // const instanceTemplate = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionInstanceTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceTemplatesClient(); + + async function callDelete() { + // Construct request + const request = { + instanceTemplate, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionInstanceTemplates_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_templates.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_templates.get.js new file mode 100644 index 00000000000..4d256724dc5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_templates.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(instanceTemplate, project, region) { + // [START compute_v1_generated_RegionInstanceTemplates_Get_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. + */ + /** + * The name of the instance template. + */ + // const instanceTemplate = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionInstanceTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceTemplatesClient(); + + async function callGet() { + // Construct request + const request = { + instanceTemplate, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionInstanceTemplates_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_templates.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_templates.insert.js new file mode 100644 index 00000000000..4cbaa287115 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_templates.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(instanceTemplateResource, project, region) { + // [START compute_v1_generated_RegionInstanceTemplates_Insert_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. + */ + /** + * The body resource for this request + */ + // const instanceTemplateResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionInstanceTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceTemplatesClient(); + + async function callInsert() { + // Construct request + const request = { + instanceTemplateResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionInstanceTemplates_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_templates.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_templates.list.js new file mode 100644 index 00000000000..ad4c7a0441b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instance_templates.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionInstanceTemplates_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the regions for this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionInstanceTemplatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstanceTemplatesClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionInstanceTemplates_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instances.bulk_insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instances.bulk_insert.js new file mode 100644 index 00000000000..f958416d953 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_instances.bulk_insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(bulkInsertInstanceResourceResource, project, region) { + // [START compute_v1_generated_RegionInstances_BulkInsert_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. + */ + /** + * The body resource for this request + */ + // const bulkInsertInstanceResourceResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionInstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionInstancesClient(); + + async function callBulkInsert() { + // Construct request + const request = { + bulkInsertInstanceResourceResource, + project, + region, + }; + + // Run request + const response = await computeClient.bulkInsert(request); + console.log(response); + } + + callBulkInsert(); + // [END compute_v1_generated_RegionInstances_BulkInsert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_endpoint_groups.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_endpoint_groups.delete.js new file mode 100644 index 00000000000..e22cbcf0220 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_endpoint_groups.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(networkEndpointGroup, project, region) { + // [START compute_v1_generated_RegionNetworkEndpointGroups_Delete_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. + */ + /** + * The name of the network endpoint group to delete. It should comply with RFC1035. + */ + // const networkEndpointGroup = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region where the network endpoint group is located. It should comply with RFC1035. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionNetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkEndpointGroupsClient(); + + async function callDelete() { + // Construct request + const request = { + networkEndpointGroup, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionNetworkEndpointGroups_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_endpoint_groups.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_endpoint_groups.get.js new file mode 100644 index 00000000000..94d76b37ded --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_endpoint_groups.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(networkEndpointGroup, project, region) { + // [START compute_v1_generated_RegionNetworkEndpointGroups_Get_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. + */ + /** + * The name of the network endpoint group. It should comply with RFC1035. + */ + // const networkEndpointGroup = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region where the network endpoint group is located. It should comply with RFC1035. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionNetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkEndpointGroupsClient(); + + async function callGet() { + // Construct request + const request = { + networkEndpointGroup, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionNetworkEndpointGroups_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_endpoint_groups.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_endpoint_groups.insert.js new file mode 100644 index 00000000000..c81faee7475 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_endpoint_groups.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(networkEndpointGroupResource, project, region) { + // [START compute_v1_generated_RegionNetworkEndpointGroups_Insert_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. + */ + /** + * The body resource for this request + */ + // const networkEndpointGroupResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region where you want to create the network endpoint group. It should comply with RFC1035. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionNetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkEndpointGroupsClient(); + + async function callInsert() { + // Construct request + const request = { + networkEndpointGroupResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionNetworkEndpointGroups_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_endpoint_groups.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_endpoint_groups.list.js new file mode 100644 index 00000000000..a49b84bc715 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_endpoint_groups.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionNetworkEndpointGroups_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region where the network endpoint group is located. It should comply with RFC1035. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionNetworkEndpointGroupsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkEndpointGroupsClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionNetworkEndpointGroups_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.add_association.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.add_association.js new file mode 100644 index 00000000000..28dcbd616e9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.add_association.js @@ -0,0 +1,84 @@ +// Copyright 2023 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(firewallPolicy, firewallPolicyAssociationResource, project, region) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_AddAssociation_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * The body resource for this request + */ + // const firewallPolicyAssociationResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Indicates whether or not to replace it if an association already exists. This is false by default, in which case an error will be returned if an association already exists. + */ + // const replaceExistingAssociation = true + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callAddAssociation() { + // Construct request + const request = { + firewallPolicy, + firewallPolicyAssociationResource, + project, + region, + }; + + // Run request + const response = await computeClient.addAssociation(request); + console.log(response); + } + + callAddAssociation(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_AddAssociation_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.add_rule.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.add_rule.js new file mode 100644 index 00000000000..5ee0c134262 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.add_rule.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(firewallPolicy, firewallPolicyRuleResource, project, region) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_AddRule_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * The body resource for this request + */ + // const firewallPolicyRuleResource = {} + /** + * When rule.priority is not specified, auto choose a unused priority between minPriority and maxPriority>. This field is exclusive with rule.priority. + */ + // const maxPriority = 1234 + /** + * When rule.priority is not specified, auto choose a unused priority between minPriority and maxPriority>. This field is exclusive with rule.priority. + */ + // const minPriority = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callAddRule() { + // Construct request + const request = { + firewallPolicy, + firewallPolicyRuleResource, + project, + region, + }; + + // Run request + const response = await computeClient.addRule(request); + console.log(response); + } + + callAddRule(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_AddRule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.clone_rules.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.clone_rules.js new file mode 100644 index 00000000000..55c78d2c4e2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.clone_rules.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(firewallPolicy, project, region) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_CloneRules_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The firewall policy from which to copy rules. + */ + // const sourceFirewallPolicy = 'abc123' + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callCloneRules() { + // Construct request + const request = { + firewallPolicy, + project, + region, + }; + + // Run request + const response = await computeClient.cloneRules(request); + console.log(response); + } + + callCloneRules(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_CloneRules_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.delete.js new file mode 100644 index 00000000000..5e6eb4bcef1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(firewallPolicy, project, region) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_Delete_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. + */ + /** + * Name of the firewall policy to delete. + */ + // const firewallPolicy = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callDelete() { + // Construct request + const request = { + firewallPolicy, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.get.js new file mode 100644 index 00000000000..e07a87e4899 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(firewallPolicy, project, region) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_Get_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. + */ + /** + * Name of the firewall policy to get. + */ + // const firewallPolicy = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callGet() { + // Construct request + const request = { + firewallPolicy, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.get_association.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.get_association.js new file mode 100644 index 00000000000..1a19389c20b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.get_association.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(firewallPolicy, project, region) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_GetAssociation_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. + */ + /** + * Name of the firewall policy to which the queried association belongs. + */ + // const firewallPolicy = 'abc123' + /** + * The name of the association to get from the firewall policy. + */ + // const name = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callGetAssociation() { + // Construct request + const request = { + firewallPolicy, + project, + region, + }; + + // Run request + const response = await computeClient.getAssociation(request); + console.log(response); + } + + callGetAssociation(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_GetAssociation_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.get_effective_firewalls.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.get_effective_firewalls.js new file mode 100644 index 00000000000..09a49f57a4a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.get_effective_firewalls.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(network, project, region) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_GetEffectiveFirewalls_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. + */ + /** + * Network reference + */ + // const network = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callGetEffectiveFirewalls() { + // Construct request + const request = { + network, + project, + region, + }; + + // Run request + const response = await computeClient.getEffectiveFirewalls(request); + console.log(response); + } + + callGetEffectiveFirewalls(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_GetEffectiveFirewalls_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.get_iam_policy.js new file mode 100644 index 00000000000..c872eb32373 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.get_iam_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, resource) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + region, + resource, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.get_rule.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.get_rule.js new file mode 100644 index 00000000000..f0989b0e151 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.get_rule.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(firewallPolicy, project, region) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_GetRule_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. + */ + /** + * Name of the firewall policy to which the queried rule belongs. + */ + // const firewallPolicy = 'abc123' + /** + * The priority of the rule to get from the firewall policy. + */ + // const priority = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callGetRule() { + // Construct request + const request = { + firewallPolicy, + project, + region, + }; + + // Run request + const response = await computeClient.getRule(request); + console.log(response); + } + + callGetRule(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_GetRule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.insert.js new file mode 100644 index 00000000000..8162e3a1b73 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(firewallPolicyResource, project, region) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_Insert_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. + */ + /** + * The body resource for this request + */ + // const firewallPolicyResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callInsert() { + // Construct request + const request = { + firewallPolicyResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.list.js new file mode 100644 index 00000000000..c2435bcf62e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.patch.js new file mode 100644 index 00000000000..2b58bdf7e5b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(firewallPolicy, firewallPolicyResource, project, region) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_Patch_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * The body resource for this request + */ + // const firewallPolicyResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callPatch() { + // Construct request + const request = { + firewallPolicy, + firewallPolicyResource, + project, + region, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.patch_rule.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.patch_rule.js new file mode 100644 index 00000000000..13439731106 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.patch_rule.js @@ -0,0 +1,84 @@ +// Copyright 2023 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(firewallPolicy, firewallPolicyRuleResource, project, region) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_PatchRule_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * The body resource for this request + */ + // const firewallPolicyRuleResource = {} + /** + * The priority of the rule to patch. + */ + // const priority = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callPatchRule() { + // Construct request + const request = { + firewallPolicy, + firewallPolicyRuleResource, + project, + region, + }; + + // Run request + const response = await computeClient.patchRule(request); + console.log(response); + } + + callPatchRule(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_PatchRule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.remove_association.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.remove_association.js new file mode 100644 index 00000000000..8ab4d6ed55d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.remove_association.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(firewallPolicy, project, region) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_RemoveAssociation_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * Name for the association that will be removed. + */ + // const name = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callRemoveAssociation() { + // Construct request + const request = { + firewallPolicy, + project, + region, + }; + + // Run request + const response = await computeClient.removeAssociation(request); + console.log(response); + } + + callRemoveAssociation(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_RemoveAssociation_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.remove_rule.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.remove_rule.js new file mode 100644 index 00000000000..21ed0a3e7cf --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.remove_rule.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(firewallPolicy, project, region) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_RemoveRule_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. + */ + /** + * Name of the firewall policy to update. + */ + // const firewallPolicy = 'abc123' + /** + * The priority of the rule to remove from the firewall policy. + */ + // const priority = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callRemoveRule() { + // Construct request + const request = { + firewallPolicy, + project, + region, + }; + + // Run request + const response = await computeClient.removeRule(request); + console.log(response); + } + + callRemoveRule(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_RemoveRule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.set_iam_policy.js new file mode 100644 index 00000000000..94ba9a09155 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.set_iam_policy.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, regionSetPolicyRequestResource, resource) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_SetIamPolicy_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionSetPolicyRequestResource = {} + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + project, + region, + regionSetPolicyRequestResource, + resource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.test_iam_permissions.js new file mode 100644 index 00000000000..97b2a153c2f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_network_firewall_policies.test_iam_permissions.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_RegionNetworkFirewallPolicies_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {RegionNetworkFirewallPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNetworkFirewallPoliciesClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + region, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_RegionNetworkFirewallPolicies_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_notification_endpoints.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_notification_endpoints.delete.js new file mode 100644 index 00000000000..f14c1092f6f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_notification_endpoints.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(notificationEndpoint, project, region) { + // [START compute_v1_generated_RegionNotificationEndpoints_Delete_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. + */ + /** + * Name of the NotificationEndpoint resource to delete. + */ + // const notificationEndpoint = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionNotificationEndpointsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNotificationEndpointsClient(); + + async function callDelete() { + // Construct request + const request = { + notificationEndpoint, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionNotificationEndpoints_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_notification_endpoints.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_notification_endpoints.get.js new file mode 100644 index 00000000000..aac9dd33abe --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_notification_endpoints.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(notificationEndpoint, project, region) { + // [START compute_v1_generated_RegionNotificationEndpoints_Get_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. + */ + /** + * Name of the NotificationEndpoint resource to return. + */ + // const notificationEndpoint = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionNotificationEndpointsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNotificationEndpointsClient(); + + async function callGet() { + // Construct request + const request = { + notificationEndpoint, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionNotificationEndpoints_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_notification_endpoints.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_notification_endpoints.insert.js new file mode 100644 index 00000000000..347d26fed20 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_notification_endpoints.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(notificationEndpointResource, project, region) { + // [START compute_v1_generated_RegionNotificationEndpoints_Insert_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. + */ + /** + * The body resource for this request + */ + // const notificationEndpointResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {RegionNotificationEndpointsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNotificationEndpointsClient(); + + async function callInsert() { + // Construct request + const request = { + notificationEndpointResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionNotificationEndpoints_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_notification_endpoints.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_notification_endpoints.list.js new file mode 100644 index 00000000000..4cf3e732caa --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_notification_endpoints.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionNotificationEndpoints_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionNotificationEndpointsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionNotificationEndpointsClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionNotificationEndpoints_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_operations.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_operations.delete.js new file mode 100644 index 00000000000..c7fa5e2971f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_operations.delete.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(operation, project, region) { + // [START compute_v1_generated_RegionOperations_Delete_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. + */ + /** + * Name of the Operations resource to delete. + */ + // const operation = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionOperationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionOperationsClient(); + + async function callDelete() { + // Construct request + const request = { + operation, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionOperations_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_operations.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_operations.get.js new file mode 100644 index 00000000000..0e9f4acc8e5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_operations.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(operation, project, region) { + // [START compute_v1_generated_RegionOperations_Get_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. + */ + /** + * Name of the Operations resource to return. + */ + // const operation = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionOperationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionOperationsClient(); + + async function callGet() { + // Construct request + const request = { + operation, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionOperations_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_operations.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_operations.list.js new file mode 100644 index 00000000000..59203c472d0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_operations.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionOperations_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionOperationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionOperationsClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionOperations_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_operations.wait.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_operations.wait.js new file mode 100644 index 00000000000..f29b702cadc --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_operations.wait.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(operation, project, region) { + // [START compute_v1_generated_RegionOperations_Wait_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. + */ + /** + * Name of the Operations resource to return. + */ + // const operation = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionOperationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionOperationsClient(); + + async function callWait() { + // Construct request + const request = { + operation, + project, + region, + }; + + // Run request + const response = await computeClient.wait(request); + console.log(response); + } + + callWait(); + // [END compute_v1_generated_RegionOperations_Wait_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_security_policies.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_security_policies.delete.js new file mode 100644 index 00000000000..fa747115420 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_security_policies.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, securityPolicy) { + // [START compute_v1_generated_RegionSecurityPolicies_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the security policy to delete. + */ + // const securityPolicy = 'abc123' + + // Imports the Compute library + const {RegionSecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionSecurityPoliciesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + region, + securityPolicy, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionSecurityPolicies_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_security_policies.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_security_policies.get.js new file mode 100644 index 00000000000..3ee8afda7ca --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_security_policies.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, securityPolicy) { + // [START compute_v1_generated_RegionSecurityPolicies_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Name of the security policy to get. + */ + // const securityPolicy = 'abc123' + + // Imports the Compute library + const {RegionSecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionSecurityPoliciesClient(); + + async function callGet() { + // Construct request + const request = { + project, + region, + securityPolicy, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionSecurityPolicies_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_security_policies.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_security_policies.insert.js new file mode 100644 index 00000000000..497e419fb69 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_security_policies.insert.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(project, region, securityPolicyResource) { + // [START compute_v1_generated_RegionSecurityPolicies_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const securityPolicyResource = {} + /** + * If true, the request will not be committed. + */ + // const validateOnly = true + + // Imports the Compute library + const {RegionSecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionSecurityPoliciesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + region, + securityPolicyResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionSecurityPolicies_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_security_policies.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_security_policies.list.js new file mode 100644 index 00000000000..611da94ddbd --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_security_policies.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionSecurityPolicies_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionSecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionSecurityPoliciesClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionSecurityPolicies_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_security_policies.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_security_policies.patch.js new file mode 100644 index 00000000000..1e10da8b3f5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_security_policies.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, securityPolicy, securityPolicyResource) { + // [START compute_v1_generated_RegionSecurityPolicies_Patch_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the security policy to update. + */ + // const securityPolicy = 'abc123' + /** + * The body resource for this request + */ + // const securityPolicyResource = {} + + // Imports the Compute library + const {RegionSecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionSecurityPoliciesClient(); + + async function callPatch() { + // Construct request + const request = { + project, + region, + securityPolicy, + securityPolicyResource, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_RegionSecurityPolicies_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_certificates.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_certificates.delete.js new file mode 100644 index 00000000000..2478f588481 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_certificates.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, sslCertificate) { + // [START compute_v1_generated_RegionSslCertificates_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the SslCertificate resource to delete. + */ + // const sslCertificate = 'abc123' + + // Imports the Compute library + const {RegionSslCertificatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionSslCertificatesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + region, + sslCertificate, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionSslCertificates_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_certificates.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_certificates.get.js new file mode 100644 index 00000000000..85efd40c316 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_certificates.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, sslCertificate) { + // [START compute_v1_generated_RegionSslCertificates_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Name of the SslCertificate resource to return. + */ + // const sslCertificate = 'abc123' + + // Imports the Compute library + const {RegionSslCertificatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionSslCertificatesClient(); + + async function callGet() { + // Construct request + const request = { + project, + region, + sslCertificate, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionSslCertificates_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_certificates.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_certificates.insert.js new file mode 100644 index 00000000000..a20ea6008da --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_certificates.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, sslCertificateResource) { + // [START compute_v1_generated_RegionSslCertificates_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const sslCertificateResource = {} + + // Imports the Compute library + const {RegionSslCertificatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionSslCertificatesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + region, + sslCertificateResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionSslCertificates_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_certificates.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_certificates.list.js new file mode 100644 index 00000000000..72e3125aed3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_certificates.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionSslCertificates_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionSslCertificatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionSslCertificatesClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionSslCertificates_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.delete.js new file mode 100644 index 00000000000..47e92f9d9ba --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, sslPolicy) { + // [START compute_v1_generated_RegionSslPolicies_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the SSL policy to delete. The name must be 1-63 characters long, and comply with RFC1035. + */ + // const sslPolicy = 'abc123' + + // Imports the Compute library + const {RegionSslPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionSslPoliciesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + region, + sslPolicy, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionSslPolicies_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.get.js new file mode 100644 index 00000000000..a6ac4fee03f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, sslPolicy) { + // [START compute_v1_generated_RegionSslPolicies_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Name of the SSL policy to update. The name must be 1-63 characters long, and comply with RFC1035. + */ + // const sslPolicy = 'abc123' + + // Imports the Compute library + const {RegionSslPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionSslPoliciesClient(); + + async function callGet() { + // Construct request + const request = { + project, + region, + sslPolicy, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionSslPolicies_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.insert.js new file mode 100644 index 00000000000..5b622435d3a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, sslPolicyResource) { + // [START compute_v1_generated_RegionSslPolicies_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const sslPolicyResource = {} + + // Imports the Compute library + const {RegionSslPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionSslPoliciesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + region, + sslPolicyResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionSslPolicies_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.list.js new file mode 100644 index 00000000000..e99f43e395e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionSslPolicies_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionSslPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionSslPoliciesClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionSslPolicies_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.list_available_features.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.list_available_features.js new file mode 100644 index 00000000000..88893b59ebd --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.list_available_features.js @@ -0,0 +1,86 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionSslPolicies_ListAvailableFeatures_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionSslPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionSslPoliciesClient(); + + async function callListAvailableFeatures() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const response = await computeClient.listAvailableFeatures(request); + console.log(response); + } + + callListAvailableFeatures(); + // [END compute_v1_generated_RegionSslPolicies_ListAvailableFeatures_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.patch.js new file mode 100644 index 00000000000..4dd37b299ac --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_ssl_policies.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, sslPolicy, sslPolicyResource) { + // [START compute_v1_generated_RegionSslPolicies_Patch_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the SSL policy to update. The name must be 1-63 characters long, and comply with RFC1035. + */ + // const sslPolicy = 'abc123' + /** + * The body resource for this request + */ + // const sslPolicyResource = {} + + // Imports the Compute library + const {RegionSslPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionSslPoliciesClient(); + + async function callPatch() { + // Construct request + const request = { + project, + region, + sslPolicy, + sslPolicyResource, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_RegionSslPolicies_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_http_proxies.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_http_proxies.delete.js new file mode 100644 index 00000000000..0ec08cd8b38 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_http_proxies.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, targetHttpProxy) { + // [START compute_v1_generated_RegionTargetHttpProxies_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetHttpProxy resource to delete. + */ + // const targetHttpProxy = 'abc123' + + // Imports the Compute library + const {RegionTargetHttpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionTargetHttpProxiesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + region, + targetHttpProxy, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionTargetHttpProxies_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_http_proxies.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_http_proxies.get.js new file mode 100644 index 00000000000..f599c3bdf4d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_http_proxies.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, targetHttpProxy) { + // [START compute_v1_generated_RegionTargetHttpProxies_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Name of the TargetHttpProxy resource to return. + */ + // const targetHttpProxy = 'abc123' + + // Imports the Compute library + const {RegionTargetHttpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionTargetHttpProxiesClient(); + + async function callGet() { + // Construct request + const request = { + project, + region, + targetHttpProxy, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionTargetHttpProxies_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_http_proxies.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_http_proxies.insert.js new file mode 100644 index 00000000000..c76195e00c2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_http_proxies.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, targetHttpProxyResource) { + // [START compute_v1_generated_RegionTargetHttpProxies_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetHttpProxyResource = {} + + // Imports the Compute library + const {RegionTargetHttpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionTargetHttpProxiesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + region, + targetHttpProxyResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionTargetHttpProxies_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_http_proxies.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_http_proxies.list.js new file mode 100644 index 00000000000..3ddb5f10e21 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_http_proxies.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionTargetHttpProxies_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionTargetHttpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionTargetHttpProxiesClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionTargetHttpProxies_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_http_proxies.set_url_map.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_http_proxies.set_url_map.js new file mode 100644 index 00000000000..ea612280429 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_http_proxies.set_url_map.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, targetHttpProxy, urlMapReferenceResource) { + // [START compute_v1_generated_RegionTargetHttpProxies_SetUrlMap_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetHttpProxy to set a URL map for. + */ + // const targetHttpProxy = 'abc123' + /** + * The body resource for this request + */ + // const urlMapReferenceResource = {} + + // Imports the Compute library + const {RegionTargetHttpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionTargetHttpProxiesClient(); + + async function callSetUrlMap() { + // Construct request + const request = { + project, + region, + targetHttpProxy, + urlMapReferenceResource, + }; + + // Run request + const response = await computeClient.setUrlMap(request); + console.log(response); + } + + callSetUrlMap(); + // [END compute_v1_generated_RegionTargetHttpProxies_SetUrlMap_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.delete.js new file mode 100644 index 00000000000..de7697faea2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, targetHttpsProxy) { + // [START compute_v1_generated_RegionTargetHttpsProxies_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetHttpsProxy resource to delete. + */ + // const targetHttpsProxy = 'abc123' + + // Imports the Compute library + const {RegionTargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionTargetHttpsProxiesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + region, + targetHttpsProxy, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionTargetHttpsProxies_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.get.js new file mode 100644 index 00000000000..9c14751ef37 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, targetHttpsProxy) { + // [START compute_v1_generated_RegionTargetHttpsProxies_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Name of the TargetHttpsProxy resource to return. + */ + // const targetHttpsProxy = 'abc123' + + // Imports the Compute library + const {RegionTargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionTargetHttpsProxiesClient(); + + async function callGet() { + // Construct request + const request = { + project, + region, + targetHttpsProxy, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionTargetHttpsProxies_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.insert.js new file mode 100644 index 00000000000..a8d04b5dd4d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, targetHttpsProxyResource) { + // [START compute_v1_generated_RegionTargetHttpsProxies_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetHttpsProxyResource = {} + + // Imports the Compute library + const {RegionTargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionTargetHttpsProxiesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + region, + targetHttpsProxyResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionTargetHttpsProxies_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.list.js new file mode 100644 index 00000000000..10333160123 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionTargetHttpsProxies_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionTargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionTargetHttpsProxiesClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionTargetHttpsProxies_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.patch.js new file mode 100644 index 00000000000..31b1bd03796 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, targetHttpsProxy, targetHttpsProxyResource) { + // [START compute_v1_generated_RegionTargetHttpsProxies_Patch_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetHttpsProxy resource to patch. + */ + // const targetHttpsProxy = 'abc123' + /** + * The body resource for this request + */ + // const targetHttpsProxyResource = {} + + // Imports the Compute library + const {RegionTargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionTargetHttpsProxiesClient(); + + async function callPatch() { + // Construct request + const request = { + project, + region, + targetHttpsProxy, + targetHttpsProxyResource, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_RegionTargetHttpsProxies_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.set_ssl_certificates.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.set_ssl_certificates.js new file mode 100644 index 00000000000..769d384486f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.set_ssl_certificates.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, regionTargetHttpsProxiesSetSslCertificatesRequestResource, targetHttpsProxy) { + // [START compute_v1_generated_RegionTargetHttpsProxies_SetSslCertificates_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionTargetHttpsProxiesSetSslCertificatesRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetHttpsProxy resource to set an SslCertificates resource for. + */ + // const targetHttpsProxy = 'abc123' + + // Imports the Compute library + const {RegionTargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionTargetHttpsProxiesClient(); + + async function callSetSslCertificates() { + // Construct request + const request = { + project, + region, + regionTargetHttpsProxiesSetSslCertificatesRequestResource, + targetHttpsProxy, + }; + + // Run request + const response = await computeClient.setSslCertificates(request); + console.log(response); + } + + callSetSslCertificates(); + // [END compute_v1_generated_RegionTargetHttpsProxies_SetSslCertificates_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.set_url_map.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.set_url_map.js new file mode 100644 index 00000000000..11a6e78bfc6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_https_proxies.set_url_map.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, targetHttpsProxy, urlMapReferenceResource) { + // [START compute_v1_generated_RegionTargetHttpsProxies_SetUrlMap_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetHttpsProxy to set a URL map for. + */ + // const targetHttpsProxy = 'abc123' + /** + * The body resource for this request + */ + // const urlMapReferenceResource = {} + + // Imports the Compute library + const {RegionTargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionTargetHttpsProxiesClient(); + + async function callSetUrlMap() { + // Construct request + const request = { + project, + region, + targetHttpsProxy, + urlMapReferenceResource, + }; + + // Run request + const response = await computeClient.setUrlMap(request); + console.log(response); + } + + callSetUrlMap(); + // [END compute_v1_generated_RegionTargetHttpsProxies_SetUrlMap_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_tcp_proxies.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_tcp_proxies.delete.js new file mode 100644 index 00000000000..29804476d68 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_tcp_proxies.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, targetTcpProxy) { + // [START compute_v1_generated_RegionTargetTcpProxies_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetTcpProxy resource to delete. + */ + // const targetTcpProxy = 'abc123' + + // Imports the Compute library + const {RegionTargetTcpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionTargetTcpProxiesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + region, + targetTcpProxy, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionTargetTcpProxies_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_tcp_proxies.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_tcp_proxies.get.js new file mode 100644 index 00000000000..001e56c4c1b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_tcp_proxies.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, targetTcpProxy) { + // [START compute_v1_generated_RegionTargetTcpProxies_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Name of the TargetTcpProxy resource to return. + */ + // const targetTcpProxy = 'abc123' + + // Imports the Compute library + const {RegionTargetTcpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionTargetTcpProxiesClient(); + + async function callGet() { + // Construct request + const request = { + project, + region, + targetTcpProxy, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionTargetTcpProxies_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_tcp_proxies.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_tcp_proxies.insert.js new file mode 100644 index 00000000000..34c45ee7bf3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_tcp_proxies.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, targetTcpProxyResource) { + // [START compute_v1_generated_RegionTargetTcpProxies_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetTcpProxyResource = {} + + // Imports the Compute library + const {RegionTargetTcpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionTargetTcpProxiesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + region, + targetTcpProxyResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionTargetTcpProxies_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_tcp_proxies.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_tcp_proxies.list.js new file mode 100644 index 00000000000..cd2243fd664 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_target_tcp_proxies.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionTargetTcpProxies_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionTargetTcpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionTargetTcpProxiesClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionTargetTcpProxies_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.delete.js new file mode 100644 index 00000000000..a11d8ed600b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, urlMap) { + // [START compute_v1_generated_RegionUrlMaps_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * begin_interface: MixerMutationRequestBuilder Request ID to support idempotency. + */ + // const requestId = 'abc123' + /** + * Name of the UrlMap resource to delete. + */ + // const urlMap = 'abc123' + + // Imports the Compute library + const {RegionUrlMapsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionUrlMapsClient(); + + async function callDelete() { + // Construct request + const request = { + project, + region, + urlMap, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_RegionUrlMaps_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.get.js new file mode 100644 index 00000000000..29098989e1f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, urlMap) { + // [START compute_v1_generated_RegionUrlMaps_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Name of the UrlMap resource to return. + */ + // const urlMap = 'abc123' + + // Imports the Compute library + const {RegionUrlMapsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionUrlMapsClient(); + + async function callGet() { + // Construct request + const request = { + project, + region, + urlMap, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_RegionUrlMaps_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.insert.js new file mode 100644 index 00000000000..0ca2e23940e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, urlMapResource) { + // [START compute_v1_generated_RegionUrlMaps_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * begin_interface: MixerMutationRequestBuilder Request ID to support idempotency. + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const urlMapResource = {} + + // Imports the Compute library + const {RegionUrlMapsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionUrlMapsClient(); + + async function callInsert() { + // Construct request + const request = { + project, + region, + urlMapResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_RegionUrlMaps_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.list.js new file mode 100644 index 00000000000..13d916cc6cc --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_RegionUrlMaps_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionUrlMapsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionUrlMapsClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_RegionUrlMaps_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.patch.js new file mode 100644 index 00000000000..cb9dd19197c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, urlMap, urlMapResource) { + // [START compute_v1_generated_RegionUrlMaps_Patch_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * begin_interface: MixerMutationRequestBuilder Request ID to support idempotency. + */ + // const requestId = 'abc123' + /** + * Name of the UrlMap resource to patch. + */ + // const urlMap = 'abc123' + /** + * The body resource for this request + */ + // const urlMapResource = {} + + // Imports the Compute library + const {RegionUrlMapsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionUrlMapsClient(); + + async function callPatch() { + // Construct request + const request = { + project, + region, + urlMap, + urlMapResource, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_RegionUrlMaps_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.update.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.update.js new file mode 100644 index 00000000000..de0fd4eff86 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.update.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, urlMap, urlMapResource) { + // [START compute_v1_generated_RegionUrlMaps_Update_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * begin_interface: MixerMutationRequestBuilder Request ID to support idempotency. + */ + // const requestId = 'abc123' + /** + * Name of the UrlMap resource to update. + */ + // const urlMap = 'abc123' + /** + * The body resource for this request + */ + // const urlMapResource = {} + + // Imports the Compute library + const {RegionUrlMapsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionUrlMapsClient(); + + async function callUpdate() { + // Construct request + const request = { + project, + region, + urlMap, + urlMapResource, + }; + + // Run request + const response = await computeClient.update(request); + console.log(response); + } + + callUpdate(); + // [END compute_v1_generated_RegionUrlMaps_Update_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.validate.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.validate.js new file mode 100644 index 00000000000..70673a7d972 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/region_url_maps.validate.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, regionUrlMapsValidateRequestResource, urlMap) { + // [START compute_v1_generated_RegionUrlMaps_Validate_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionUrlMapsValidateRequestResource = {} + /** + * Name of the UrlMap resource to be validated as. + */ + // const urlMap = 'abc123' + + // Imports the Compute library + const {RegionUrlMapsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionUrlMapsClient(); + + async function callValidate() { + // Construct request + const request = { + project, + region, + regionUrlMapsValidateRequestResource, + urlMap, + }; + + // Run request + const response = await computeClient.validate(request); + console.log(response); + } + + callValidate(); + // [END compute_v1_generated_RegionUrlMaps_Validate_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/regions.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/regions.get.js new file mode 100644 index 00000000000..32001785320 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/regions.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_Regions_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region resource to return. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionsClient(); + + async function callGet() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Regions_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/regions.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/regions.list.js new file mode 100644 index 00000000000..696b146a4a0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/regions.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Regions_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RegionsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RegionsClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_Regions_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.aggregated_list.js new file mode 100644 index 00000000000..582ee6944ea --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Reservations_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {ReservationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ReservationsClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_Reservations_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.delete.js new file mode 100644 index 00000000000..543b528888c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, reservation, zone) { + // [START compute_v1_generated_Reservations_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the reservation to delete. + */ + // const reservation = 'abc123' + /** + * Name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {ReservationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ReservationsClient(); + + async function callDelete() { + // Construct request + const request = { + project, + reservation, + zone, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_Reservations_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.get.js new file mode 100644 index 00000000000..b0a46018ff9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, reservation, zone) { + // [START compute_v1_generated_Reservations_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the reservation to retrieve. + */ + // const reservation = 'abc123' + /** + * Name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {ReservationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ReservationsClient(); + + async function callGet() { + // Construct request + const request = { + project, + reservation, + zone, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Reservations_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.get_iam_policy.js new file mode 100644 index 00000000000..ade281c5b31 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.get_iam_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, resource, zone) { + // [START compute_v1_generated_Reservations_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {ReservationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ReservationsClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + resource, + zone, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_Reservations_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.insert.js new file mode 100644 index 00000000000..60ccb70c5a4 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, reservationResource, zone) { + // [START compute_v1_generated_Reservations_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const reservationResource = {} + /** + * Name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {ReservationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ReservationsClient(); + + async function callInsert() { + // Construct request + const request = { + project, + reservationResource, + zone, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_Reservations_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.list.js new file mode 100644 index 00000000000..7583dffe0a4 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, zone) { + // [START compute_v1_generated_Reservations_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * Name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {ReservationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ReservationsClient(); + + async function callList() { + // Construct request + const request = { + project, + zone, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_Reservations_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.resize.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.resize.js new file mode 100644 index 00000000000..c688e72cf52 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.resize.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, reservation, reservationsResizeRequestResource, zone) { + // [START compute_v1_generated_Reservations_Resize_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the reservation to update. + */ + // const reservation = 'abc123' + /** + * The body resource for this request + */ + // const reservationsResizeRequestResource = {} + /** + * Name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {ReservationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ReservationsClient(); + + async function callResize() { + // Construct request + const request = { + project, + reservation, + reservationsResizeRequestResource, + zone, + }; + + // Run request + const response = await computeClient.resize(request); + console.log(response); + } + + callResize(); + // [END compute_v1_generated_Reservations_Resize_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.set_iam_policy.js new file mode 100644 index 00000000000..fdd20058896 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.set_iam_policy.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, resource, zone, zoneSetPolicyRequestResource) { + // [START compute_v1_generated_Reservations_SetIamPolicy_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + /** + * The body resource for this request + */ + // const zoneSetPolicyRequestResource = {} + + // Imports the Compute library + const {ReservationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ReservationsClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + project, + resource, + zone, + zoneSetPolicyRequestResource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_Reservations_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.test_iam_permissions.js new file mode 100644 index 00000000000..a0fb1a5c70c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.test_iam_permissions.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, resource, testPermissionsRequestResource, zone) { + // [START compute_v1_generated_Reservations_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + /** + * The name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {ReservationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ReservationsClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + resource, + testPermissionsRequestResource, + zone, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_Reservations_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.update.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.update.js new file mode 100644 index 00000000000..2d79bc7b220 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/reservations.update.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project, reservation, reservationResource, zone) { + // [START compute_v1_generated_Reservations_Update_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 paths = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the reservation to update. + */ + // const reservation = 'abc123' + /** + * The body resource for this request + */ + // const reservationResource = {} + /** + * Update_mask indicates fields to be updated as part of this request. + */ + // const updateMask = 'abc123' + /** + * Name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {ReservationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ReservationsClient(); + + async function callUpdate() { + // Construct request + const request = { + project, + reservation, + reservationResource, + zone, + }; + + // Run request + const response = await computeClient.update(request); + console.log(response); + } + + callUpdate(); + // [END compute_v1_generated_Reservations_Update_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.aggregated_list.js new file mode 100644 index 00000000000..62f41ac17d7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_ResourcePolicies_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {ResourcePoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ResourcePoliciesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_ResourcePolicies_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.delete.js new file mode 100644 index 00000000000..0cf7412fa4d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, resourcePolicy) { + // [START compute_v1_generated_ResourcePolicies_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the resource policy to delete. + */ + // const resourcePolicy = 'abc123' + + // Imports the Compute library + const {ResourcePoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ResourcePoliciesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + region, + resourcePolicy, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_ResourcePolicies_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.get.js new file mode 100644 index 00000000000..8c3d49f604b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, resourcePolicy) { + // [START compute_v1_generated_ResourcePolicies_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name of the resource policy to retrieve. + */ + // const resourcePolicy = 'abc123' + + // Imports the Compute library + const {ResourcePoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ResourcePoliciesClient(); + + async function callGet() { + // Construct request + const request = { + project, + region, + resourcePolicy, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_ResourcePolicies_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.get_iam_policy.js new file mode 100644 index 00000000000..7c32644f12a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.get_iam_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, resource) { + // [START compute_v1_generated_ResourcePolicies_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {ResourcePoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ResourcePoliciesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + region, + resource, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_ResourcePolicies_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.insert.js new file mode 100644 index 00000000000..01a7b13442c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, resourcePolicyResource) { + // [START compute_v1_generated_ResourcePolicies_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const resourcePolicyResource = {} + + // Imports the Compute library + const {ResourcePoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ResourcePoliciesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + region, + resourcePolicyResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_ResourcePolicies_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.list.js new file mode 100644 index 00000000000..0460854b2f6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_ResourcePolicies_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {ResourcePoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ResourcePoliciesClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_ResourcePolicies_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.set_iam_policy.js new file mode 100644 index 00000000000..0f1aceae078 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.set_iam_policy.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, regionSetPolicyRequestResource, resource) { + // [START compute_v1_generated_ResourcePolicies_SetIamPolicy_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionSetPolicyRequestResource = {} + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {ResourcePoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ResourcePoliciesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + project, + region, + regionSetPolicyRequestResource, + resource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_ResourcePolicies_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.test_iam_permissions.js new file mode 100644 index 00000000000..d125ea3daea --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/resource_policies.test_iam_permissions.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_ResourcePolicies_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {ResourcePoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ResourcePoliciesClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + region, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_ResourcePolicies_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.aggregated_list.js new file mode 100644 index 00000000000..d9df2c111ee --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Routers_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RoutersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RoutersClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_Routers_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.delete.js new file mode 100644 index 00000000000..8e314525f86 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, router) { + // [START compute_v1_generated_Routers_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the Router resource to delete. + */ + // const router = 'abc123' + + // Imports the Compute library + const {RoutersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RoutersClient(); + + async function callDelete() { + // Construct request + const request = { + project, + region, + router, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_Routers_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.get.js new file mode 100644 index 00000000000..2ab9a40decd --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, router) { + // [START compute_v1_generated_Routers_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name of the Router resource to return. + */ + // const router = 'abc123' + + // Imports the Compute library + const {RoutersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RoutersClient(); + + async function callGet() { + // Construct request + const request = { + project, + region, + router, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Routers_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.get_nat_mapping_info.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.get_nat_mapping_info.js new file mode 100644 index 00000000000..d37ebbfd3c0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.get_nat_mapping_info.js @@ -0,0 +1,93 @@ +// Copyright 2023 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(project, region, router) { + // [START compute_v1_generated_Routers_GetNatMappingInfo_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * Name of the Router resource to query for Nat Mapping information of VM endpoints. + */ + // const router = 'abc123' + + // Imports the Compute library + const {RoutersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RoutersClient(); + + async function callGetNatMappingInfo() { + // Construct request + const request = { + project, + region, + router, + }; + + // Run request + const iterable = await computeClient.getNatMappingInfoAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callGetNatMappingInfo(); + // [END compute_v1_generated_Routers_GetNatMappingInfo_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.get_router_status.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.get_router_status.js new file mode 100644 index 00000000000..52a46d156d4 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.get_router_status.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, router) { + // [START compute_v1_generated_Routers_GetRouterStatus_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name of the Router resource to query. + */ + // const router = 'abc123' + + // Imports the Compute library + const {RoutersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RoutersClient(); + + async function callGetRouterStatus() { + // Construct request + const request = { + project, + region, + router, + }; + + // Run request + const response = await computeClient.getRouterStatus(request); + console.log(response); + } + + callGetRouterStatus(); + // [END compute_v1_generated_Routers_GetRouterStatus_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.insert.js new file mode 100644 index 00000000000..a596e98fb67 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, routerResource) { + // [START compute_v1_generated_Routers_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const routerResource = {} + + // Imports the Compute library + const {RoutersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RoutersClient(); + + async function callInsert() { + // Construct request + const request = { + project, + region, + routerResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_Routers_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.list.js new file mode 100644 index 00000000000..b7c0749fdec --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_Routers_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RoutersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RoutersClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_Routers_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.patch.js new file mode 100644 index 00000000000..69c0b4e23ac --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, router, routerResource) { + // [START compute_v1_generated_Routers_Patch_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the Router resource to patch. + */ + // const router = 'abc123' + /** + * The body resource for this request + */ + // const routerResource = {} + + // Imports the Compute library + const {RoutersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RoutersClient(); + + async function callPatch() { + // Construct request + const request = { + project, + region, + router, + routerResource, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_Routers_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.preview.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.preview.js new file mode 100644 index 00000000000..d5e1c25214a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.preview.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, router, routerResource) { + // [START compute_v1_generated_Routers_Preview_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name of the Router resource to query. + */ + // const router = 'abc123' + /** + * The body resource for this request + */ + // const routerResource = {} + + // Imports the Compute library + const {RoutersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RoutersClient(); + + async function callPreview() { + // Construct request + const request = { + project, + region, + router, + routerResource, + }; + + // Run request + const response = await computeClient.preview(request); + console.log(response); + } + + callPreview(); + // [END compute_v1_generated_Routers_Preview_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.update.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.update.js new file mode 100644 index 00000000000..fb33d2dce25 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routers.update.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, router, routerResource) { + // [START compute_v1_generated_Routers_Update_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the Router resource to update. + */ + // const router = 'abc123' + /** + * The body resource for this request + */ + // const routerResource = {} + + // Imports the Compute library + const {RoutersClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RoutersClient(); + + async function callUpdate() { + // Construct request + const request = { + project, + region, + router, + routerResource, + }; + + // Run request + const response = await computeClient.update(request); + console.log(response); + } + + callUpdate(); + // [END compute_v1_generated_Routers_Update_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routes.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routes.delete.js new file mode 100644 index 00000000000..df27a1fbc3e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routes.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, route) { + // [START compute_v1_generated_Routes_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the Route resource to delete. + */ + // const route = 'abc123' + + // Imports the Compute library + const {RoutesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RoutesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + route, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_Routes_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routes.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routes.get.js new file mode 100644 index 00000000000..216edc26114 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routes.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(project, route) { + // [START compute_v1_generated_Routes_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the Route resource to return. + */ + // const route = 'abc123' + + // Imports the Compute library + const {RoutesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RoutesClient(); + + async function callGet() { + // Construct request + const request = { + project, + route, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Routes_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routes.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routes.insert.js new file mode 100644 index 00000000000..0dbf324a344 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routes.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, routeResource) { + // [START compute_v1_generated_Routes_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const routeResource = {} + + // Imports the Compute library + const {RoutesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RoutesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + routeResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_Routes_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routes.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routes.list.js new file mode 100644 index 00000000000..a688574d80a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/routes.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Routes_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {RoutesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new RoutesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_Routes_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.add_rule.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.add_rule.js new file mode 100644 index 00000000000..a93cb3625c6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.add_rule.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, securityPolicy, securityPolicyRuleResource) { + // [START compute_v1_generated_SecurityPolicies_AddRule_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the security policy to update. + */ + // const securityPolicy = 'abc123' + /** + * The body resource for this request + */ + // const securityPolicyRuleResource = {} + /** + * If true, the request will not be committed. + */ + // const validateOnly = true + + // Imports the Compute library + const {SecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SecurityPoliciesClient(); + + async function callAddRule() { + // Construct request + const request = { + project, + securityPolicy, + securityPolicyRuleResource, + }; + + // Run request + const response = await computeClient.addRule(request); + console.log(response); + } + + callAddRule(); + // [END compute_v1_generated_SecurityPolicies_AddRule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.aggregated_list.js new file mode 100644 index 00000000000..8f5efd6a0e2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_SecurityPolicies_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Name of the project scoping this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {SecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SecurityPoliciesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_SecurityPolicies_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.delete.js new file mode 100644 index 00000000000..91566a98ca7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, securityPolicy) { + // [START compute_v1_generated_SecurityPolicies_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the security policy to delete. + */ + // const securityPolicy = 'abc123' + + // Imports the Compute library + const {SecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SecurityPoliciesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + securityPolicy, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_SecurityPolicies_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.get.js new file mode 100644 index 00000000000..8266b22694d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(project, securityPolicy) { + // [START compute_v1_generated_SecurityPolicies_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the security policy to get. + */ + // const securityPolicy = 'abc123' + + // Imports the Compute library + const {SecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SecurityPoliciesClient(); + + async function callGet() { + // Construct request + const request = { + project, + securityPolicy, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_SecurityPolicies_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.get_rule.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.get_rule.js new file mode 100644 index 00000000000..f447a99c532 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.get_rule.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, securityPolicy) { + // [START compute_v1_generated_SecurityPolicies_GetRule_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. + */ + /** + * The priority of the rule to get from the security policy. + */ + // const priority = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the security policy to which the queried rule belongs. + */ + // const securityPolicy = 'abc123' + + // Imports the Compute library + const {SecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SecurityPoliciesClient(); + + async function callGetRule() { + // Construct request + const request = { + project, + securityPolicy, + }; + + // Run request + const response = await computeClient.getRule(request); + console.log(response); + } + + callGetRule(); + // [END compute_v1_generated_SecurityPolicies_GetRule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.insert.js new file mode 100644 index 00000000000..7faf3685405 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.insert.js @@ -0,0 +1,74 @@ +// Copyright 2023 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(project, securityPolicyResource) { + // [START compute_v1_generated_SecurityPolicies_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const securityPolicyResource = {} + /** + * If true, the request will not be committed. + */ + // const validateOnly = true + + // Imports the Compute library + const {SecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SecurityPoliciesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + securityPolicyResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_SecurityPolicies_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.list.js new file mode 100644 index 00000000000..6ee19ebb552 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_SecurityPolicies_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {SecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SecurityPoliciesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_SecurityPolicies_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.list_preconfigured_expression_sets.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.list_preconfigured_expression_sets.js new file mode 100644 index 00000000000..0cd166274e6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.list_preconfigured_expression_sets.js @@ -0,0 +1,81 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_SecurityPolicies_ListPreconfiguredExpressionSets_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {SecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SecurityPoliciesClient(); + + async function callListPreconfiguredExpressionSets() { + // Construct request + const request = { + project, + }; + + // Run request + const response = await computeClient.listPreconfiguredExpressionSets(request); + console.log(response); + } + + callListPreconfiguredExpressionSets(); + // [END compute_v1_generated_SecurityPolicies_ListPreconfiguredExpressionSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.patch.js new file mode 100644 index 00000000000..534fdbe1d9e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, securityPolicy, securityPolicyResource) { + // [START compute_v1_generated_SecurityPolicies_Patch_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the security policy to update. + */ + // const securityPolicy = 'abc123' + /** + * The body resource for this request + */ + // const securityPolicyResource = {} + + // Imports the Compute library + const {SecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SecurityPoliciesClient(); + + async function callPatch() { + // Construct request + const request = { + project, + securityPolicy, + securityPolicyResource, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_SecurityPolicies_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.patch_rule.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.patch_rule.js new file mode 100644 index 00000000000..626a04e0a03 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.patch_rule.js @@ -0,0 +1,79 @@ +// Copyright 2023 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(project, securityPolicy, securityPolicyRuleResource) { + // [START compute_v1_generated_SecurityPolicies_PatchRule_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. + */ + /** + * The priority of the rule to patch. + */ + // const priority = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the security policy to update. + */ + // const securityPolicy = 'abc123' + /** + * The body resource for this request + */ + // const securityPolicyRuleResource = {} + /** + * If true, the request will not be committed. + */ + // const validateOnly = true + + // Imports the Compute library + const {SecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SecurityPoliciesClient(); + + async function callPatchRule() { + // Construct request + const request = { + project, + securityPolicy, + securityPolicyRuleResource, + }; + + // Run request + const response = await computeClient.patchRule(request); + console.log(response); + } + + callPatchRule(); + // [END compute_v1_generated_SecurityPolicies_PatchRule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.remove_rule.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.remove_rule.js new file mode 100644 index 00000000000..ec1b8bb985c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.remove_rule.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, securityPolicy) { + // [START compute_v1_generated_SecurityPolicies_RemoveRule_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. + */ + /** + * The priority of the rule to remove from the security policy. + */ + // const priority = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the security policy to update. + */ + // const securityPolicy = 'abc123' + + // Imports the Compute library + const {SecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SecurityPoliciesClient(); + + async function callRemoveRule() { + // Construct request + const request = { + project, + securityPolicy, + }; + + // Run request + const response = await computeClient.removeRule(request); + console.log(response); + } + + callRemoveRule(); + // [END compute_v1_generated_SecurityPolicies_RemoveRule_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.set_labels.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.set_labels.js new file mode 100644 index 00000000000..fcf5f900e62 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/security_policies.set_labels.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(globalSetLabelsRequestResource, project, resource) { + // [START compute_v1_generated_SecurityPolicies_SetLabels_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. + */ + /** + * The body resource for this request + */ + // const globalSetLabelsRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {SecurityPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SecurityPoliciesClient(); + + async function callSetLabels() { + // Construct request + const request = { + globalSetLabelsRequestResource, + project, + resource, + }; + + // Run request + const response = await computeClient.setLabels(request); + console.log(response); + } + + callSetLabels(); + // [END compute_v1_generated_SecurityPolicies_SetLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.aggregated_list.js new file mode 100644 index 00000000000..c112a0a3d6c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_ServiceAttachments_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Name of the project scoping this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {ServiceAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ServiceAttachmentsClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_ServiceAttachments_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.delete.js new file mode 100644 index 00000000000..a2fb096db45 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, serviceAttachment) { + // [START compute_v1_generated_ServiceAttachments_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region of this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the ServiceAttachment resource to delete. + */ + // const serviceAttachment = 'abc123' + + // Imports the Compute library + const {ServiceAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ServiceAttachmentsClient(); + + async function callDelete() { + // Construct request + const request = { + project, + region, + serviceAttachment, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_ServiceAttachments_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.get.js new file mode 100644 index 00000000000..92a97573774 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, serviceAttachment) { + // [START compute_v1_generated_ServiceAttachments_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region of this request. + */ + // const region = 'us-central1' + /** + * Name of the ServiceAttachment resource to return. + */ + // const serviceAttachment = 'abc123' + + // Imports the Compute library + const {ServiceAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ServiceAttachmentsClient(); + + async function callGet() { + // Construct request + const request = { + project, + region, + serviceAttachment, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_ServiceAttachments_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.get_iam_policy.js new file mode 100644 index 00000000000..aa9f84f82eb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.get_iam_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, resource) { + // [START compute_v1_generated_ServiceAttachments_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {ServiceAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ServiceAttachmentsClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + region, + resource, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_ServiceAttachments_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.insert.js new file mode 100644 index 00000000000..1b3b122c22a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, serviceAttachmentResource) { + // [START compute_v1_generated_ServiceAttachments_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region of this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const serviceAttachmentResource = {} + + // Imports the Compute library + const {ServiceAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ServiceAttachmentsClient(); + + async function callInsert() { + // Construct request + const request = { + project, + region, + serviceAttachmentResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_ServiceAttachments_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.list.js new file mode 100644 index 00000000000..04c342dd665 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_ServiceAttachments_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region of this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {ServiceAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ServiceAttachmentsClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_ServiceAttachments_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.patch.js new file mode 100644 index 00000000000..3759410f3c7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.patch.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, serviceAttachment, serviceAttachmentResource) { + // [START compute_v1_generated_ServiceAttachments_Patch_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The region scoping this request and should conform to RFC1035. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The resource id of the ServiceAttachment to patch. It should conform to RFC1035 resource name or be a string form on an unsigned long number. + */ + // const serviceAttachment = 'abc123' + /** + * The body resource for this request + */ + // const serviceAttachmentResource = {} + + // Imports the Compute library + const {ServiceAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ServiceAttachmentsClient(); + + async function callPatch() { + // Construct request + const request = { + project, + region, + serviceAttachment, + serviceAttachmentResource, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_ServiceAttachments_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.set_iam_policy.js new file mode 100644 index 00000000000..0f21a286e6c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.set_iam_policy.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, regionSetPolicyRequestResource, resource) { + // [START compute_v1_generated_ServiceAttachments_SetIamPolicy_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionSetPolicyRequestResource = {} + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {ServiceAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ServiceAttachmentsClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + project, + region, + regionSetPolicyRequestResource, + resource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_ServiceAttachments_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.test_iam_permissions.js new file mode 100644 index 00000000000..e4d18a9f7f3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/service_attachments.test_iam_permissions.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_ServiceAttachments_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {ServiceAttachmentsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ServiceAttachmentsClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + region, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_ServiceAttachments_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.delete.js new file mode 100644 index 00000000000..d7928bf446e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, snapshot) { + // [START compute_v1_generated_Snapshots_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the Snapshot resource to delete. + */ + // const snapshot = 'abc123' + + // Imports the Compute library + const {SnapshotsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SnapshotsClient(); + + async function callDelete() { + // Construct request + const request = { + project, + snapshot, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_Snapshots_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.get.js new file mode 100644 index 00000000000..2b45d004864 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(project, snapshot) { + // [START compute_v1_generated_Snapshots_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the Snapshot resource to return. + */ + // const snapshot = 'abc123' + + // Imports the Compute library + const {SnapshotsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SnapshotsClient(); + + async function callGet() { + // Construct request + const request = { + project, + snapshot, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Snapshots_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.get_iam_policy.js new file mode 100644 index 00000000000..8e5a8f6944d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.get_iam_policy.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, resource) { + // [START compute_v1_generated_Snapshots_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {SnapshotsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SnapshotsClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + resource, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_Snapshots_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.insert.js new file mode 100644 index 00000000000..0b8fd7877c4 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, snapshotResource) { + // [START compute_v1_generated_Snapshots_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const snapshotResource = {} + + // Imports the Compute library + const {SnapshotsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SnapshotsClient(); + + async function callInsert() { + // Construct request + const request = { + project, + snapshotResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_Snapshots_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.list.js new file mode 100644 index 00000000000..275565a25fa --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Snapshots_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {SnapshotsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SnapshotsClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_Snapshots_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.set_iam_policy.js new file mode 100644 index 00000000000..56bde27c482 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.set_iam_policy.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(globalSetPolicyRequestResource, project, resource) { + // [START compute_v1_generated_Snapshots_SetIamPolicy_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. + */ + /** + * The body resource for this request + */ + // const globalSetPolicyRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {SnapshotsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SnapshotsClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + globalSetPolicyRequestResource, + project, + resource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_Snapshots_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.set_labels.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.set_labels.js new file mode 100644 index 00000000000..372b824664c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.set_labels.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(globalSetLabelsRequestResource, project, resource) { + // [START compute_v1_generated_Snapshots_SetLabels_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. + */ + /** + * The body resource for this request + */ + // const globalSetLabelsRequestResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {SnapshotsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SnapshotsClient(); + + async function callSetLabels() { + // Construct request + const request = { + globalSetLabelsRequestResource, + project, + resource, + }; + + // Run request + const response = await computeClient.setLabels(request); + console.log(response); + } + + callSetLabels(); + // [END compute_v1_generated_Snapshots_SetLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.test_iam_permissions.js new file mode 100644 index 00000000000..bd62e709fe3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snapshots.test_iam_permissions.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_Snapshots_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {SnapshotsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SnapshotsClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_Snapshots_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snippet_metadata.google.cloud.compute.v1.json b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snippet_metadata.google.cloud.compute.v1.json new file mode 100644 index 00000000000..b80334589f4 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/snippet_metadata.google.cloud.compute.v1.json @@ -0,0 +1,36887 @@ +{ + "clientLibrary": { + "name": "nodejs-compute", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.compute.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "compute_v1_generated_AcceleratorTypes_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of accelerator types.", + "canonical": true, + "file": "accelerator_types.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.AcceleratorTypes.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.AcceleratorTypeAggregatedList", + "client": { + "shortName": "AcceleratorTypesClient", + "fullName": "google.cloud.compute.v1.AcceleratorTypesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.AcceleratorTypes.AggregatedList", + "service": { + "shortName": "AcceleratorTypes", + "fullName": "google.cloud.compute.v1.AcceleratorTypes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_AcceleratorTypes_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified accelerator type.", + "canonical": true, + "file": "accelerator_types.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.AcceleratorTypes.Get", + "async": true, + "parameters": [ + { + "name": "accelerator_type", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.AcceleratorType", + "client": { + "shortName": "AcceleratorTypesClient", + "fullName": "google.cloud.compute.v1.AcceleratorTypesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.AcceleratorTypes.Get", + "service": { + "shortName": "AcceleratorTypes", + "fullName": "google.cloud.compute.v1.AcceleratorTypes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_AcceleratorTypes_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of accelerator types that are available to the specified project.", + "canonical": true, + "file": "accelerator_types.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.AcceleratorTypes.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.AcceleratorTypeList", + "client": { + "shortName": "AcceleratorTypesClient", + "fullName": "google.cloud.compute.v1.AcceleratorTypesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.AcceleratorTypes.List", + "service": { + "shortName": "AcceleratorTypes", + "fullName": "google.cloud.compute.v1.AcceleratorTypes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Addresses_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of addresses.", + "canonical": true, + "file": "addresses.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.Addresses.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.AddressAggregatedList", + "client": { + "shortName": "AddressesClient", + "fullName": "google.cloud.compute.v1.AddressesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.Addresses.AggregatedList", + "service": { + "shortName": "Addresses", + "fullName": "google.cloud.compute.v1.Addresses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Addresses_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified address resource.", + "canonical": true, + "file": "addresses.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Addresses.Delete", + "async": true, + "parameters": [ + { + "name": "address", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "AddressesClient", + "fullName": "google.cloud.compute.v1.AddressesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Addresses.Delete", + "service": { + "shortName": "Addresses", + "fullName": "google.cloud.compute.v1.Addresses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Addresses_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified address resource.", + "canonical": true, + "file": "addresses.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Addresses.Get", + "async": true, + "parameters": [ + { + "name": "address", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Address", + "client": { + "shortName": "AddressesClient", + "fullName": "google.cloud.compute.v1.AddressesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Addresses.Get", + "service": { + "shortName": "Addresses", + "fullName": "google.cloud.compute.v1.Addresses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Addresses_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates an address resource in the specified project by using the data included in the request.", + "canonical": true, + "file": "addresses.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Addresses.Insert", + "async": true, + "parameters": [ + { + "name": "address_resource", + "type": ".google.cloud.compute.v1.Address" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "AddressesClient", + "fullName": "google.cloud.compute.v1.AddressesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Addresses.Insert", + "service": { + "shortName": "Addresses", + "fullName": "google.cloud.compute.v1.Addresses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Addresses_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of addresses contained within the specified region.", + "canonical": true, + "file": "addresses.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Addresses.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.AddressList", + "client": { + "shortName": "AddressesClient", + "fullName": "google.cloud.compute.v1.AddressesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Addresses.List", + "service": { + "shortName": "Addresses", + "fullName": "google.cloud.compute.v1.Addresses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Addresses_SetLabels_async", + "title": "AcceleratorTypes setLabels Sample", + "origin": "API_DEFINITION", + "description": " Sets the labels on an Address. To learn more about labels, read the Labeling Resources documentation.", + "canonical": true, + "file": "addresses.set_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.Addresses.SetLabels", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_set_labels_request_resource", + "type": ".google.cloud.compute.v1.RegionSetLabelsRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "AddressesClient", + "fullName": "google.cloud.compute.v1.AddressesClient" + }, + "method": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.Addresses.SetLabels", + "service": { + "shortName": "Addresses", + "fullName": "google.cloud.compute.v1.Addresses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Autoscalers_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of autoscalers.", + "canonical": true, + "file": "autoscalers.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.Autoscalers.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.AutoscalerAggregatedList", + "client": { + "shortName": "AutoscalersClient", + "fullName": "google.cloud.compute.v1.AutoscalersClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.Autoscalers.AggregatedList", + "service": { + "shortName": "Autoscalers", + "fullName": "google.cloud.compute.v1.Autoscalers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Autoscalers_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified autoscaler.", + "canonical": true, + "file": "autoscalers.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Autoscalers.Delete", + "async": true, + "parameters": [ + { + "name": "autoscaler", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "AutoscalersClient", + "fullName": "google.cloud.compute.v1.AutoscalersClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Autoscalers.Delete", + "service": { + "shortName": "Autoscalers", + "fullName": "google.cloud.compute.v1.Autoscalers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Autoscalers_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified autoscaler resource.", + "canonical": true, + "file": "autoscalers.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Autoscalers.Get", + "async": true, + "parameters": [ + { + "name": "autoscaler", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Autoscaler", + "client": { + "shortName": "AutoscalersClient", + "fullName": "google.cloud.compute.v1.AutoscalersClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Autoscalers.Get", + "service": { + "shortName": "Autoscalers", + "fullName": "google.cloud.compute.v1.Autoscalers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Autoscalers_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates an autoscaler in the specified project using the data included in the request.", + "canonical": true, + "file": "autoscalers.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Autoscalers.Insert", + "async": true, + "parameters": [ + { + "name": "autoscaler_resource", + "type": ".google.cloud.compute.v1.Autoscaler" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "AutoscalersClient", + "fullName": "google.cloud.compute.v1.AutoscalersClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Autoscalers.Insert", + "service": { + "shortName": "Autoscalers", + "fullName": "google.cloud.compute.v1.Autoscalers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Autoscalers_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of autoscalers contained within the specified zone.", + "canonical": true, + "file": "autoscalers.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Autoscalers.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.AutoscalerList", + "client": { + "shortName": "AutoscalersClient", + "fullName": "google.cloud.compute.v1.AutoscalersClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Autoscalers.List", + "service": { + "shortName": "Autoscalers", + "fullName": "google.cloud.compute.v1.Autoscalers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Autoscalers_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Updates an autoscaler in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.", + "canonical": true, + "file": "autoscalers.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.Autoscalers.Patch", + "async": true, + "parameters": [ + { + "name": "autoscaler", + "type": "TYPE_STRING" + }, + { + "name": "autoscaler_resource", + "type": ".google.cloud.compute.v1.Autoscaler" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "AutoscalersClient", + "fullName": "google.cloud.compute.v1.AutoscalersClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.Autoscalers.Patch", + "service": { + "shortName": "Autoscalers", + "fullName": "google.cloud.compute.v1.Autoscalers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Autoscalers_Update_async", + "title": "AcceleratorTypes update Sample", + "origin": "API_DEFINITION", + "description": " Updates an autoscaler in the specified project using the data included in the request.", + "canonical": true, + "file": "autoscalers.update.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.Autoscalers.Update", + "async": true, + "parameters": [ + { + "name": "autoscaler", + "type": "TYPE_STRING" + }, + { + "name": "autoscaler_resource", + "type": ".google.cloud.compute.v1.Autoscaler" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "AutoscalersClient", + "fullName": "google.cloud.compute.v1.AutoscalersClient" + }, + "method": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.Autoscalers.Update", + "service": { + "shortName": "Autoscalers", + "fullName": "google.cloud.compute.v1.Autoscalers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendBuckets_AddSignedUrlKey_async", + "title": "AcceleratorTypes addSignedUrlKey Sample", + "origin": "API_DEFINITION", + "description": " Adds a key for validating requests with signed URLs for this backend bucket.", + "canonical": true, + "file": "backend_buckets.add_signed_url_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddSignedUrlKey", + "fullName": "google.cloud.compute.v1.BackendBuckets.AddSignedUrlKey", + "async": true, + "parameters": [ + { + "name": "backend_bucket", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "signed_url_key_resource", + "type": ".google.cloud.compute.v1.SignedUrlKey" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "BackendBucketsClient", + "fullName": "google.cloud.compute.v1.BackendBucketsClient" + }, + "method": { + "shortName": "AddSignedUrlKey", + "fullName": "google.cloud.compute.v1.BackendBuckets.AddSignedUrlKey", + "service": { + "shortName": "BackendBuckets", + "fullName": "google.cloud.compute.v1.BackendBuckets" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendBuckets_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified BackendBucket resource.", + "canonical": true, + "file": "backend_buckets.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.BackendBuckets.Delete", + "async": true, + "parameters": [ + { + "name": "backend_bucket", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "BackendBucketsClient", + "fullName": "google.cloud.compute.v1.BackendBucketsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.BackendBuckets.Delete", + "service": { + "shortName": "BackendBuckets", + "fullName": "google.cloud.compute.v1.BackendBuckets" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendBuckets_DeleteSignedUrlKey_async", + "title": "AcceleratorTypes deleteSignedUrlKey Sample", + "origin": "API_DEFINITION", + "description": " Deletes a key for validating requests with signed URLs for this backend bucket.", + "canonical": true, + "file": "backend_buckets.delete_signed_url_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteSignedUrlKey", + "fullName": "google.cloud.compute.v1.BackendBuckets.DeleteSignedUrlKey", + "async": true, + "parameters": [ + { + "name": "backend_bucket", + "type": "TYPE_STRING" + }, + { + "name": "key_name", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "BackendBucketsClient", + "fullName": "google.cloud.compute.v1.BackendBucketsClient" + }, + "method": { + "shortName": "DeleteSignedUrlKey", + "fullName": "google.cloud.compute.v1.BackendBuckets.DeleteSignedUrlKey", + "service": { + "shortName": "BackendBuckets", + "fullName": "google.cloud.compute.v1.BackendBuckets" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendBuckets_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified BackendBucket resource.", + "canonical": true, + "file": "backend_buckets.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.BackendBuckets.Get", + "async": true, + "parameters": [ + { + "name": "backend_bucket", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.BackendBucket", + "client": { + "shortName": "BackendBucketsClient", + "fullName": "google.cloud.compute.v1.BackendBucketsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.BackendBuckets.Get", + "service": { + "shortName": "BackendBuckets", + "fullName": "google.cloud.compute.v1.BackendBuckets" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendBuckets_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a BackendBucket resource in the specified project using the data included in the request.", + "canonical": true, + "file": "backend_buckets.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.BackendBuckets.Insert", + "async": true, + "parameters": [ + { + "name": "backend_bucket_resource", + "type": ".google.cloud.compute.v1.BackendBucket" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "BackendBucketsClient", + "fullName": "google.cloud.compute.v1.BackendBucketsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.BackendBuckets.Insert", + "service": { + "shortName": "BackendBuckets", + "fullName": "google.cloud.compute.v1.BackendBuckets" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendBuckets_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of BackendBucket resources available to the specified project.", + "canonical": true, + "file": "backend_buckets.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.BackendBuckets.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.BackendBucketList", + "client": { + "shortName": "BackendBucketsClient", + "fullName": "google.cloud.compute.v1.BackendBucketsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.BackendBuckets.List", + "service": { + "shortName": "BackendBuckets", + "fullName": "google.cloud.compute.v1.BackendBuckets" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendBuckets_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified BackendBucket resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.", + "canonical": true, + "file": "backend_buckets.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.BackendBuckets.Patch", + "async": true, + "parameters": [ + { + "name": "backend_bucket", + "type": "TYPE_STRING" + }, + { + "name": "backend_bucket_resource", + "type": ".google.cloud.compute.v1.BackendBucket" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "BackendBucketsClient", + "fullName": "google.cloud.compute.v1.BackendBucketsClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.BackendBuckets.Patch", + "service": { + "shortName": "BackendBuckets", + "fullName": "google.cloud.compute.v1.BackendBuckets" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendBuckets_SetEdgeSecurityPolicy_async", + "title": "AcceleratorTypes setEdgeSecurityPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the edge security policy for the specified backend bucket.", + "canonical": true, + "file": "backend_buckets.set_edge_security_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetEdgeSecurityPolicy", + "fullName": "google.cloud.compute.v1.BackendBuckets.SetEdgeSecurityPolicy", + "async": true, + "parameters": [ + { + "name": "backend_bucket", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "security_policy_reference_resource", + "type": ".google.cloud.compute.v1.SecurityPolicyReference" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "BackendBucketsClient", + "fullName": "google.cloud.compute.v1.BackendBucketsClient" + }, + "method": { + "shortName": "SetEdgeSecurityPolicy", + "fullName": "google.cloud.compute.v1.BackendBuckets.SetEdgeSecurityPolicy", + "service": { + "shortName": "BackendBuckets", + "fullName": "google.cloud.compute.v1.BackendBuckets" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendBuckets_Update_async", + "title": "AcceleratorTypes update Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified BackendBucket resource with the data included in the request.", + "canonical": true, + "file": "backend_buckets.update.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.BackendBuckets.Update", + "async": true, + "parameters": [ + { + "name": "backend_bucket", + "type": "TYPE_STRING" + }, + { + "name": "backend_bucket_resource", + "type": ".google.cloud.compute.v1.BackendBucket" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "BackendBucketsClient", + "fullName": "google.cloud.compute.v1.BackendBucketsClient" + }, + "method": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.BackendBuckets.Update", + "service": { + "shortName": "BackendBuckets", + "fullName": "google.cloud.compute.v1.BackendBuckets" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendServices_AddSignedUrlKey_async", + "title": "AcceleratorTypes addSignedUrlKey Sample", + "origin": "API_DEFINITION", + "description": " Adds a key for validating requests with signed URLs for this backend service.", + "canonical": true, + "file": "backend_services.add_signed_url_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddSignedUrlKey", + "fullName": "google.cloud.compute.v1.BackendServices.AddSignedUrlKey", + "async": true, + "parameters": [ + { + "name": "backend_service", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "signed_url_key_resource", + "type": ".google.cloud.compute.v1.SignedUrlKey" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "BackendServicesClient", + "fullName": "google.cloud.compute.v1.BackendServicesClient" + }, + "method": { + "shortName": "AddSignedUrlKey", + "fullName": "google.cloud.compute.v1.BackendServices.AddSignedUrlKey", + "service": { + "shortName": "BackendServices", + "fullName": "google.cloud.compute.v1.BackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendServices_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of all BackendService resources, regional and global, available to the specified project.", + "canonical": true, + "file": "backend_services.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.BackendServices.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.BackendServiceAggregatedList", + "client": { + "shortName": "BackendServicesClient", + "fullName": "google.cloud.compute.v1.BackendServicesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.BackendServices.AggregatedList", + "service": { + "shortName": "BackendServices", + "fullName": "google.cloud.compute.v1.BackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendServices_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified BackendService resource.", + "canonical": true, + "file": "backend_services.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.BackendServices.Delete", + "async": true, + "parameters": [ + { + "name": "backend_service", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "BackendServicesClient", + "fullName": "google.cloud.compute.v1.BackendServicesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.BackendServices.Delete", + "service": { + "shortName": "BackendServices", + "fullName": "google.cloud.compute.v1.BackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendServices_DeleteSignedUrlKey_async", + "title": "AcceleratorTypes deleteSignedUrlKey Sample", + "origin": "API_DEFINITION", + "description": " Deletes a key for validating requests with signed URLs for this backend service.", + "canonical": true, + "file": "backend_services.delete_signed_url_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteSignedUrlKey", + "fullName": "google.cloud.compute.v1.BackendServices.DeleteSignedUrlKey", + "async": true, + "parameters": [ + { + "name": "backend_service", + "type": "TYPE_STRING" + }, + { + "name": "key_name", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "BackendServicesClient", + "fullName": "google.cloud.compute.v1.BackendServicesClient" + }, + "method": { + "shortName": "DeleteSignedUrlKey", + "fullName": "google.cloud.compute.v1.BackendServices.DeleteSignedUrlKey", + "service": { + "shortName": "BackendServices", + "fullName": "google.cloud.compute.v1.BackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendServices_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified BackendService resource.", + "canonical": true, + "file": "backend_services.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.BackendServices.Get", + "async": true, + "parameters": [ + { + "name": "backend_service", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.BackendService", + "client": { + "shortName": "BackendServicesClient", + "fullName": "google.cloud.compute.v1.BackendServicesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.BackendServices.Get", + "service": { + "shortName": "BackendServices", + "fullName": "google.cloud.compute.v1.BackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendServices_GetHealth_async", + "title": "AcceleratorTypes getHealth Sample", + "origin": "API_DEFINITION", + "description": " Gets the most recent health check results for this BackendService. Example request body: { \"group\": \"/zones/us-east1-b/instanceGroups/lb-backend-example\" }", + "canonical": true, + "file": "backend_services.get_health.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetHealth", + "fullName": "google.cloud.compute.v1.BackendServices.GetHealth", + "async": true, + "parameters": [ + { + "name": "backend_service", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource_group_reference_resource", + "type": ".google.cloud.compute.v1.ResourceGroupReference" + } + ], + "resultType": ".google.cloud.compute.v1.BackendServiceGroupHealth", + "client": { + "shortName": "BackendServicesClient", + "fullName": "google.cloud.compute.v1.BackendServicesClient" + }, + "method": { + "shortName": "GetHealth", + "fullName": "google.cloud.compute.v1.BackendServices.GetHealth", + "service": { + "shortName": "BackendServices", + "fullName": "google.cloud.compute.v1.BackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendServices_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "backend_services.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.BackendServices.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "BackendServicesClient", + "fullName": "google.cloud.compute.v1.BackendServicesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.BackendServices.GetIamPolicy", + "service": { + "shortName": "BackendServices", + "fullName": "google.cloud.compute.v1.BackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendServices_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a BackendService resource in the specified project using the data included in the request. For more information, see Backend services overview .", + "canonical": true, + "file": "backend_services.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.BackendServices.Insert", + "async": true, + "parameters": [ + { + "name": "backend_service_resource", + "type": ".google.cloud.compute.v1.BackendService" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "BackendServicesClient", + "fullName": "google.cloud.compute.v1.BackendServicesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.BackendServices.Insert", + "service": { + "shortName": "BackendServices", + "fullName": "google.cloud.compute.v1.BackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendServices_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of BackendService resources available to the specified project.", + "canonical": true, + "file": "backend_services.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.BackendServices.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.BackendServiceList", + "client": { + "shortName": "BackendServicesClient", + "fullName": "google.cloud.compute.v1.BackendServicesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.BackendServices.List", + "service": { + "shortName": "BackendServices", + "fullName": "google.cloud.compute.v1.BackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendServices_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified BackendService resource with the data included in the request. For more information, see Backend services overview. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.", + "canonical": true, + "file": "backend_services.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.BackendServices.Patch", + "async": true, + "parameters": [ + { + "name": "backend_service", + "type": "TYPE_STRING" + }, + { + "name": "backend_service_resource", + "type": ".google.cloud.compute.v1.BackendService" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "BackendServicesClient", + "fullName": "google.cloud.compute.v1.BackendServicesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.BackendServices.Patch", + "service": { + "shortName": "BackendServices", + "fullName": "google.cloud.compute.v1.BackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendServices_SetEdgeSecurityPolicy_async", + "title": "AcceleratorTypes setEdgeSecurityPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the edge security policy for the specified backend service.", + "canonical": true, + "file": "backend_services.set_edge_security_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetEdgeSecurityPolicy", + "fullName": "google.cloud.compute.v1.BackendServices.SetEdgeSecurityPolicy", + "async": true, + "parameters": [ + { + "name": "backend_service", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "security_policy_reference_resource", + "type": ".google.cloud.compute.v1.SecurityPolicyReference" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "BackendServicesClient", + "fullName": "google.cloud.compute.v1.BackendServicesClient" + }, + "method": { + "shortName": "SetEdgeSecurityPolicy", + "fullName": "google.cloud.compute.v1.BackendServices.SetEdgeSecurityPolicy", + "service": { + "shortName": "BackendServices", + "fullName": "google.cloud.compute.v1.BackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendServices_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "backend_services.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.BackendServices.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "global_set_policy_request_resource", + "type": ".google.cloud.compute.v1.GlobalSetPolicyRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "BackendServicesClient", + "fullName": "google.cloud.compute.v1.BackendServicesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.BackendServices.SetIamPolicy", + "service": { + "shortName": "BackendServices", + "fullName": "google.cloud.compute.v1.BackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendServices_SetSecurityPolicy_async", + "title": "AcceleratorTypes setSecurityPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the Google Cloud Armor security policy for the specified backend service. For more information, see Google Cloud Armor Overview", + "canonical": true, + "file": "backend_services.set_security_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetSecurityPolicy", + "fullName": "google.cloud.compute.v1.BackendServices.SetSecurityPolicy", + "async": true, + "parameters": [ + { + "name": "backend_service", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "security_policy_reference_resource", + "type": ".google.cloud.compute.v1.SecurityPolicyReference" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "BackendServicesClient", + "fullName": "google.cloud.compute.v1.BackendServicesClient" + }, + "method": { + "shortName": "SetSecurityPolicy", + "fullName": "google.cloud.compute.v1.BackendServices.SetSecurityPolicy", + "service": { + "shortName": "BackendServices", + "fullName": "google.cloud.compute.v1.BackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_BackendServices_Update_async", + "title": "AcceleratorTypes update Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified BackendService resource with the data included in the request. For more information, see Backend services overview.", + "canonical": true, + "file": "backend_services.update.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.BackendServices.Update", + "async": true, + "parameters": [ + { + "name": "backend_service", + "type": "TYPE_STRING" + }, + { + "name": "backend_service_resource", + "type": ".google.cloud.compute.v1.BackendService" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "BackendServicesClient", + "fullName": "google.cloud.compute.v1.BackendServicesClient" + }, + "method": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.BackendServices.Update", + "service": { + "shortName": "BackendServices", + "fullName": "google.cloud.compute.v1.BackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Disks_AddResourcePolicies_async", + "title": "AcceleratorTypes addResourcePolicies Sample", + "origin": "API_DEFINITION", + "description": " Adds existing resource policies to a disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation.", + "canonical": true, + "file": "disks.add_resource_policies.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddResourcePolicies", + "fullName": "google.cloud.compute.v1.Disks.AddResourcePolicies", + "async": true, + "parameters": [ + { + "name": "disk", + "type": "TYPE_STRING" + }, + { + "name": "disks_add_resource_policies_request_resource", + "type": ".google.cloud.compute.v1.DisksAddResourcePoliciesRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "DisksClient", + "fullName": "google.cloud.compute.v1.DisksClient" + }, + "method": { + "shortName": "AddResourcePolicies", + "fullName": "google.cloud.compute.v1.Disks.AddResourcePolicies", + "service": { + "shortName": "Disks", + "fullName": "google.cloud.compute.v1.Disks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Disks_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of persistent disks.", + "canonical": true, + "file": "disks.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.Disks.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.DiskAggregatedList", + "client": { + "shortName": "DisksClient", + "fullName": "google.cloud.compute.v1.DisksClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.Disks.AggregatedList", + "service": { + "shortName": "Disks", + "fullName": "google.cloud.compute.v1.Disks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Disks_CreateSnapshot_async", + "title": "AcceleratorTypes createSnapshot Sample", + "origin": "API_DEFINITION", + "description": " Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project.", + "canonical": true, + "file": "disks.create_snapshot.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 76, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateSnapshot", + "fullName": "google.cloud.compute.v1.Disks.CreateSnapshot", + "async": true, + "parameters": [ + { + "name": "disk", + "type": "TYPE_STRING" + }, + { + "name": "guest_flush", + "type": "TYPE_BOOL" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "snapshot_resource", + "type": ".google.cloud.compute.v1.Snapshot" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "DisksClient", + "fullName": "google.cloud.compute.v1.DisksClient" + }, + "method": { + "shortName": "CreateSnapshot", + "fullName": "google.cloud.compute.v1.Disks.CreateSnapshot", + "service": { + "shortName": "Disks", + "fullName": "google.cloud.compute.v1.Disks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Disks_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified persistent disk. Deleting a disk removes its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots.", + "canonical": true, + "file": "disks.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Disks.Delete", + "async": true, + "parameters": [ + { + "name": "disk", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "DisksClient", + "fullName": "google.cloud.compute.v1.DisksClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Disks.Delete", + "service": { + "shortName": "Disks", + "fullName": "google.cloud.compute.v1.Disks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Disks_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified persistent disk.", + "canonical": true, + "file": "disks.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Disks.Get", + "async": true, + "parameters": [ + { + "name": "disk", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Disk", + "client": { + "shortName": "DisksClient", + "fullName": "google.cloud.compute.v1.DisksClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Disks.Get", + "service": { + "shortName": "Disks", + "fullName": "google.cloud.compute.v1.Disks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Disks_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "disks.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.Disks.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "DisksClient", + "fullName": "google.cloud.compute.v1.DisksClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.Disks.GetIamPolicy", + "service": { + "shortName": "Disks", + "fullName": "google.cloud.compute.v1.Disks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Disks_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a persistent disk in the specified project using the data in the request. You can create a disk from a source (sourceImage, sourceSnapshot, or sourceDisk) or create an empty 500 GB data disk by omitting all properties. You can also create a disk that is larger than the default size by specifying the sizeGb property.", + "canonical": true, + "file": "disks.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Disks.Insert", + "async": true, + "parameters": [ + { + "name": "disk_resource", + "type": ".google.cloud.compute.v1.Disk" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "source_image", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "DisksClient", + "fullName": "google.cloud.compute.v1.DisksClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Disks.Insert", + "service": { + "shortName": "Disks", + "fullName": "google.cloud.compute.v1.Disks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Disks_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of persistent disks contained within the specified zone.", + "canonical": true, + "file": "disks.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Disks.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.DiskList", + "client": { + "shortName": "DisksClient", + "fullName": "google.cloud.compute.v1.DisksClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Disks.List", + "service": { + "shortName": "Disks", + "fullName": "google.cloud.compute.v1.Disks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Disks_RemoveResourcePolicies_async", + "title": "AcceleratorTypes removeResourcePolicies Sample", + "origin": "API_DEFINITION", + "description": " Removes resource policies from a disk.", + "canonical": true, + "file": "disks.remove_resource_policies.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveResourcePolicies", + "fullName": "google.cloud.compute.v1.Disks.RemoveResourcePolicies", + "async": true, + "parameters": [ + { + "name": "disk", + "type": "TYPE_STRING" + }, + { + "name": "disks_remove_resource_policies_request_resource", + "type": ".google.cloud.compute.v1.DisksRemoveResourcePoliciesRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "DisksClient", + "fullName": "google.cloud.compute.v1.DisksClient" + }, + "method": { + "shortName": "RemoveResourcePolicies", + "fullName": "google.cloud.compute.v1.Disks.RemoveResourcePolicies", + "service": { + "shortName": "Disks", + "fullName": "google.cloud.compute.v1.Disks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Disks_Resize_async", + "title": "AcceleratorTypes resize Sample", + "origin": "API_DEFINITION", + "description": " Resizes the specified persistent disk. You can only increase the size of the disk.", + "canonical": true, + "file": "disks.resize.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Resize", + "fullName": "google.cloud.compute.v1.Disks.Resize", + "async": true, + "parameters": [ + { + "name": "disk", + "type": "TYPE_STRING" + }, + { + "name": "disks_resize_request_resource", + "type": ".google.cloud.compute.v1.DisksResizeRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "DisksClient", + "fullName": "google.cloud.compute.v1.DisksClient" + }, + "method": { + "shortName": "Resize", + "fullName": "google.cloud.compute.v1.Disks.Resize", + "service": { + "shortName": "Disks", + "fullName": "google.cloud.compute.v1.Disks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Disks_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "disks.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.Disks.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + }, + { + "name": "zone_set_policy_request_resource", + "type": ".google.cloud.compute.v1.ZoneSetPolicyRequest" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "DisksClient", + "fullName": "google.cloud.compute.v1.DisksClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.Disks.SetIamPolicy", + "service": { + "shortName": "Disks", + "fullName": "google.cloud.compute.v1.Disks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Disks_SetLabels_async", + "title": "AcceleratorTypes setLabels Sample", + "origin": "API_DEFINITION", + "description": " Sets the labels on a disk. To learn more about labels, read the Labeling Resources documentation.", + "canonical": true, + "file": "disks.set_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.Disks.SetLabels", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + }, + { + "name": "zone_set_labels_request_resource", + "type": ".google.cloud.compute.v1.ZoneSetLabelsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "DisksClient", + "fullName": "google.cloud.compute.v1.DisksClient" + }, + "method": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.Disks.SetLabels", + "service": { + "shortName": "Disks", + "fullName": "google.cloud.compute.v1.Disks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Disks_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "disks.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.Disks.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "DisksClient", + "fullName": "google.cloud.compute.v1.DisksClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.Disks.TestIamPermissions", + "service": { + "shortName": "Disks", + "fullName": "google.cloud.compute.v1.Disks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Disks_Update_async", + "title": "AcceleratorTypes update Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified disk with the data included in the request. The update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: user_license.", + "canonical": true, + "file": "disks.update.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.Disks.Update", + "async": true, + "parameters": [ + { + "name": "disk", + "type": "TYPE_STRING" + }, + { + "name": "disk_resource", + "type": ".google.cloud.compute.v1.Disk" + }, + { + "name": "paths", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "update_mask", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "DisksClient", + "fullName": "google.cloud.compute.v1.DisksClient" + }, + "method": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.Disks.Update", + "service": { + "shortName": "Disks", + "fullName": "google.cloud.compute.v1.Disks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_DiskTypes_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of disk types.", + "canonical": true, + "file": "disk_types.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.DiskTypes.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.DiskTypeAggregatedList", + "client": { + "shortName": "DiskTypesClient", + "fullName": "google.cloud.compute.v1.DiskTypesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.DiskTypes.AggregatedList", + "service": { + "shortName": "DiskTypes", + "fullName": "google.cloud.compute.v1.DiskTypes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_DiskTypes_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified disk type.", + "canonical": true, + "file": "disk_types.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.DiskTypes.Get", + "async": true, + "parameters": [ + { + "name": "disk_type", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.DiskType", + "client": { + "shortName": "DiskTypesClient", + "fullName": "google.cloud.compute.v1.DiskTypesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.DiskTypes.Get", + "service": { + "shortName": "DiskTypes", + "fullName": "google.cloud.compute.v1.DiskTypes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_DiskTypes_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of disk types available to the specified project.", + "canonical": true, + "file": "disk_types.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.DiskTypes.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.DiskTypeList", + "client": { + "shortName": "DiskTypesClient", + "fullName": "google.cloud.compute.v1.DiskTypesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.DiskTypes.List", + "service": { + "shortName": "DiskTypes", + "fullName": "google.cloud.compute.v1.DiskTypes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ExternalVpnGateways_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified externalVpnGateway.", + "canonical": true, + "file": "external_vpn_gateways.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways.Delete", + "async": true, + "parameters": [ + { + "name": "external_vpn_gateway", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ExternalVpnGatewaysClient", + "fullName": "google.cloud.compute.v1.ExternalVpnGatewaysClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways.Delete", + "service": { + "shortName": "ExternalVpnGateways", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ExternalVpnGateways_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified externalVpnGateway. Get a list of available externalVpnGateways by making a list() request.", + "canonical": true, + "file": "external_vpn_gateways.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways.Get", + "async": true, + "parameters": [ + { + "name": "external_vpn_gateway", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.ExternalVpnGateway", + "client": { + "shortName": "ExternalVpnGatewaysClient", + "fullName": "google.cloud.compute.v1.ExternalVpnGatewaysClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways.Get", + "service": { + "shortName": "ExternalVpnGateways", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ExternalVpnGateways_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a ExternalVpnGateway in the specified project using the data included in the request.", + "canonical": true, + "file": "external_vpn_gateways.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways.Insert", + "async": true, + "parameters": [ + { + "name": "external_vpn_gateway_resource", + "type": ".google.cloud.compute.v1.ExternalVpnGateway" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ExternalVpnGatewaysClient", + "fullName": "google.cloud.compute.v1.ExternalVpnGatewaysClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways.Insert", + "service": { + "shortName": "ExternalVpnGateways", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ExternalVpnGateways_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of ExternalVpnGateway available to the specified project.", + "canonical": true, + "file": "external_vpn_gateways.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.ExternalVpnGatewayList", + "client": { + "shortName": "ExternalVpnGatewaysClient", + "fullName": "google.cloud.compute.v1.ExternalVpnGatewaysClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways.List", + "service": { + "shortName": "ExternalVpnGateways", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ExternalVpnGateways_SetLabels_async", + "title": "AcceleratorTypes setLabels Sample", + "origin": "API_DEFINITION", + "description": " Sets the labels on an ExternalVpnGateway. To learn more about labels, read the Labeling Resources documentation.", + "canonical": true, + "file": "external_vpn_gateways.set_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways.SetLabels", + "async": true, + "parameters": [ + { + "name": "global_set_labels_request_resource", + "type": ".google.cloud.compute.v1.GlobalSetLabelsRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ExternalVpnGatewaysClient", + "fullName": "google.cloud.compute.v1.ExternalVpnGatewaysClient" + }, + "method": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways.SetLabels", + "service": { + "shortName": "ExternalVpnGateways", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ExternalVpnGateways_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "external_vpn_gateways.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "ExternalVpnGatewaysClient", + "fullName": "google.cloud.compute.v1.ExternalVpnGatewaysClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways.TestIamPermissions", + "service": { + "shortName": "ExternalVpnGateways", + "fullName": "google.cloud.compute.v1.ExternalVpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_AddAssociation_async", + "title": "AcceleratorTypes addAssociation Sample", + "origin": "API_DEFINITION", + "description": " Inserts an association for the specified firewall policy.", + "canonical": true, + "file": "firewall_policies.add_association.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddAssociation", + "fullName": "google.cloud.compute.v1.FirewallPolicies.AddAssociation", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "firewall_policy_association_resource", + "type": ".google.cloud.compute.v1.FirewallPolicyAssociation" + }, + { + "name": "replace_existing_association", + "type": "TYPE_BOOL" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "AddAssociation", + "fullName": "google.cloud.compute.v1.FirewallPolicies.AddAssociation", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_AddRule_async", + "title": "AcceleratorTypes addRule Sample", + "origin": "API_DEFINITION", + "description": " Inserts a rule into a firewall policy.", + "canonical": true, + "file": "firewall_policies.add_rule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddRule", + "fullName": "google.cloud.compute.v1.FirewallPolicies.AddRule", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "firewall_policy_rule_resource", + "type": ".google.cloud.compute.v1.FirewallPolicyRule" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "AddRule", + "fullName": "google.cloud.compute.v1.FirewallPolicies.AddRule", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_CloneRules_async", + "title": "AcceleratorTypes cloneRules Sample", + "origin": "API_DEFINITION", + "description": " Copies rules to the specified firewall policy.", + "canonical": true, + "file": "firewall_policies.clone_rules.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CloneRules", + "fullName": "google.cloud.compute.v1.FirewallPolicies.CloneRules", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "source_firewall_policy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "CloneRules", + "fullName": "google.cloud.compute.v1.FirewallPolicies.CloneRules", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified policy.", + "canonical": true, + "file": "firewall_policies.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.FirewallPolicies.Delete", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.FirewallPolicies.Delete", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified firewall policy.", + "canonical": true, + "file": "firewall_policies.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.FirewallPolicies.Get", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.FirewallPolicy", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.FirewallPolicies.Get", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_GetAssociation_async", + "title": "AcceleratorTypes getAssociation Sample", + "origin": "API_DEFINITION", + "description": " Gets an association with the specified name.", + "canonical": true, + "file": "firewall_policies.get_association.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAssociation", + "fullName": "google.cloud.compute.v1.FirewallPolicies.GetAssociation", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.FirewallPolicyAssociation", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "GetAssociation", + "fullName": "google.cloud.compute.v1.FirewallPolicies.GetAssociation", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "firewall_policies.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.FirewallPolicies.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.FirewallPolicies.GetIamPolicy", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_GetRule_async", + "title": "AcceleratorTypes getRule Sample", + "origin": "API_DEFINITION", + "description": " Gets a rule of the specified priority.", + "canonical": true, + "file": "firewall_policies.get_rule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetRule", + "fullName": "google.cloud.compute.v1.FirewallPolicies.GetRule", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "priority", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.compute.v1.FirewallPolicyRule", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "GetRule", + "fullName": "google.cloud.compute.v1.FirewallPolicies.GetRule", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a new policy in the specified project using the data included in the request.", + "canonical": true, + "file": "firewall_policies.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.FirewallPolicies.Insert", + "async": true, + "parameters": [ + { + "name": "firewall_policy_resource", + "type": ".google.cloud.compute.v1.FirewallPolicy" + }, + { + "name": "parent_id", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.FirewallPolicies.Insert", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Lists all the policies that have been configured for the specified folder or organization.", + "canonical": true, + "file": "firewall_policies.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 74, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.FirewallPolicies.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "parent_id", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.FirewallPolicyList", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.FirewallPolicies.List", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_ListAssociations_async", + "title": "AcceleratorTypes listAssociations Sample", + "origin": "API_DEFINITION", + "description": " Lists associations of a specified target, i.e., organization or folder.", + "canonical": true, + "file": "firewall_policies.list_associations.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 52, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListAssociations", + "fullName": "google.cloud.compute.v1.FirewallPolicies.ListAssociations", + "async": true, + "parameters": [ + { + "name": "target_resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.FirewallPoliciesListAssociationsResponse", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "ListAssociations", + "fullName": "google.cloud.compute.v1.FirewallPolicies.ListAssociations", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_Move_async", + "title": "AcceleratorTypes move Sample", + "origin": "API_DEFINITION", + "description": " Moves the specified firewall policy.", + "canonical": true, + "file": "firewall_policies.move.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Move", + "fullName": "google.cloud.compute.v1.FirewallPolicies.Move", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "parent_id", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "Move", + "fullName": "google.cloud.compute.v1.FirewallPolicies.Move", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified policy with the data included in the request.", + "canonical": true, + "file": "firewall_policies.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.FirewallPolicies.Patch", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "firewall_policy_resource", + "type": ".google.cloud.compute.v1.FirewallPolicy" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.FirewallPolicies.Patch", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_PatchRule_async", + "title": "AcceleratorTypes patchRule Sample", + "origin": "API_DEFINITION", + "description": " Patches a rule of the specified priority.", + "canonical": true, + "file": "firewall_policies.patch_rule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PatchRule", + "fullName": "google.cloud.compute.v1.FirewallPolicies.PatchRule", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "firewall_policy_rule_resource", + "type": ".google.cloud.compute.v1.FirewallPolicyRule" + }, + { + "name": "priority", + "type": "TYPE_INT32" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "PatchRule", + "fullName": "google.cloud.compute.v1.FirewallPolicies.PatchRule", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_RemoveAssociation_async", + "title": "AcceleratorTypes removeAssociation Sample", + "origin": "API_DEFINITION", + "description": " Removes an association for the specified firewall policy.", + "canonical": true, + "file": "firewall_policies.remove_association.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveAssociation", + "fullName": "google.cloud.compute.v1.FirewallPolicies.RemoveAssociation", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "RemoveAssociation", + "fullName": "google.cloud.compute.v1.FirewallPolicies.RemoveAssociation", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_RemoveRule_async", + "title": "AcceleratorTypes removeRule Sample", + "origin": "API_DEFINITION", + "description": " Deletes a rule of the specified priority.", + "canonical": true, + "file": "firewall_policies.remove_rule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveRule", + "fullName": "google.cloud.compute.v1.FirewallPolicies.RemoveRule", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "priority", + "type": "TYPE_INT32" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "RemoveRule", + "fullName": "google.cloud.compute.v1.FirewallPolicies.RemoveRule", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "firewall_policies.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.FirewallPolicies.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "global_organization_set_policy_request_resource", + "type": ".google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.FirewallPolicies.SetIamPolicy", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_FirewallPolicies_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "firewall_policies.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.FirewallPolicies.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "FirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.FirewallPoliciesClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.FirewallPolicies.TestIamPermissions", + "service": { + "shortName": "FirewallPolicies", + "fullName": "google.cloud.compute.v1.FirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Firewalls_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified firewall.", + "canonical": true, + "file": "firewalls.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Firewalls.Delete", + "async": true, + "parameters": [ + { + "name": "firewall", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "FirewallsClient", + "fullName": "google.cloud.compute.v1.FirewallsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Firewalls.Delete", + "service": { + "shortName": "Firewalls", + "fullName": "google.cloud.compute.v1.Firewalls" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Firewalls_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified firewall.", + "canonical": true, + "file": "firewalls.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Firewalls.Get", + "async": true, + "parameters": [ + { + "name": "firewall", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Firewall", + "client": { + "shortName": "FirewallsClient", + "fullName": "google.cloud.compute.v1.FirewallsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Firewalls.Get", + "service": { + "shortName": "Firewalls", + "fullName": "google.cloud.compute.v1.Firewalls" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Firewalls_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a firewall rule in the specified project using the data included in the request.", + "canonical": true, + "file": "firewalls.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Firewalls.Insert", + "async": true, + "parameters": [ + { + "name": "firewall_resource", + "type": ".google.cloud.compute.v1.Firewall" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "FirewallsClient", + "fullName": "google.cloud.compute.v1.FirewallsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Firewalls.Insert", + "service": { + "shortName": "Firewalls", + "fullName": "google.cloud.compute.v1.Firewalls" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Firewalls_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of firewall rules available to the specified project.", + "canonical": true, + "file": "firewalls.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Firewalls.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.FirewallList", + "client": { + "shortName": "FirewallsClient", + "fullName": "google.cloud.compute.v1.FirewallsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Firewalls.List", + "service": { + "shortName": "Firewalls", + "fullName": "google.cloud.compute.v1.Firewalls" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Firewalls_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified firewall rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.", + "canonical": true, + "file": "firewalls.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.Firewalls.Patch", + "async": true, + "parameters": [ + { + "name": "firewall", + "type": "TYPE_STRING" + }, + { + "name": "firewall_resource", + "type": ".google.cloud.compute.v1.Firewall" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "FirewallsClient", + "fullName": "google.cloud.compute.v1.FirewallsClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.Firewalls.Patch", + "service": { + "shortName": "Firewalls", + "fullName": "google.cloud.compute.v1.Firewalls" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Firewalls_Update_async", + "title": "AcceleratorTypes update Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified firewall rule with the data included in the request. Note that all fields will be updated if using PUT, even fields that are not specified. To update individual fields, please use PATCH instead.", + "canonical": true, + "file": "firewalls.update.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.Firewalls.Update", + "async": true, + "parameters": [ + { + "name": "firewall", + "type": "TYPE_STRING" + }, + { + "name": "firewall_resource", + "type": ".google.cloud.compute.v1.Firewall" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "FirewallsClient", + "fullName": "google.cloud.compute.v1.FirewallsClient" + }, + "method": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.Firewalls.Update", + "service": { + "shortName": "Firewalls", + "fullName": "google.cloud.compute.v1.Firewalls" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ForwardingRules_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of forwarding rules.", + "canonical": true, + "file": "forwarding_rules.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.ForwardingRules.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.ForwardingRuleAggregatedList", + "client": { + "shortName": "ForwardingRulesClient", + "fullName": "google.cloud.compute.v1.ForwardingRulesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.ForwardingRules.AggregatedList", + "service": { + "shortName": "ForwardingRules", + "fullName": "google.cloud.compute.v1.ForwardingRules" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ForwardingRules_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified ForwardingRule resource.", + "canonical": true, + "file": "forwarding_rules.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.ForwardingRules.Delete", + "async": true, + "parameters": [ + { + "name": "forwarding_rule", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ForwardingRulesClient", + "fullName": "google.cloud.compute.v1.ForwardingRulesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.ForwardingRules.Delete", + "service": { + "shortName": "ForwardingRules", + "fullName": "google.cloud.compute.v1.ForwardingRules" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ForwardingRules_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified ForwardingRule resource.", + "canonical": true, + "file": "forwarding_rules.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.ForwardingRules.Get", + "async": true, + "parameters": [ + { + "name": "forwarding_rule", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.ForwardingRule", + "client": { + "shortName": "ForwardingRulesClient", + "fullName": "google.cloud.compute.v1.ForwardingRulesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.ForwardingRules.Get", + "service": { + "shortName": "ForwardingRules", + "fullName": "google.cloud.compute.v1.ForwardingRules" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ForwardingRules_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a ForwardingRule resource in the specified project and region using the data included in the request.", + "canonical": true, + "file": "forwarding_rules.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.ForwardingRules.Insert", + "async": true, + "parameters": [ + { + "name": "forwarding_rule_resource", + "type": ".google.cloud.compute.v1.ForwardingRule" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ForwardingRulesClient", + "fullName": "google.cloud.compute.v1.ForwardingRulesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.ForwardingRules.Insert", + "service": { + "shortName": "ForwardingRules", + "fullName": "google.cloud.compute.v1.ForwardingRules" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ForwardingRules_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of ForwardingRule resources available to the specified project and region.", + "canonical": true, + "file": "forwarding_rules.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.ForwardingRules.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.ForwardingRuleList", + "client": { + "shortName": "ForwardingRulesClient", + "fullName": "google.cloud.compute.v1.ForwardingRulesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.ForwardingRules.List", + "service": { + "shortName": "ForwardingRules", + "fullName": "google.cloud.compute.v1.ForwardingRules" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ForwardingRules_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. Currently, you can only patch the network_tier field.", + "canonical": true, + "file": "forwarding_rules.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.ForwardingRules.Patch", + "async": true, + "parameters": [ + { + "name": "forwarding_rule", + "type": "TYPE_STRING" + }, + { + "name": "forwarding_rule_resource", + "type": ".google.cloud.compute.v1.ForwardingRule" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ForwardingRulesClient", + "fullName": "google.cloud.compute.v1.ForwardingRulesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.ForwardingRules.Patch", + "service": { + "shortName": "ForwardingRules", + "fullName": "google.cloud.compute.v1.ForwardingRules" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ForwardingRules_SetLabels_async", + "title": "AcceleratorTypes setLabels Sample", + "origin": "API_DEFINITION", + "description": " Sets the labels on the specified resource. To learn more about labels, read the Labeling Resources documentation.", + "canonical": true, + "file": "forwarding_rules.set_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.ForwardingRules.SetLabels", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_set_labels_request_resource", + "type": ".google.cloud.compute.v1.RegionSetLabelsRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ForwardingRulesClient", + "fullName": "google.cloud.compute.v1.ForwardingRulesClient" + }, + "method": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.ForwardingRules.SetLabels", + "service": { + "shortName": "ForwardingRules", + "fullName": "google.cloud.compute.v1.ForwardingRules" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ForwardingRules_SetTarget_async", + "title": "AcceleratorTypes setTarget Sample", + "origin": "API_DEFINITION", + "description": " Changes target URL for forwarding rule. The new target should be of the same type as the old target.", + "canonical": true, + "file": "forwarding_rules.set_target.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetTarget", + "fullName": "google.cloud.compute.v1.ForwardingRules.SetTarget", + "async": true, + "parameters": [ + { + "name": "forwarding_rule", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_reference_resource", + "type": ".google.cloud.compute.v1.TargetReference" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ForwardingRulesClient", + "fullName": "google.cloud.compute.v1.ForwardingRulesClient" + }, + "method": { + "shortName": "SetTarget", + "fullName": "google.cloud.compute.v1.ForwardingRules.SetTarget", + "service": { + "shortName": "ForwardingRules", + "fullName": "google.cloud.compute.v1.ForwardingRules" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalAddresses_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified address resource.", + "canonical": true, + "file": "global_addresses.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.GlobalAddresses.Delete", + "async": true, + "parameters": [ + { + "name": "address", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalAddressesClient", + "fullName": "google.cloud.compute.v1.GlobalAddressesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.GlobalAddresses.Delete", + "service": { + "shortName": "GlobalAddresses", + "fullName": "google.cloud.compute.v1.GlobalAddresses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalAddresses_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified address resource.", + "canonical": true, + "file": "global_addresses.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.GlobalAddresses.Get", + "async": true, + "parameters": [ + { + "name": "address", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Address", + "client": { + "shortName": "GlobalAddressesClient", + "fullName": "google.cloud.compute.v1.GlobalAddressesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.GlobalAddresses.Get", + "service": { + "shortName": "GlobalAddresses", + "fullName": "google.cloud.compute.v1.GlobalAddresses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalAddresses_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates an address resource in the specified project by using the data included in the request.", + "canonical": true, + "file": "global_addresses.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.GlobalAddresses.Insert", + "async": true, + "parameters": [ + { + "name": "address_resource", + "type": ".google.cloud.compute.v1.Address" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalAddressesClient", + "fullName": "google.cloud.compute.v1.GlobalAddressesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.GlobalAddresses.Insert", + "service": { + "shortName": "GlobalAddresses", + "fullName": "google.cloud.compute.v1.GlobalAddresses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalAddresses_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of global addresses.", + "canonical": true, + "file": "global_addresses.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.GlobalAddresses.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.AddressList", + "client": { + "shortName": "GlobalAddressesClient", + "fullName": "google.cloud.compute.v1.GlobalAddressesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.GlobalAddresses.List", + "service": { + "shortName": "GlobalAddresses", + "fullName": "google.cloud.compute.v1.GlobalAddresses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalAddresses_SetLabels_async", + "title": "AcceleratorTypes setLabels Sample", + "origin": "API_DEFINITION", + "description": " Sets the labels on a GlobalAddress. To learn more about labels, read the Labeling Resources documentation.", + "canonical": true, + "file": "global_addresses.set_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.GlobalAddresses.SetLabels", + "async": true, + "parameters": [ + { + "name": "global_set_labels_request_resource", + "type": ".google.cloud.compute.v1.GlobalSetLabelsRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalAddressesClient", + "fullName": "google.cloud.compute.v1.GlobalAddressesClient" + }, + "method": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.GlobalAddresses.SetLabels", + "service": { + "shortName": "GlobalAddresses", + "fullName": "google.cloud.compute.v1.GlobalAddresses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalForwardingRules_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified GlobalForwardingRule resource.", + "canonical": true, + "file": "global_forwarding_rules.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules.Delete", + "async": true, + "parameters": [ + { + "name": "forwarding_rule", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalForwardingRulesClient", + "fullName": "google.cloud.compute.v1.GlobalForwardingRulesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules.Delete", + "service": { + "shortName": "GlobalForwardingRules", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalForwardingRules_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified GlobalForwardingRule resource. Gets a list of available forwarding rules by making a list() request.", + "canonical": true, + "file": "global_forwarding_rules.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules.Get", + "async": true, + "parameters": [ + { + "name": "forwarding_rule", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.ForwardingRule", + "client": { + "shortName": "GlobalForwardingRulesClient", + "fullName": "google.cloud.compute.v1.GlobalForwardingRulesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules.Get", + "service": { + "shortName": "GlobalForwardingRules", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalForwardingRules_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a GlobalForwardingRule resource in the specified project using the data included in the request.", + "canonical": true, + "file": "global_forwarding_rules.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules.Insert", + "async": true, + "parameters": [ + { + "name": "forwarding_rule_resource", + "type": ".google.cloud.compute.v1.ForwardingRule" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalForwardingRulesClient", + "fullName": "google.cloud.compute.v1.GlobalForwardingRulesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules.Insert", + "service": { + "shortName": "GlobalForwardingRules", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalForwardingRules_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of GlobalForwardingRule resources available to the specified project.", + "canonical": true, + "file": "global_forwarding_rules.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.ForwardingRuleList", + "client": { + "shortName": "GlobalForwardingRulesClient", + "fullName": "google.cloud.compute.v1.GlobalForwardingRulesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules.List", + "service": { + "shortName": "GlobalForwardingRules", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalForwardingRules_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. Currently, you can only patch the network_tier field.", + "canonical": true, + "file": "global_forwarding_rules.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules.Patch", + "async": true, + "parameters": [ + { + "name": "forwarding_rule", + "type": "TYPE_STRING" + }, + { + "name": "forwarding_rule_resource", + "type": ".google.cloud.compute.v1.ForwardingRule" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalForwardingRulesClient", + "fullName": "google.cloud.compute.v1.GlobalForwardingRulesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules.Patch", + "service": { + "shortName": "GlobalForwardingRules", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalForwardingRules_SetLabels_async", + "title": "AcceleratorTypes setLabels Sample", + "origin": "API_DEFINITION", + "description": " Sets the labels on the specified resource. To learn more about labels, read the Labeling resources documentation.", + "canonical": true, + "file": "global_forwarding_rules.set_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules.SetLabels", + "async": true, + "parameters": [ + { + "name": "global_set_labels_request_resource", + "type": ".google.cloud.compute.v1.GlobalSetLabelsRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalForwardingRulesClient", + "fullName": "google.cloud.compute.v1.GlobalForwardingRulesClient" + }, + "method": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules.SetLabels", + "service": { + "shortName": "GlobalForwardingRules", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalForwardingRules_SetTarget_async", + "title": "AcceleratorTypes setTarget Sample", + "origin": "API_DEFINITION", + "description": " Changes target URL for the GlobalForwardingRule resource. The new target should be of the same type as the old target.", + "canonical": true, + "file": "global_forwarding_rules.set_target.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetTarget", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules.SetTarget", + "async": true, + "parameters": [ + { + "name": "forwarding_rule", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_reference_resource", + "type": ".google.cloud.compute.v1.TargetReference" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalForwardingRulesClient", + "fullName": "google.cloud.compute.v1.GlobalForwardingRulesClient" + }, + "method": { + "shortName": "SetTarget", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules.SetTarget", + "service": { + "shortName": "GlobalForwardingRules", + "fullName": "google.cloud.compute.v1.GlobalForwardingRules" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalNetworkEndpointGroups_AttachNetworkEndpoints_async", + "title": "AcceleratorTypes attachNetworkEndpoints Sample", + "origin": "API_DEFINITION", + "description": " Attach a network endpoint to the specified network endpoint group.", + "canonical": true, + "file": "global_network_endpoint_groups.attach_network_endpoints.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AttachNetworkEndpoints", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups.AttachNetworkEndpoints", + "async": true, + "parameters": [ + { + "name": "global_network_endpoint_groups_attach_endpoints_request_resource", + "type": ".google.cloud.compute.v1.GlobalNetworkEndpointGroupsAttachEndpointsRequest" + }, + { + "name": "network_endpoint_group", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalNetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroupsClient" + }, + "method": { + "shortName": "AttachNetworkEndpoints", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups.AttachNetworkEndpoints", + "service": { + "shortName": "GlobalNetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalNetworkEndpointGroups_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified network endpoint group.Note that the NEG cannot be deleted if there are backend services referencing it.", + "canonical": true, + "file": "global_network_endpoint_groups.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups.Delete", + "async": true, + "parameters": [ + { + "name": "network_endpoint_group", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalNetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroupsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups.Delete", + "service": { + "shortName": "GlobalNetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalNetworkEndpointGroups_DetachNetworkEndpoints_async", + "title": "AcceleratorTypes detachNetworkEndpoints Sample", + "origin": "API_DEFINITION", + "description": " Detach the network endpoint from the specified network endpoint group.", + "canonical": true, + "file": "global_network_endpoint_groups.detach_network_endpoints.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DetachNetworkEndpoints", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups.DetachNetworkEndpoints", + "async": true, + "parameters": [ + { + "name": "global_network_endpoint_groups_detach_endpoints_request_resource", + "type": ".google.cloud.compute.v1.GlobalNetworkEndpointGroupsDetachEndpointsRequest" + }, + { + "name": "network_endpoint_group", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalNetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroupsClient" + }, + "method": { + "shortName": "DetachNetworkEndpoints", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups.DetachNetworkEndpoints", + "service": { + "shortName": "GlobalNetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalNetworkEndpointGroups_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified network endpoint group.", + "canonical": true, + "file": "global_network_endpoint_groups.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups.Get", + "async": true, + "parameters": [ + { + "name": "network_endpoint_group", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.NetworkEndpointGroup", + "client": { + "shortName": "GlobalNetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroupsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups.Get", + "service": { + "shortName": "GlobalNetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalNetworkEndpointGroups_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a network endpoint group in the specified project using the parameters that are included in the request.", + "canonical": true, + "file": "global_network_endpoint_groups.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups.Insert", + "async": true, + "parameters": [ + { + "name": "network_endpoint_group_resource", + "type": ".google.cloud.compute.v1.NetworkEndpointGroup" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalNetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroupsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups.Insert", + "service": { + "shortName": "GlobalNetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalNetworkEndpointGroups_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of network endpoint groups that are located in the specified project.", + "canonical": true, + "file": "global_network_endpoint_groups.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.NetworkEndpointGroupList", + "client": { + "shortName": "GlobalNetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroupsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups.List", + "service": { + "shortName": "GlobalNetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalNetworkEndpointGroups_ListNetworkEndpoints_async", + "title": "AcceleratorTypes listNetworkEndpoints Sample", + "origin": "API_DEFINITION", + "description": " Lists the network endpoints in the specified network endpoint group.", + "canonical": true, + "file": "global_network_endpoint_groups.list_network_endpoints.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListNetworkEndpoints", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups.ListNetworkEndpoints", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "network_endpoint_group", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.NetworkEndpointGroupsListNetworkEndpoints", + "client": { + "shortName": "GlobalNetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroupsClient" + }, + "method": { + "shortName": "ListNetworkEndpoints", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups.ListNetworkEndpoints", + "service": { + "shortName": "GlobalNetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalOperations_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of all operations.", + "canonical": true, + "file": "global_operations.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.GlobalOperations.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.OperationAggregatedList", + "client": { + "shortName": "GlobalOperationsClient", + "fullName": "google.cloud.compute.v1.GlobalOperationsClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.GlobalOperations.AggregatedList", + "service": { + "shortName": "GlobalOperations", + "fullName": "google.cloud.compute.v1.GlobalOperations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalOperations_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified Operations resource.", + "canonical": true, + "file": "global_operations.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.GlobalOperations.Delete", + "async": true, + "parameters": [ + { + "name": "operation", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.DeleteGlobalOperationResponse", + "client": { + "shortName": "GlobalOperationsClient", + "fullName": "google.cloud.compute.v1.GlobalOperationsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.GlobalOperations.Delete", + "service": { + "shortName": "GlobalOperations", + "fullName": "google.cloud.compute.v1.GlobalOperations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalOperations_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the specified Operations resource.", + "canonical": true, + "file": "global_operations.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.GlobalOperations.Get", + "async": true, + "parameters": [ + { + "name": "operation", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalOperationsClient", + "fullName": "google.cloud.compute.v1.GlobalOperationsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.GlobalOperations.Get", + "service": { + "shortName": "GlobalOperations", + "fullName": "google.cloud.compute.v1.GlobalOperations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalOperations_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of Operation resources contained within the specified project.", + "canonical": true, + "file": "global_operations.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.GlobalOperations.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.OperationList", + "client": { + "shortName": "GlobalOperationsClient", + "fullName": "google.cloud.compute.v1.GlobalOperationsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.GlobalOperations.List", + "service": { + "shortName": "GlobalOperations", + "fullName": "google.cloud.compute.v1.GlobalOperations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalOperations_Wait_async", + "title": "AcceleratorTypes wait Sample", + "origin": "API_DEFINITION", + "description": " Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the `GET` method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. ", + "canonical": true, + "file": "global_operations.wait.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Wait", + "fullName": "google.cloud.compute.v1.GlobalOperations.Wait", + "async": true, + "parameters": [ + { + "name": "operation", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalOperationsClient", + "fullName": "google.cloud.compute.v1.GlobalOperationsClient" + }, + "method": { + "shortName": "Wait", + "fullName": "google.cloud.compute.v1.GlobalOperations.Wait", + "service": { + "shortName": "GlobalOperations", + "fullName": "google.cloud.compute.v1.GlobalOperations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalOrganizationOperations_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified Operations resource.", + "canonical": true, + "file": "global_organization_operations.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.GlobalOrganizationOperations.Delete", + "async": true, + "parameters": [ + { + "name": "operation", + "type": "TYPE_STRING" + }, + { + "name": "parent_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.DeleteGlobalOrganizationOperationResponse", + "client": { + "shortName": "GlobalOrganizationOperationsClient", + "fullName": "google.cloud.compute.v1.GlobalOrganizationOperationsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.GlobalOrganizationOperations.Delete", + "service": { + "shortName": "GlobalOrganizationOperations", + "fullName": "google.cloud.compute.v1.GlobalOrganizationOperations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalOrganizationOperations_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the specified Operations resource. Gets a list of operations by making a `list()` request.", + "canonical": true, + "file": "global_organization_operations.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.GlobalOrganizationOperations.Get", + "async": true, + "parameters": [ + { + "name": "operation", + "type": "TYPE_STRING" + }, + { + "name": "parent_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalOrganizationOperationsClient", + "fullName": "google.cloud.compute.v1.GlobalOrganizationOperationsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.GlobalOrganizationOperations.Get", + "service": { + "shortName": "GlobalOrganizationOperations", + "fullName": "google.cloud.compute.v1.GlobalOrganizationOperations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalOrganizationOperations_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of Operation resources contained within the specified organization.", + "canonical": true, + "file": "global_organization_operations.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 74, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.GlobalOrganizationOperations.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "parent_id", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.OperationList", + "client": { + "shortName": "GlobalOrganizationOperationsClient", + "fullName": "google.cloud.compute.v1.GlobalOrganizationOperationsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.GlobalOrganizationOperations.List", + "service": { + "shortName": "GlobalOrganizationOperations", + "fullName": "google.cloud.compute.v1.GlobalOrganizationOperations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalPublicDelegatedPrefixes_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified global PublicDelegatedPrefix.", + "canonical": true, + "file": "global_public_delegated_prefixes.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "public_delegated_prefix", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalPublicDelegatedPrefixesClient", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes.Delete", + "service": { + "shortName": "GlobalPublicDelegatedPrefixes", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalPublicDelegatedPrefixes_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified global PublicDelegatedPrefix resource.", + "canonical": true, + "file": "global_public_delegated_prefixes.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "public_delegated_prefix", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.PublicDelegatedPrefix", + "client": { + "shortName": "GlobalPublicDelegatedPrefixesClient", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes.Get", + "service": { + "shortName": "GlobalPublicDelegatedPrefixes", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalPublicDelegatedPrefixes_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a global PublicDelegatedPrefix in the specified project using the parameters that are included in the request.", + "canonical": true, + "file": "global_public_delegated_prefixes.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "public_delegated_prefix_resource", + "type": ".google.cloud.compute.v1.PublicDelegatedPrefix" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalPublicDelegatedPrefixesClient", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes.Insert", + "service": { + "shortName": "GlobalPublicDelegatedPrefixes", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalPublicDelegatedPrefixes_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Lists the global PublicDelegatedPrefixes for a project.", + "canonical": true, + "file": "global_public_delegated_prefixes.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.PublicDelegatedPrefixList", + "client": { + "shortName": "GlobalPublicDelegatedPrefixesClient", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes.List", + "service": { + "shortName": "GlobalPublicDelegatedPrefixes", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_GlobalPublicDelegatedPrefixes_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified global PublicDelegatedPrefix resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.", + "canonical": true, + "file": "global_public_delegated_prefixes.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes.Patch", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "public_delegated_prefix", + "type": "TYPE_STRING" + }, + { + "name": "public_delegated_prefix_resource", + "type": ".google.cloud.compute.v1.PublicDelegatedPrefix" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "GlobalPublicDelegatedPrefixesClient", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes.Patch", + "service": { + "shortName": "GlobalPublicDelegatedPrefixes", + "fullName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_HealthChecks_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of all HealthCheck resources, regional and global, available to the specified project.", + "canonical": true, + "file": "health_checks.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.HealthChecks.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.HealthChecksAggregatedList", + "client": { + "shortName": "HealthChecksClient", + "fullName": "google.cloud.compute.v1.HealthChecksClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.HealthChecks.AggregatedList", + "service": { + "shortName": "HealthChecks", + "fullName": "google.cloud.compute.v1.HealthChecks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_HealthChecks_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified HealthCheck resource.", + "canonical": true, + "file": "health_checks.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.HealthChecks.Delete", + "async": true, + "parameters": [ + { + "name": "health_check", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "HealthChecksClient", + "fullName": "google.cloud.compute.v1.HealthChecksClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.HealthChecks.Delete", + "service": { + "shortName": "HealthChecks", + "fullName": "google.cloud.compute.v1.HealthChecks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_HealthChecks_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified HealthCheck resource.", + "canonical": true, + "file": "health_checks.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.HealthChecks.Get", + "async": true, + "parameters": [ + { + "name": "health_check", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.HealthCheck", + "client": { + "shortName": "HealthChecksClient", + "fullName": "google.cloud.compute.v1.HealthChecksClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.HealthChecks.Get", + "service": { + "shortName": "HealthChecks", + "fullName": "google.cloud.compute.v1.HealthChecks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_HealthChecks_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a HealthCheck resource in the specified project using the data included in the request.", + "canonical": true, + "file": "health_checks.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.HealthChecks.Insert", + "async": true, + "parameters": [ + { + "name": "health_check_resource", + "type": ".google.cloud.compute.v1.HealthCheck" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "HealthChecksClient", + "fullName": "google.cloud.compute.v1.HealthChecksClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.HealthChecks.Insert", + "service": { + "shortName": "HealthChecks", + "fullName": "google.cloud.compute.v1.HealthChecks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_HealthChecks_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of HealthCheck resources available to the specified project.", + "canonical": true, + "file": "health_checks.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.HealthChecks.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.HealthCheckList", + "client": { + "shortName": "HealthChecksClient", + "fullName": "google.cloud.compute.v1.HealthChecksClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.HealthChecks.List", + "service": { + "shortName": "HealthChecks", + "fullName": "google.cloud.compute.v1.HealthChecks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_HealthChecks_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Updates a HealthCheck resource in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.", + "canonical": true, + "file": "health_checks.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.HealthChecks.Patch", + "async": true, + "parameters": [ + { + "name": "health_check", + "type": "TYPE_STRING" + }, + { + "name": "health_check_resource", + "type": ".google.cloud.compute.v1.HealthCheck" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "HealthChecksClient", + "fullName": "google.cloud.compute.v1.HealthChecksClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.HealthChecks.Patch", + "service": { + "shortName": "HealthChecks", + "fullName": "google.cloud.compute.v1.HealthChecks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_HealthChecks_Update_async", + "title": "AcceleratorTypes update Sample", + "origin": "API_DEFINITION", + "description": " Updates a HealthCheck resource in the specified project using the data included in the request.", + "canonical": true, + "file": "health_checks.update.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.HealthChecks.Update", + "async": true, + "parameters": [ + { + "name": "health_check", + "type": "TYPE_STRING" + }, + { + "name": "health_check_resource", + "type": ".google.cloud.compute.v1.HealthCheck" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "HealthChecksClient", + "fullName": "google.cloud.compute.v1.HealthChecksClient" + }, + "method": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.HealthChecks.Update", + "service": { + "shortName": "HealthChecks", + "fullName": "google.cloud.compute.v1.HealthChecks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ImageFamilyViews_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the latest image that is part of an image family, is not deprecated and is rolled out in the specified zone.", + "canonical": true, + "file": "image_family_views.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.ImageFamilyViews.Get", + "async": true, + "parameters": [ + { + "name": "family", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.ImageFamilyView", + "client": { + "shortName": "ImageFamilyViewsClient", + "fullName": "google.cloud.compute.v1.ImageFamilyViewsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.ImageFamilyViews.Get", + "service": { + "shortName": "ImageFamilyViews", + "fullName": "google.cloud.compute.v1.ImageFamilyViews" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Images_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified image.", + "canonical": true, + "file": "images.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Images.Delete", + "async": true, + "parameters": [ + { + "name": "image", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ImagesClient", + "fullName": "google.cloud.compute.v1.ImagesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Images.Delete", + "service": { + "shortName": "Images", + "fullName": "google.cloud.compute.v1.Images" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Images_Deprecate_async", + "title": "AcceleratorTypes deprecate Sample", + "origin": "API_DEFINITION", + "description": " Sets the deprecation status of an image. If an empty request body is given, clears the deprecation status instead.", + "canonical": true, + "file": "images.deprecate.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Deprecate", + "fullName": "google.cloud.compute.v1.Images.Deprecate", + "async": true, + "parameters": [ + { + "name": "deprecation_status_resource", + "type": ".google.cloud.compute.v1.DeprecationStatus" + }, + { + "name": "image", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ImagesClient", + "fullName": "google.cloud.compute.v1.ImagesClient" + }, + "method": { + "shortName": "Deprecate", + "fullName": "google.cloud.compute.v1.Images.Deprecate", + "service": { + "shortName": "Images", + "fullName": "google.cloud.compute.v1.Images" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Images_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified image.", + "canonical": true, + "file": "images.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Images.Get", + "async": true, + "parameters": [ + { + "name": "image", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Image", + "client": { + "shortName": "ImagesClient", + "fullName": "google.cloud.compute.v1.ImagesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Images.Get", + "service": { + "shortName": "Images", + "fullName": "google.cloud.compute.v1.Images" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Images_GetFromFamily_async", + "title": "AcceleratorTypes getFromFamily Sample", + "origin": "API_DEFINITION", + "description": " Returns the latest image that is part of an image family and is not deprecated. For more information on image families, see Public image families documentation.", + "canonical": true, + "file": "images.get_from_family.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetFromFamily", + "fullName": "google.cloud.compute.v1.Images.GetFromFamily", + "async": true, + "parameters": [ + { + "name": "family", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Image", + "client": { + "shortName": "ImagesClient", + "fullName": "google.cloud.compute.v1.ImagesClient" + }, + "method": { + "shortName": "GetFromFamily", + "fullName": "google.cloud.compute.v1.Images.GetFromFamily", + "service": { + "shortName": "Images", + "fullName": "google.cloud.compute.v1.Images" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Images_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "images.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.Images.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "ImagesClient", + "fullName": "google.cloud.compute.v1.ImagesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.Images.GetIamPolicy", + "service": { + "shortName": "Images", + "fullName": "google.cloud.compute.v1.Images" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Images_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates an image in the specified project using the data included in the request.", + "canonical": true, + "file": "images.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Images.Insert", + "async": true, + "parameters": [ + { + "name": "force_create", + "type": "TYPE_BOOL" + }, + { + "name": "image_resource", + "type": ".google.cloud.compute.v1.Image" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ImagesClient", + "fullName": "google.cloud.compute.v1.ImagesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Images.Insert", + "service": { + "shortName": "Images", + "fullName": "google.cloud.compute.v1.Images" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Images_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of custom images available to the specified project. Custom images are images you create that belong to your project. This method does not get any images that belong to other projects, including publicly-available images, like Debian 8. If you want to get a list of publicly-available images, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud.", + "canonical": true, + "file": "images.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Images.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.ImageList", + "client": { + "shortName": "ImagesClient", + "fullName": "google.cloud.compute.v1.ImagesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Images.List", + "service": { + "shortName": "Images", + "fullName": "google.cloud.compute.v1.Images" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Images_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified image with the data included in the request. Only the following fields can be modified: family, description, deprecation status.", + "canonical": true, + "file": "images.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.Images.Patch", + "async": true, + "parameters": [ + { + "name": "image", + "type": "TYPE_STRING" + }, + { + "name": "image_resource", + "type": ".google.cloud.compute.v1.Image" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ImagesClient", + "fullName": "google.cloud.compute.v1.ImagesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.Images.Patch", + "service": { + "shortName": "Images", + "fullName": "google.cloud.compute.v1.Images" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Images_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "images.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.Images.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "global_set_policy_request_resource", + "type": ".google.cloud.compute.v1.GlobalSetPolicyRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "ImagesClient", + "fullName": "google.cloud.compute.v1.ImagesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.Images.SetIamPolicy", + "service": { + "shortName": "Images", + "fullName": "google.cloud.compute.v1.Images" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Images_SetLabels_async", + "title": "AcceleratorTypes setLabels Sample", + "origin": "API_DEFINITION", + "description": " Sets the labels on an image. To learn more about labels, read the Labeling Resources documentation.", + "canonical": true, + "file": "images.set_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.Images.SetLabels", + "async": true, + "parameters": [ + { + "name": "global_set_labels_request_resource", + "type": ".google.cloud.compute.v1.GlobalSetLabelsRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ImagesClient", + "fullName": "google.cloud.compute.v1.ImagesClient" + }, + "method": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.Images.SetLabels", + "service": { + "shortName": "Images", + "fullName": "google.cloud.compute.v1.Images" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Images_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "images.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.Images.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "ImagesClient", + "fullName": "google.cloud.compute.v1.ImagesClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.Images.TestIamPermissions", + "service": { + "shortName": "Images", + "fullName": "google.cloud.compute.v1.Images" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_AbandonInstances_async", + "title": "AcceleratorTypes abandonInstances Sample", + "origin": "API_DEFINITION", + "description": " Flags the specified instances to be removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.", + "canonical": true, + "file": "instance_group_managers.abandon_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AbandonInstances", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.AbandonInstances", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_managers_abandon_instances_request_resource", + "type": ".google.cloud.compute.v1.InstanceGroupManagersAbandonInstancesRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "AbandonInstances", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.AbandonInstances", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of managed instance groups and groups them by zone.", + "canonical": true, + "file": "instance_group_managers.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceGroupManagerAggregatedList", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.AggregatedList", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_ApplyUpdatesToInstances_async", + "title": "AcceleratorTypes applyUpdatesToInstances Sample", + "origin": "API_DEFINITION", + "description": " Applies changes to selected instances on the managed instance group. This method can be used to apply new overrides and/or new versions.", + "canonical": true, + "file": "instance_group_managers.apply_updates_to_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ApplyUpdatesToInstances", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.ApplyUpdatesToInstances", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_managers_apply_updates_request_resource", + "type": ".google.cloud.compute.v1.InstanceGroupManagersApplyUpdatesRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "ApplyUpdatesToInstances", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.ApplyUpdatesToInstances", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_CreateInstances_async", + "title": "AcceleratorTypes createInstances Sample", + "origin": "API_DEFINITION", + "description": " Creates instances with per-instance configurations in this managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method.", + "canonical": true, + "file": "instance_group_managers.create_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateInstances", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.CreateInstances", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_managers_create_instances_request_resource", + "type": ".google.cloud.compute.v1.InstanceGroupManagersCreateInstancesRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "CreateInstances", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.CreateInstances", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified managed instance group and all of the instances in that group. Note that the instance group must not belong to a backend service. Read Deleting an instance group for more information.", + "canonical": true, + "file": "instance_group_managers.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.Delete", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.Delete", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_DeleteInstances_async", + "title": "AcceleratorTypes deleteInstances Sample", + "origin": "API_DEFINITION", + "description": " Flags the specified instances in the managed instance group for immediate deletion. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. This operation is marked as DONE when the action is scheduled even if the instances are still being deleted. You must separately verify the status of the deleting action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.", + "canonical": true, + "file": "instance_group_managers.delete_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteInstances", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.DeleteInstances", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_managers_delete_instances_request_resource", + "type": ".google.cloud.compute.v1.InstanceGroupManagersDeleteInstancesRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "DeleteInstances", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.DeleteInstances", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_DeletePerInstanceConfigs_async", + "title": "AcceleratorTypes deletePerInstanceConfigs Sample", + "origin": "API_DEFINITION", + "description": " Deletes selected per-instance configurations for the managed instance group.", + "canonical": true, + "file": "instance_group_managers.delete_per_instance_configs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeletePerInstanceConfigs", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.DeletePerInstanceConfigs", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_managers_delete_per_instance_configs_req_resource", + "type": ".google.cloud.compute.v1.InstanceGroupManagersDeletePerInstanceConfigsReq" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "DeletePerInstanceConfigs", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.DeletePerInstanceConfigs", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns all of the details about the specified managed instance group.", + "canonical": true, + "file": "instance_group_managers.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.Get", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceGroupManager", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.Get", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. A managed instance group can have up to 1000 VM instances per group. Please contact Cloud Support if you need an increase in this limit.", + "canonical": true, + "file": "instance_group_managers.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.Insert", + "async": true, + "parameters": [ + { + "name": "instance_group_manager_resource", + "type": ".google.cloud.compute.v1.InstanceGroupManager" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.Insert", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of managed instance groups that are contained within the specified project and zone.", + "canonical": true, + "file": "instance_group_managers.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceGroupManagerList", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.List", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_ListErrors_async", + "title": "AcceleratorTypes listErrors Sample", + "origin": "API_DEFINITION", + "description": " Lists all errors thrown by actions on instances for a given managed instance group. The filter and orderBy query parameters are not supported.", + "canonical": true, + "file": "instance_group_managers.list_errors.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListErrors", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.ListErrors", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceGroupManagersListErrorsResponse", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "ListErrors", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.ListErrors", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_ListManagedInstances_async", + "title": "AcceleratorTypes listManagedInstances Sample", + "origin": "API_DEFINITION", + "description": " Lists all of the instances in the managed instance group. Each instance in the list has a currentAction, which indicates the action that the managed instance group is performing on the instance. For example, if the group is still creating an instance, the currentAction is CREATING. If a previous action failed, the list displays the errors for that failed action. The orderBy query parameter is not supported. The `pageToken` query parameter is supported only in the alpha and beta API and only if the group's `listManagedInstancesResults` field is set to `PAGINATED`.", + "canonical": true, + "file": "instance_group_managers.list_managed_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListManagedInstances", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.ListManagedInstances", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceGroupManagersListManagedInstancesResponse", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "ListManagedInstances", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.ListManagedInstances", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_ListPerInstanceConfigs_async", + "title": "AcceleratorTypes listPerInstanceConfigs Sample", + "origin": "API_DEFINITION", + "description": " Lists all of the per-instance configurations defined for the managed instance group. The orderBy query parameter is not supported.", + "canonical": true, + "file": "instance_group_managers.list_per_instance_configs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListPerInstanceConfigs", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.ListPerInstanceConfigs", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceGroupManagersListPerInstanceConfigsResp", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "ListPerInstanceConfigs", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.ListPerInstanceConfigs", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listManagedInstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. If you update your group to specify a new template or instance configuration, it's possible that your intended specification for each VM in the group is different from the current state of that VM. To learn how to apply an updated configuration to the VMs in a MIG, see Updating instances in a MIG.", + "canonical": true, + "file": "instance_group_managers.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.Patch", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_manager_resource", + "type": ".google.cloud.compute.v1.InstanceGroupManager" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.Patch", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_PatchPerInstanceConfigs_async", + "title": "AcceleratorTypes patchPerInstanceConfigs Sample", + "origin": "API_DEFINITION", + "description": " Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch.", + "canonical": true, + "file": "instance_group_managers.patch_per_instance_configs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PatchPerInstanceConfigs", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.PatchPerInstanceConfigs", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_managers_patch_per_instance_configs_req_resource", + "type": ".google.cloud.compute.v1.InstanceGroupManagersPatchPerInstanceConfigsReq" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "PatchPerInstanceConfigs", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.PatchPerInstanceConfigs", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_RecreateInstances_async", + "title": "AcceleratorTypes recreateInstances Sample", + "origin": "API_DEFINITION", + "description": " Flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group's current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.", + "canonical": true, + "file": "instance_group_managers.recreate_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RecreateInstances", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.RecreateInstances", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_managers_recreate_instances_request_resource", + "type": ".google.cloud.compute.v1.InstanceGroupManagersRecreateInstancesRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "RecreateInstances", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.RecreateInstances", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_Resize_async", + "title": "AcceleratorTypes resize Sample", + "origin": "API_DEFINITION", + "description": " Resizes the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes instances. The resize operation is marked DONE when the resize actions are scheduled even if the group has not yet added or deleted any instances. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. When resizing down, the instance group arbitrarily chooses the order in which VMs are deleted. The group takes into account some VM attributes when making the selection including: + The status of the VM instance. + The health of the VM instance. + The instance template version the VM is based on. + For regional managed instance groups, the location of the VM instance. This list is subject to change. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted.", + "canonical": true, + "file": "instance_group_managers.resize.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Resize", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.Resize", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "size", + "type": "TYPE_INT32" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "Resize", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.Resize", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_SetInstanceTemplate_async", + "title": "AcceleratorTypes setInstanceTemplate Sample", + "origin": "API_DEFINITION", + "description": " Specifies the instance template to use when creating new instances in this group. The templates for existing instances in the group do not change unless you run recreateInstances, run applyUpdatesToInstances, or set the group's updatePolicy.type to PROACTIVE.", + "canonical": true, + "file": "instance_group_managers.set_instance_template.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInstanceTemplate", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.SetInstanceTemplate", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_managers_set_instance_template_request_resource", + "type": ".google.cloud.compute.v1.InstanceGroupManagersSetInstanceTemplateRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "SetInstanceTemplate", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.SetInstanceTemplate", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_SetTargetPools_async", + "title": "AcceleratorTypes setTargetPools Sample", + "origin": "API_DEFINITION", + "description": " Modifies the target pools to which all instances in this managed instance group are assigned. The target pools automatically apply to all of the instances in the managed instance group. This operation is marked DONE when you make the request even if the instances have not yet been added to their target pools. The change might take some time to apply to all of the instances in the group depending on the size of the group.", + "canonical": true, + "file": "instance_group_managers.set_target_pools.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetTargetPools", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.SetTargetPools", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_managers_set_target_pools_request_resource", + "type": ".google.cloud.compute.v1.InstanceGroupManagersSetTargetPoolsRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "SetTargetPools", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.SetTargetPools", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroupManagers_UpdatePerInstanceConfigs_async", + "title": "AcceleratorTypes updatePerInstanceConfigs Sample", + "origin": "API_DEFINITION", + "description": " Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch.", + "canonical": true, + "file": "instance_group_managers.update_per_instance_configs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdatePerInstanceConfigs", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.UpdatePerInstanceConfigs", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_managers_update_per_instance_configs_req_resource", + "type": ".google.cloud.compute.v1.InstanceGroupManagersUpdatePerInstanceConfigsReq" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.InstanceGroupManagersClient" + }, + "method": { + "shortName": "UpdatePerInstanceConfigs", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.UpdatePerInstanceConfigs", + "service": { + "shortName": "InstanceGroupManagers", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroups_AddInstances_async", + "title": "AcceleratorTypes addInstances Sample", + "origin": "API_DEFINITION", + "description": " Adds a list of instances to the specified instance group. All of the instances in the instance group must be in the same network/subnetwork. Read Adding instances for more information.", + "canonical": true, + "file": "instance_groups.add_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddInstances", + "fullName": "google.cloud.compute.v1.InstanceGroups.AddInstances", + "async": true, + "parameters": [ + { + "name": "instance_group", + "type": "TYPE_STRING" + }, + { + "name": "instance_groups_add_instances_request_resource", + "type": ".google.cloud.compute.v1.InstanceGroupsAddInstancesRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupsClient", + "fullName": "google.cloud.compute.v1.InstanceGroupsClient" + }, + "method": { + "shortName": "AddInstances", + "fullName": "google.cloud.compute.v1.InstanceGroups.AddInstances", + "service": { + "shortName": "InstanceGroups", + "fullName": "google.cloud.compute.v1.InstanceGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroups_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of instance groups and sorts them by zone.", + "canonical": true, + "file": "instance_groups.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.InstanceGroups.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceGroupAggregatedList", + "client": { + "shortName": "InstanceGroupsClient", + "fullName": "google.cloud.compute.v1.InstanceGroupsClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.InstanceGroups.AggregatedList", + "service": { + "shortName": "InstanceGroups", + "fullName": "google.cloud.compute.v1.InstanceGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroups_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified instance group. The instances in the group are not deleted. Note that instance group must not belong to a backend service. Read Deleting an instance group for more information.", + "canonical": true, + "file": "instance_groups.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.InstanceGroups.Delete", + "async": true, + "parameters": [ + { + "name": "instance_group", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupsClient", + "fullName": "google.cloud.compute.v1.InstanceGroupsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.InstanceGroups.Delete", + "service": { + "shortName": "InstanceGroups", + "fullName": "google.cloud.compute.v1.InstanceGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroups_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified zonal instance group. Get a list of available zonal instance groups by making a list() request. For managed instance groups, use the instanceGroupManagers or regionInstanceGroupManagers methods instead.", + "canonical": true, + "file": "instance_groups.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.InstanceGroups.Get", + "async": true, + "parameters": [ + { + "name": "instance_group", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceGroup", + "client": { + "shortName": "InstanceGroupsClient", + "fullName": "google.cloud.compute.v1.InstanceGroupsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.InstanceGroups.Get", + "service": { + "shortName": "InstanceGroups", + "fullName": "google.cloud.compute.v1.InstanceGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroups_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates an instance group in the specified project using the parameters that are included in the request.", + "canonical": true, + "file": "instance_groups.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.InstanceGroups.Insert", + "async": true, + "parameters": [ + { + "name": "instance_group_resource", + "type": ".google.cloud.compute.v1.InstanceGroup" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupsClient", + "fullName": "google.cloud.compute.v1.InstanceGroupsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.InstanceGroups.Insert", + "service": { + "shortName": "InstanceGroups", + "fullName": "google.cloud.compute.v1.InstanceGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroups_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of zonal instance group resources contained within the specified zone. For managed instance groups, use the instanceGroupManagers or regionInstanceGroupManagers methods instead.", + "canonical": true, + "file": "instance_groups.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.InstanceGroups.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceGroupList", + "client": { + "shortName": "InstanceGroupsClient", + "fullName": "google.cloud.compute.v1.InstanceGroupsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.InstanceGroups.List", + "service": { + "shortName": "InstanceGroups", + "fullName": "google.cloud.compute.v1.InstanceGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroups_ListInstances_async", + "title": "AcceleratorTypes listInstances Sample", + "origin": "API_DEFINITION", + "description": " Lists the instances in the specified instance group. The orderBy query parameter is not supported. The filter query parameter is supported, but only for expressions that use `eq` (equal) or `ne` (not equal) operators.", + "canonical": true, + "file": "instance_groups.list_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 90, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListInstances", + "fullName": "google.cloud.compute.v1.InstanceGroups.ListInstances", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "instance_group", + "type": "TYPE_STRING" + }, + { + "name": "instance_groups_list_instances_request_resource", + "type": ".google.cloud.compute.v1.InstanceGroupsListInstancesRequest" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceGroupsListInstances", + "client": { + "shortName": "InstanceGroupsClient", + "fullName": "google.cloud.compute.v1.InstanceGroupsClient" + }, + "method": { + "shortName": "ListInstances", + "fullName": "google.cloud.compute.v1.InstanceGroups.ListInstances", + "service": { + "shortName": "InstanceGroups", + "fullName": "google.cloud.compute.v1.InstanceGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroups_RemoveInstances_async", + "title": "AcceleratorTypes removeInstances Sample", + "origin": "API_DEFINITION", + "description": " Removes one or more instances from the specified instance group, but does not delete those instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration before the VM instance is removed or deleted.", + "canonical": true, + "file": "instance_groups.remove_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveInstances", + "fullName": "google.cloud.compute.v1.InstanceGroups.RemoveInstances", + "async": true, + "parameters": [ + { + "name": "instance_group", + "type": "TYPE_STRING" + }, + { + "name": "instance_groups_remove_instances_request_resource", + "type": ".google.cloud.compute.v1.InstanceGroupsRemoveInstancesRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupsClient", + "fullName": "google.cloud.compute.v1.InstanceGroupsClient" + }, + "method": { + "shortName": "RemoveInstances", + "fullName": "google.cloud.compute.v1.InstanceGroups.RemoveInstances", + "service": { + "shortName": "InstanceGroups", + "fullName": "google.cloud.compute.v1.InstanceGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceGroups_SetNamedPorts_async", + "title": "AcceleratorTypes setNamedPorts Sample", + "origin": "API_DEFINITION", + "description": " Sets the named ports for the specified instance group.", + "canonical": true, + "file": "instance_groups.set_named_ports.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetNamedPorts", + "fullName": "google.cloud.compute.v1.InstanceGroups.SetNamedPorts", + "async": true, + "parameters": [ + { + "name": "instance_group", + "type": "TYPE_STRING" + }, + { + "name": "instance_groups_set_named_ports_request_resource", + "type": ".google.cloud.compute.v1.InstanceGroupsSetNamedPortsRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceGroupsClient", + "fullName": "google.cloud.compute.v1.InstanceGroupsClient" + }, + "method": { + "shortName": "SetNamedPorts", + "fullName": "google.cloud.compute.v1.InstanceGroups.SetNamedPorts", + "service": { + "shortName": "InstanceGroups", + "fullName": "google.cloud.compute.v1.InstanceGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_AddAccessConfig_async", + "title": "AcceleratorTypes addAccessConfig Sample", + "origin": "API_DEFINITION", + "description": " Adds an access config to an instance's network interface.", + "canonical": true, + "file": "instances.add_access_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddAccessConfig", + "fullName": "google.cloud.compute.v1.Instances.AddAccessConfig", + "async": true, + "parameters": [ + { + "name": "access_config_resource", + "type": ".google.cloud.compute.v1.AccessConfig" + }, + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "network_interface", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "AddAccessConfig", + "fullName": "google.cloud.compute.v1.Instances.AddAccessConfig", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_AddResourcePolicies_async", + "title": "AcceleratorTypes addResourcePolicies Sample", + "origin": "API_DEFINITION", + "description": " Adds existing resource policies to an instance. You can only add one policy right now which will be applied to this instance for scheduling live migrations.", + "canonical": true, + "file": "instances.add_resource_policies.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddResourcePolicies", + "fullName": "google.cloud.compute.v1.Instances.AddResourcePolicies", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "instances_add_resource_policies_request_resource", + "type": ".google.cloud.compute.v1.InstancesAddResourcePoliciesRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "AddResourcePolicies", + "fullName": "google.cloud.compute.v1.Instances.AddResourcePolicies", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of all of the instances in your project across all regions and zones. The performance of this method degrades when a filter is specified on a project that has a very large number of instances.", + "canonical": true, + "file": "instances.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.Instances.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceAggregatedList", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.Instances.AggregatedList", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_AttachDisk_async", + "title": "AcceleratorTypes attachDisk Sample", + "origin": "API_DEFINITION", + "description": " Attaches an existing Disk resource to an instance. You must first create the disk before you can attach it. It is not possible to create and attach a disk at the same time. For more information, read Adding a persistent disk to your instance.", + "canonical": true, + "file": "instances.attach_disk.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 76, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AttachDisk", + "fullName": "google.cloud.compute.v1.Instances.AttachDisk", + "async": true, + "parameters": [ + { + "name": "attached_disk_resource", + "type": ".google.cloud.compute.v1.AttachedDisk" + }, + { + "name": "force_attach", + "type": "TYPE_BOOL" + }, + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "AttachDisk", + "fullName": "google.cloud.compute.v1.Instances.AttachDisk", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_BulkInsert_async", + "title": "AcceleratorTypes bulkInsert Sample", + "origin": "API_DEFINITION", + "description": " Creates multiple instances. Count specifies the number of instances to create. For more information, see About bulk creation of VMs.", + "canonical": true, + "file": "instances.bulk_insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BulkInsert", + "fullName": "google.cloud.compute.v1.Instances.BulkInsert", + "async": true, + "parameters": [ + { + "name": "bulk_insert_instance_resource_resource", + "type": ".google.cloud.compute.v1.BulkInsertInstanceResource" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "BulkInsert", + "fullName": "google.cloud.compute.v1.Instances.BulkInsert", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified Instance resource. For more information, see Deleting an instance.", + "canonical": true, + "file": "instances.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Instances.Delete", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Instances.Delete", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_DeleteAccessConfig_async", + "title": "AcceleratorTypes deleteAccessConfig Sample", + "origin": "API_DEFINITION", + "description": " Deletes an access config from an instance's network interface.", + "canonical": true, + "file": "instances.delete_access_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteAccessConfig", + "fullName": "google.cloud.compute.v1.Instances.DeleteAccessConfig", + "async": true, + "parameters": [ + { + "name": "access_config", + "type": "TYPE_STRING" + }, + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "network_interface", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "DeleteAccessConfig", + "fullName": "google.cloud.compute.v1.Instances.DeleteAccessConfig", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_DetachDisk_async", + "title": "AcceleratorTypes detachDisk Sample", + "origin": "API_DEFINITION", + "description": " Detaches a disk from an instance.", + "canonical": true, + "file": "instances.detach_disk.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DetachDisk", + "fullName": "google.cloud.compute.v1.Instances.DetachDisk", + "async": true, + "parameters": [ + { + "name": "device_name", + "type": "TYPE_STRING" + }, + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "DetachDisk", + "fullName": "google.cloud.compute.v1.Instances.DetachDisk", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified Instance resource.", + "canonical": true, + "file": "instances.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Instances.Get", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Instance", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Instances.Get", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_GetEffectiveFirewalls_async", + "title": "AcceleratorTypes getEffectiveFirewalls Sample", + "origin": "API_DEFINITION", + "description": " Returns effective firewalls applied to an interface of the instance.", + "canonical": true, + "file": "instances.get_effective_firewalls.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetEffectiveFirewalls", + "fullName": "google.cloud.compute.v1.Instances.GetEffectiveFirewalls", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "network_interface", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InstancesGetEffectiveFirewallsResponse", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "GetEffectiveFirewalls", + "fullName": "google.cloud.compute.v1.Instances.GetEffectiveFirewalls", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_GetGuestAttributes_async", + "title": "AcceleratorTypes getGuestAttributes Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified guest attributes entry.", + "canonical": true, + "file": "instances.get_guest_attributes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetGuestAttributes", + "fullName": "google.cloud.compute.v1.Instances.GetGuestAttributes", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "query_path", + "type": "TYPE_STRING" + }, + { + "name": "variable_key", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.GuestAttributes", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "GetGuestAttributes", + "fullName": "google.cloud.compute.v1.Instances.GetGuestAttributes", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "instances.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.Instances.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.Instances.GetIamPolicy", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_GetScreenshot_async", + "title": "AcceleratorTypes getScreenshot Sample", + "origin": "API_DEFINITION", + "description": " Returns the screenshot from the specified instance.", + "canonical": true, + "file": "instances.get_screenshot.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetScreenshot", + "fullName": "google.cloud.compute.v1.Instances.GetScreenshot", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Screenshot", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "GetScreenshot", + "fullName": "google.cloud.compute.v1.Instances.GetScreenshot", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_GetSerialPortOutput_async", + "title": "AcceleratorTypes getSerialPortOutput Sample", + "origin": "API_DEFINITION", + "description": " Returns the last 1 MB of serial port output from the specified instance.", + "canonical": true, + "file": "instances.get_serial_port_output.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetSerialPortOutput", + "fullName": "google.cloud.compute.v1.Instances.GetSerialPortOutput", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "port", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "start", + "type": "TYPE_INT64" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.SerialPortOutput", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "GetSerialPortOutput", + "fullName": "google.cloud.compute.v1.Instances.GetSerialPortOutput", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_GetShieldedInstanceIdentity_async", + "title": "AcceleratorTypes getShieldedInstanceIdentity Sample", + "origin": "API_DEFINITION", + "description": " Returns the Shielded Instance Identity of an instance", + "canonical": true, + "file": "instances.get_shielded_instance_identity.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetShieldedInstanceIdentity", + "fullName": "google.cloud.compute.v1.Instances.GetShieldedInstanceIdentity", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.ShieldedInstanceIdentity", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "GetShieldedInstanceIdentity", + "fullName": "google.cloud.compute.v1.Instances.GetShieldedInstanceIdentity", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates an instance resource in the specified project using the data included in the request.", + "canonical": true, + "file": "instances.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Instances.Insert", + "async": true, + "parameters": [ + { + "name": "instance_resource", + "type": ".google.cloud.compute.v1.Instance" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "source_instance_template", + "type": "TYPE_STRING" + }, + { + "name": "source_machine_image", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Instances.Insert", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of instances contained within the specified zone.", + "canonical": true, + "file": "instances.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Instances.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceList", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Instances.List", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_ListReferrers_async", + "title": "AcceleratorTypes listReferrers Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of resources that refer to the VM instance specified in the request. For example, if the VM instance is part of a managed or unmanaged instance group, the referrers list includes the instance group. For more information, read Viewing referrers to VM instances.", + "canonical": true, + "file": "instances.list_referrers.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListReferrers", + "fullName": "google.cloud.compute.v1.Instances.ListReferrers", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceListReferrers", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "ListReferrers", + "fullName": "google.cloud.compute.v1.Instances.ListReferrers", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_RemoveResourcePolicies_async", + "title": "AcceleratorTypes removeResourcePolicies Sample", + "origin": "API_DEFINITION", + "description": " Removes resource policies from an instance.", + "canonical": true, + "file": "instances.remove_resource_policies.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveResourcePolicies", + "fullName": "google.cloud.compute.v1.Instances.RemoveResourcePolicies", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "instances_remove_resource_policies_request_resource", + "type": ".google.cloud.compute.v1.InstancesRemoveResourcePoliciesRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "RemoveResourcePolicies", + "fullName": "google.cloud.compute.v1.Instances.RemoveResourcePolicies", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_Reset_async", + "title": "AcceleratorTypes reset Sample", + "origin": "API_DEFINITION", + "description": " Performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more information, see Resetting an instance.", + "canonical": true, + "file": "instances.reset.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Reset", + "fullName": "google.cloud.compute.v1.Instances.Reset", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "Reset", + "fullName": "google.cloud.compute.v1.Instances.Reset", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_Resume_async", + "title": "AcceleratorTypes resume Sample", + "origin": "API_DEFINITION", + "description": " Resumes an instance that was suspended using the instances().suspend method.", + "canonical": true, + "file": "instances.resume.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Resume", + "fullName": "google.cloud.compute.v1.Instances.Resume", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "Resume", + "fullName": "google.cloud.compute.v1.Instances.Resume", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_SendDiagnosticInterrupt_async", + "title": "AcceleratorTypes sendDiagnosticInterrupt Sample", + "origin": "API_DEFINITION", + "description": " Sends diagnostic interrupt to the instance.", + "canonical": true, + "file": "instances.send_diagnostic_interrupt.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SendDiagnosticInterrupt", + "fullName": "google.cloud.compute.v1.Instances.SendDiagnosticInterrupt", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.SendDiagnosticInterruptInstanceResponse", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "SendDiagnosticInterrupt", + "fullName": "google.cloud.compute.v1.Instances.SendDiagnosticInterrupt", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_SetDeletionProtection_async", + "title": "AcceleratorTypes setDeletionProtection Sample", + "origin": "API_DEFINITION", + "description": " Sets deletion protection on the instance.", + "canonical": true, + "file": "instances.set_deletion_protection.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetDeletionProtection", + "fullName": "google.cloud.compute.v1.Instances.SetDeletionProtection", + "async": true, + "parameters": [ + { + "name": "deletion_protection", + "type": "TYPE_BOOL" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "SetDeletionProtection", + "fullName": "google.cloud.compute.v1.Instances.SetDeletionProtection", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_SetDiskAutoDelete_async", + "title": "AcceleratorTypes setDiskAutoDelete Sample", + "origin": "API_DEFINITION", + "description": " Sets the auto-delete flag for a disk attached to an instance.", + "canonical": true, + "file": "instances.set_disk_auto_delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetDiskAutoDelete", + "fullName": "google.cloud.compute.v1.Instances.SetDiskAutoDelete", + "async": true, + "parameters": [ + { + "name": "auto_delete", + "type": "TYPE_BOOL" + }, + { + "name": "device_name", + "type": "TYPE_STRING" + }, + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "SetDiskAutoDelete", + "fullName": "google.cloud.compute.v1.Instances.SetDiskAutoDelete", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "instances.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.Instances.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + }, + { + "name": "zone_set_policy_request_resource", + "type": ".google.cloud.compute.v1.ZoneSetPolicyRequest" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.Instances.SetIamPolicy", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_SetLabels_async", + "title": "AcceleratorTypes setLabels Sample", + "origin": "API_DEFINITION", + "description": " Sets labels on an instance. To learn more about labels, read the Labeling Resources documentation.", + "canonical": true, + "file": "instances.set_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.Instances.SetLabels", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "instances_set_labels_request_resource", + "type": ".google.cloud.compute.v1.InstancesSetLabelsRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.Instances.SetLabels", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_SetMachineResources_async", + "title": "AcceleratorTypes setMachineResources Sample", + "origin": "API_DEFINITION", + "description": " Changes the number and/or type of accelerator for a stopped instance to the values specified in the request.", + "canonical": true, + "file": "instances.set_machine_resources.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetMachineResources", + "fullName": "google.cloud.compute.v1.Instances.SetMachineResources", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "instances_set_machine_resources_request_resource", + "type": ".google.cloud.compute.v1.InstancesSetMachineResourcesRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "SetMachineResources", + "fullName": "google.cloud.compute.v1.Instances.SetMachineResources", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_SetMachineType_async", + "title": "AcceleratorTypes setMachineType Sample", + "origin": "API_DEFINITION", + "description": " Changes the machine type for a stopped instance to the machine type specified in the request.", + "canonical": true, + "file": "instances.set_machine_type.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetMachineType", + "fullName": "google.cloud.compute.v1.Instances.SetMachineType", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "instances_set_machine_type_request_resource", + "type": ".google.cloud.compute.v1.InstancesSetMachineTypeRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "SetMachineType", + "fullName": "google.cloud.compute.v1.Instances.SetMachineType", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_SetMetadata_async", + "title": "AcceleratorTypes setMetadata Sample", + "origin": "API_DEFINITION", + "description": " Sets metadata for the specified instance to the data included in the request.", + "canonical": true, + "file": "instances.set_metadata.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetMetadata", + "fullName": "google.cloud.compute.v1.Instances.SetMetadata", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "metadata_resource", + "type": ".google.cloud.compute.v1.Metadata" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "SetMetadata", + "fullName": "google.cloud.compute.v1.Instances.SetMetadata", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_SetMinCpuPlatform_async", + "title": "AcceleratorTypes setMinCpuPlatform Sample", + "origin": "API_DEFINITION", + "description": " Changes the minimum CPU platform that this instance should use. This method can only be called on a stopped instance. For more information, read Specifying a Minimum CPU Platform.", + "canonical": true, + "file": "instances.set_min_cpu_platform.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetMinCpuPlatform", + "fullName": "google.cloud.compute.v1.Instances.SetMinCpuPlatform", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "instances_set_min_cpu_platform_request_resource", + "type": ".google.cloud.compute.v1.InstancesSetMinCpuPlatformRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "SetMinCpuPlatform", + "fullName": "google.cloud.compute.v1.Instances.SetMinCpuPlatform", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_SetName_async", + "title": "AcceleratorTypes setName Sample", + "origin": "API_DEFINITION", + "description": " Sets name of an instance.", + "canonical": true, + "file": "instances.set_name.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetName", + "fullName": "google.cloud.compute.v1.Instances.SetName", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "instances_set_name_request_resource", + "type": ".google.cloud.compute.v1.InstancesSetNameRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "SetName", + "fullName": "google.cloud.compute.v1.Instances.SetName", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_SetScheduling_async", + "title": "AcceleratorTypes setScheduling Sample", + "origin": "API_DEFINITION", + "description": " Sets an instance's scheduling options. You can only call this method on a stopped instance, that is, a VM instance that is in a `TERMINATED` state. See Instance Life Cycle for more information on the possible instance states. For more information about setting scheduling options for a VM, see Set VM host maintenance policy.", + "canonical": true, + "file": "instances.set_scheduling.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetScheduling", + "fullName": "google.cloud.compute.v1.Instances.SetScheduling", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "scheduling_resource", + "type": ".google.cloud.compute.v1.Scheduling" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "SetScheduling", + "fullName": "google.cloud.compute.v1.Instances.SetScheduling", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_SetServiceAccount_async", + "title": "AcceleratorTypes setServiceAccount Sample", + "origin": "API_DEFINITION", + "description": " Sets the service account on the instance. For more information, read Changing the service account and access scopes for an instance.", + "canonical": true, + "file": "instances.set_service_account.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetServiceAccount", + "fullName": "google.cloud.compute.v1.Instances.SetServiceAccount", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "instances_set_service_account_request_resource", + "type": ".google.cloud.compute.v1.InstancesSetServiceAccountRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "SetServiceAccount", + "fullName": "google.cloud.compute.v1.Instances.SetServiceAccount", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_SetShieldedInstanceIntegrityPolicy_async", + "title": "AcceleratorTypes setShieldedInstanceIntegrityPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the Shielded Instance integrity policy for an instance. You can only use this method on a running instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.", + "canonical": true, + "file": "instances.set_shielded_instance_integrity_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetShieldedInstanceIntegrityPolicy", + "fullName": "google.cloud.compute.v1.Instances.SetShieldedInstanceIntegrityPolicy", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "shielded_instance_integrity_policy_resource", + "type": ".google.cloud.compute.v1.ShieldedInstanceIntegrityPolicy" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "SetShieldedInstanceIntegrityPolicy", + "fullName": "google.cloud.compute.v1.Instances.SetShieldedInstanceIntegrityPolicy", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_SetTags_async", + "title": "AcceleratorTypes setTags Sample", + "origin": "API_DEFINITION", + "description": " Sets network tags for the specified instance to the data included in the request.", + "canonical": true, + "file": "instances.set_tags.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetTags", + "fullName": "google.cloud.compute.v1.Instances.SetTags", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "tags_resource", + "type": ".google.cloud.compute.v1.Tags" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "SetTags", + "fullName": "google.cloud.compute.v1.Instances.SetTags", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_SimulateMaintenanceEvent_async", + "title": "AcceleratorTypes simulateMaintenanceEvent Sample", + "origin": "API_DEFINITION", + "description": " Simulates a host maintenance event on a VM. For more information, see Simulate a host maintenance event.", + "canonical": true, + "file": "instances.simulate_maintenance_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SimulateMaintenanceEvent", + "fullName": "google.cloud.compute.v1.Instances.SimulateMaintenanceEvent", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "SimulateMaintenanceEvent", + "fullName": "google.cloud.compute.v1.Instances.SimulateMaintenanceEvent", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_Start_async", + "title": "AcceleratorTypes start Sample", + "origin": "API_DEFINITION", + "description": " Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance.", + "canonical": true, + "file": "instances.start.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Start", + "fullName": "google.cloud.compute.v1.Instances.Start", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "Start", + "fullName": "google.cloud.compute.v1.Instances.Start", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_StartWithEncryptionKey_async", + "title": "AcceleratorTypes startWithEncryptionKey Sample", + "origin": "API_DEFINITION", + "description": " Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance.", + "canonical": true, + "file": "instances.start_with_encryption_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StartWithEncryptionKey", + "fullName": "google.cloud.compute.v1.Instances.StartWithEncryptionKey", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "instances_start_with_encryption_key_request_resource", + "type": ".google.cloud.compute.v1.InstancesStartWithEncryptionKeyRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "StartWithEncryptionKey", + "fullName": "google.cloud.compute.v1.Instances.StartWithEncryptionKey", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_Stop_async", + "title": "AcceleratorTypes stop Sample", + "origin": "API_DEFINITION", + "description": " Stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. Stopped instances do not incur VM usage charges while they are stopped. However, resources that the VM is using, such as persistent disks and static IP addresses, will continue to be charged until they are deleted. For more information, see Stopping an instance.", + "canonical": true, + "file": "instances.stop.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Stop", + "fullName": "google.cloud.compute.v1.Instances.Stop", + "async": true, + "parameters": [ + { + "name": "discard_local_ssd", + "type": "TYPE_BOOL" + }, + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "Stop", + "fullName": "google.cloud.compute.v1.Instances.Stop", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_Suspend_async", + "title": "AcceleratorTypes suspend Sample", + "origin": "API_DEFINITION", + "description": " This method suspends a running instance, saving its state to persistent storage, and allows you to resume the instance at a later time. Suspended instances have no compute costs (cores or RAM), and incur only storage charges for the saved VM memory and localSSD data. Any charged resources the virtual machine was using, such as persistent disks and static IP addresses, will continue to be charged while the instance is suspended. For more information, see Suspending and resuming an instance.", + "canonical": true, + "file": "instances.suspend.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Suspend", + "fullName": "google.cloud.compute.v1.Instances.Suspend", + "async": true, + "parameters": [ + { + "name": "discard_local_ssd", + "type": "TYPE_BOOL" + }, + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "Suspend", + "fullName": "google.cloud.compute.v1.Instances.Suspend", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "instances.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.Instances.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.Instances.TestIamPermissions", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_Update_async", + "title": "AcceleratorTypes update Sample", + "origin": "API_DEFINITION", + "description": " Updates an instance only if the necessary resources are available. This method can update only a specific set of instance properties. See Updating a running instance for a list of updatable instance properties.", + "canonical": true, + "file": "instances.update.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 46, + "end": 82, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.Instances.Update", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "instance_resource", + "type": ".google.cloud.compute.v1.Instance" + }, + { + "name": "minimal_action", + "type": "TYPE_STRING" + }, + { + "name": "most_disruptive_allowed_action", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.Instances.Update", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_UpdateAccessConfig_async", + "title": "AcceleratorTypes updateAccessConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified access config from an instance's network interface with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.", + "canonical": true, + "file": "instances.update_access_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateAccessConfig", + "fullName": "google.cloud.compute.v1.Instances.UpdateAccessConfig", + "async": true, + "parameters": [ + { + "name": "access_config_resource", + "type": ".google.cloud.compute.v1.AccessConfig" + }, + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "network_interface", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "UpdateAccessConfig", + "fullName": "google.cloud.compute.v1.Instances.UpdateAccessConfig", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_UpdateDisplayDevice_async", + "title": "AcceleratorTypes updateDisplayDevice Sample", + "origin": "API_DEFINITION", + "description": " Updates the Display config for a VM instance. You can only use this method on a stopped VM instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.", + "canonical": true, + "file": "instances.update_display_device.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateDisplayDevice", + "fullName": "google.cloud.compute.v1.Instances.UpdateDisplayDevice", + "async": true, + "parameters": [ + { + "name": "display_device_resource", + "type": ".google.cloud.compute.v1.DisplayDevice" + }, + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "UpdateDisplayDevice", + "fullName": "google.cloud.compute.v1.Instances.UpdateDisplayDevice", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_UpdateNetworkInterface_async", + "title": "AcceleratorTypes updateNetworkInterface Sample", + "origin": "API_DEFINITION", + "description": " Updates an instance's network interface. This method can only update an interface's alias IP range and attached network. See Modifying alias IP ranges for an existing instance for instructions on changing alias IP ranges. See Migrating a VM between networks for instructions on migrating an interface. This method follows PATCH semantics.", + "canonical": true, + "file": "instances.update_network_interface.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateNetworkInterface", + "fullName": "google.cloud.compute.v1.Instances.UpdateNetworkInterface", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "network_interface", + "type": "TYPE_STRING" + }, + { + "name": "network_interface_resource", + "type": ".google.cloud.compute.v1.NetworkInterface" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "UpdateNetworkInterface", + "fullName": "google.cloud.compute.v1.Instances.UpdateNetworkInterface", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Instances_UpdateShieldedInstanceConfig_async", + "title": "AcceleratorTypes updateShieldedInstanceConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the Shielded Instance config for an instance. You can only use this method on a stopped instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.", + "canonical": true, + "file": "instances.update_shielded_instance_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateShieldedInstanceConfig", + "fullName": "google.cloud.compute.v1.Instances.UpdateShieldedInstanceConfig", + "async": true, + "parameters": [ + { + "name": "instance", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "shielded_instance_config_resource", + "type": ".google.cloud.compute.v1.ShieldedInstanceConfig" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstancesClient", + "fullName": "google.cloud.compute.v1.InstancesClient" + }, + "method": { + "shortName": "UpdateShieldedInstanceConfig", + "fullName": "google.cloud.compute.v1.Instances.UpdateShieldedInstanceConfig", + "service": { + "shortName": "Instances", + "fullName": "google.cloud.compute.v1.Instances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceTemplates_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of all InstanceTemplates resources, regional and global, available to the specified project.", + "canonical": true, + "file": "instance_templates.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.InstanceTemplates.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceTemplateAggregatedList", + "client": { + "shortName": "InstanceTemplatesClient", + "fullName": "google.cloud.compute.v1.InstanceTemplatesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.InstanceTemplates.AggregatedList", + "service": { + "shortName": "InstanceTemplates", + "fullName": "google.cloud.compute.v1.InstanceTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceTemplates_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified instance template. Deleting an instance template is permanent and cannot be undone. It is not possible to delete templates that are already in use by a managed instance group.", + "canonical": true, + "file": "instance_templates.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.InstanceTemplates.Delete", + "async": true, + "parameters": [ + { + "name": "instance_template", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceTemplatesClient", + "fullName": "google.cloud.compute.v1.InstanceTemplatesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.InstanceTemplates.Delete", + "service": { + "shortName": "InstanceTemplates", + "fullName": "google.cloud.compute.v1.InstanceTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceTemplates_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified instance template.", + "canonical": true, + "file": "instance_templates.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.InstanceTemplates.Get", + "async": true, + "parameters": [ + { + "name": "instance_template", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceTemplate", + "client": { + "shortName": "InstanceTemplatesClient", + "fullName": "google.cloud.compute.v1.InstanceTemplatesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.InstanceTemplates.Get", + "service": { + "shortName": "InstanceTemplates", + "fullName": "google.cloud.compute.v1.InstanceTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceTemplates_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "instance_templates.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.InstanceTemplates.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "InstanceTemplatesClient", + "fullName": "google.cloud.compute.v1.InstanceTemplatesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.InstanceTemplates.GetIamPolicy", + "service": { + "shortName": "InstanceTemplates", + "fullName": "google.cloud.compute.v1.InstanceTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceTemplates_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates an instance template in the specified project using the data that is included in the request. If you are creating a new template to update an existing instance group, your new instance template must use the same network or, if applicable, the same subnetwork as the original template.", + "canonical": true, + "file": "instance_templates.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.InstanceTemplates.Insert", + "async": true, + "parameters": [ + { + "name": "instance_template_resource", + "type": ".google.cloud.compute.v1.InstanceTemplate" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InstanceTemplatesClient", + "fullName": "google.cloud.compute.v1.InstanceTemplatesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.InstanceTemplates.Insert", + "service": { + "shortName": "InstanceTemplates", + "fullName": "google.cloud.compute.v1.InstanceTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceTemplates_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of instance templates that are contained within the specified project.", + "canonical": true, + "file": "instance_templates.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.InstanceTemplates.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceTemplateList", + "client": { + "shortName": "InstanceTemplatesClient", + "fullName": "google.cloud.compute.v1.InstanceTemplatesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.InstanceTemplates.List", + "service": { + "shortName": "InstanceTemplates", + "fullName": "google.cloud.compute.v1.InstanceTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceTemplates_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "instance_templates.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.InstanceTemplates.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "global_set_policy_request_resource", + "type": ".google.cloud.compute.v1.GlobalSetPolicyRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "InstanceTemplatesClient", + "fullName": "google.cloud.compute.v1.InstanceTemplatesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.InstanceTemplates.SetIamPolicy", + "service": { + "shortName": "InstanceTemplates", + "fullName": "google.cloud.compute.v1.InstanceTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InstanceTemplates_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "instance_templates.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.InstanceTemplates.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "InstanceTemplatesClient", + "fullName": "google.cloud.compute.v1.InstanceTemplatesClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.InstanceTemplates.TestIamPermissions", + "service": { + "shortName": "InstanceTemplates", + "fullName": "google.cloud.compute.v1.InstanceTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InterconnectAttachments_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of interconnect attachments.", + "canonical": true, + "file": "interconnect_attachments.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.InterconnectAttachments.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.InterconnectAttachmentAggregatedList", + "client": { + "shortName": "InterconnectAttachmentsClient", + "fullName": "google.cloud.compute.v1.InterconnectAttachmentsClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.InterconnectAttachments.AggregatedList", + "service": { + "shortName": "InterconnectAttachments", + "fullName": "google.cloud.compute.v1.InterconnectAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InterconnectAttachments_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified interconnect attachment.", + "canonical": true, + "file": "interconnect_attachments.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.InterconnectAttachments.Delete", + "async": true, + "parameters": [ + { + "name": "interconnect_attachment", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InterconnectAttachmentsClient", + "fullName": "google.cloud.compute.v1.InterconnectAttachmentsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.InterconnectAttachments.Delete", + "service": { + "shortName": "InterconnectAttachments", + "fullName": "google.cloud.compute.v1.InterconnectAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InterconnectAttachments_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified interconnect attachment.", + "canonical": true, + "file": "interconnect_attachments.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.InterconnectAttachments.Get", + "async": true, + "parameters": [ + { + "name": "interconnect_attachment", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InterconnectAttachment", + "client": { + "shortName": "InterconnectAttachmentsClient", + "fullName": "google.cloud.compute.v1.InterconnectAttachmentsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.InterconnectAttachments.Get", + "service": { + "shortName": "InterconnectAttachments", + "fullName": "google.cloud.compute.v1.InterconnectAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InterconnectAttachments_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates an InterconnectAttachment in the specified project using the data included in the request.", + "canonical": true, + "file": "interconnect_attachments.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.InterconnectAttachments.Insert", + "async": true, + "parameters": [ + { + "name": "interconnect_attachment_resource", + "type": ".google.cloud.compute.v1.InterconnectAttachment" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InterconnectAttachmentsClient", + "fullName": "google.cloud.compute.v1.InterconnectAttachmentsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.InterconnectAttachments.Insert", + "service": { + "shortName": "InterconnectAttachments", + "fullName": "google.cloud.compute.v1.InterconnectAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InterconnectAttachments_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of interconnect attachments contained within the specified region.", + "canonical": true, + "file": "interconnect_attachments.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.InterconnectAttachments.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.InterconnectAttachmentList", + "client": { + "shortName": "InterconnectAttachmentsClient", + "fullName": "google.cloud.compute.v1.InterconnectAttachmentsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.InterconnectAttachments.List", + "service": { + "shortName": "InterconnectAttachments", + "fullName": "google.cloud.compute.v1.InterconnectAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InterconnectAttachments_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified interconnect attachment with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.", + "canonical": true, + "file": "interconnect_attachments.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.InterconnectAttachments.Patch", + "async": true, + "parameters": [ + { + "name": "interconnect_attachment", + "type": "TYPE_STRING" + }, + { + "name": "interconnect_attachment_resource", + "type": ".google.cloud.compute.v1.InterconnectAttachment" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InterconnectAttachmentsClient", + "fullName": "google.cloud.compute.v1.InterconnectAttachmentsClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.InterconnectAttachments.Patch", + "service": { + "shortName": "InterconnectAttachments", + "fullName": "google.cloud.compute.v1.InterconnectAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InterconnectAttachments_SetLabels_async", + "title": "AcceleratorTypes setLabels Sample", + "origin": "API_DEFINITION", + "description": " Sets the labels on an InterconnectAttachment. To learn more about labels, read the Labeling Resources documentation.", + "canonical": true, + "file": "interconnect_attachments.set_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.InterconnectAttachments.SetLabels", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_set_labels_request_resource", + "type": ".google.cloud.compute.v1.RegionSetLabelsRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InterconnectAttachmentsClient", + "fullName": "google.cloud.compute.v1.InterconnectAttachmentsClient" + }, + "method": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.InterconnectAttachments.SetLabels", + "service": { + "shortName": "InterconnectAttachments", + "fullName": "google.cloud.compute.v1.InterconnectAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InterconnectLocations_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the details for the specified interconnect location. Gets a list of available interconnect locations by making a list() request.", + "canonical": true, + "file": "interconnect_locations.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.InterconnectLocations.Get", + "async": true, + "parameters": [ + { + "name": "interconnect_location", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InterconnectLocation", + "client": { + "shortName": "InterconnectLocationsClient", + "fullName": "google.cloud.compute.v1.InterconnectLocationsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.InterconnectLocations.Get", + "service": { + "shortName": "InterconnectLocations", + "fullName": "google.cloud.compute.v1.InterconnectLocations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_InterconnectLocations_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of interconnect locations available to the specified project.", + "canonical": true, + "file": "interconnect_locations.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.InterconnectLocations.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.InterconnectLocationList", + "client": { + "shortName": "InterconnectLocationsClient", + "fullName": "google.cloud.compute.v1.InterconnectLocationsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.InterconnectLocations.List", + "service": { + "shortName": "InterconnectLocations", + "fullName": "google.cloud.compute.v1.InterconnectLocations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Interconnects_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified Interconnect.", + "canonical": true, + "file": "interconnects.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Interconnects.Delete", + "async": true, + "parameters": [ + { + "name": "interconnect", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InterconnectsClient", + "fullName": "google.cloud.compute.v1.InterconnectsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Interconnects.Delete", + "service": { + "shortName": "Interconnects", + "fullName": "google.cloud.compute.v1.Interconnects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Interconnects_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified Interconnect. Get a list of available Interconnects by making a list() request.", + "canonical": true, + "file": "interconnects.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Interconnects.Get", + "async": true, + "parameters": [ + { + "name": "interconnect", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Interconnect", + "client": { + "shortName": "InterconnectsClient", + "fullName": "google.cloud.compute.v1.InterconnectsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Interconnects.Get", + "service": { + "shortName": "Interconnects", + "fullName": "google.cloud.compute.v1.Interconnects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Interconnects_GetDiagnostics_async", + "title": "AcceleratorTypes getDiagnostics Sample", + "origin": "API_DEFINITION", + "description": " Returns the interconnectDiagnostics for the specified Interconnect.", + "canonical": true, + "file": "interconnects.get_diagnostics.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDiagnostics", + "fullName": "google.cloud.compute.v1.Interconnects.GetDiagnostics", + "async": true, + "parameters": [ + { + "name": "interconnect", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InterconnectsGetDiagnosticsResponse", + "client": { + "shortName": "InterconnectsClient", + "fullName": "google.cloud.compute.v1.InterconnectsClient" + }, + "method": { + "shortName": "GetDiagnostics", + "fullName": "google.cloud.compute.v1.Interconnects.GetDiagnostics", + "service": { + "shortName": "Interconnects", + "fullName": "google.cloud.compute.v1.Interconnects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Interconnects_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates an Interconnect in the specified project using the data included in the request.", + "canonical": true, + "file": "interconnects.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Interconnects.Insert", + "async": true, + "parameters": [ + { + "name": "interconnect_resource", + "type": ".google.cloud.compute.v1.Interconnect" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InterconnectsClient", + "fullName": "google.cloud.compute.v1.InterconnectsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Interconnects.Insert", + "service": { + "shortName": "Interconnects", + "fullName": "google.cloud.compute.v1.Interconnects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Interconnects_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of Interconnects available to the specified project.", + "canonical": true, + "file": "interconnects.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Interconnects.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.InterconnectList", + "client": { + "shortName": "InterconnectsClient", + "fullName": "google.cloud.compute.v1.InterconnectsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Interconnects.List", + "service": { + "shortName": "Interconnects", + "fullName": "google.cloud.compute.v1.Interconnects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Interconnects_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified Interconnect with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.", + "canonical": true, + "file": "interconnects.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.Interconnects.Patch", + "async": true, + "parameters": [ + { + "name": "interconnect", + "type": "TYPE_STRING" + }, + { + "name": "interconnect_resource", + "type": ".google.cloud.compute.v1.Interconnect" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InterconnectsClient", + "fullName": "google.cloud.compute.v1.InterconnectsClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.Interconnects.Patch", + "service": { + "shortName": "Interconnects", + "fullName": "google.cloud.compute.v1.Interconnects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Interconnects_SetLabels_async", + "title": "AcceleratorTypes setLabels Sample", + "origin": "API_DEFINITION", + "description": " Sets the labels on an Interconnect. To learn more about labels, read the Labeling Resources documentation.", + "canonical": true, + "file": "interconnects.set_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.Interconnects.SetLabels", + "async": true, + "parameters": [ + { + "name": "global_set_labels_request_resource", + "type": ".google.cloud.compute.v1.GlobalSetLabelsRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "InterconnectsClient", + "fullName": "google.cloud.compute.v1.InterconnectsClient" + }, + "method": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.Interconnects.SetLabels", + "service": { + "shortName": "Interconnects", + "fullName": "google.cloud.compute.v1.Interconnects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_LicenseCodes_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Return a specified license code. License codes are mirrored across all projects that have permissions to read the License Code. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. ", + "canonical": true, + "file": "license_codes.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.LicenseCodes.Get", + "async": true, + "parameters": [ + { + "name": "license_code", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.LicenseCode", + "client": { + "shortName": "LicenseCodesClient", + "fullName": "google.cloud.compute.v1.LicenseCodesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.LicenseCodes.Get", + "service": { + "shortName": "LicenseCodes", + "fullName": "google.cloud.compute.v1.LicenseCodes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_LicenseCodes_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. ", + "canonical": true, + "file": "license_codes.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.LicenseCodes.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "LicenseCodesClient", + "fullName": "google.cloud.compute.v1.LicenseCodesClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.LicenseCodes.TestIamPermissions", + "service": { + "shortName": "LicenseCodes", + "fullName": "google.cloud.compute.v1.LicenseCodes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Licenses_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified license. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. ", + "canonical": true, + "file": "licenses.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Licenses.Delete", + "async": true, + "parameters": [ + { + "name": "license", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "LicensesClient", + "fullName": "google.cloud.compute.v1.LicensesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Licenses.Delete", + "service": { + "shortName": "Licenses", + "fullName": "google.cloud.compute.v1.Licenses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Licenses_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified License resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. ", + "canonical": true, + "file": "licenses.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Licenses.Get", + "async": true, + "parameters": [ + { + "name": "license", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.License", + "client": { + "shortName": "LicensesClient", + "fullName": "google.cloud.compute.v1.LicensesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Licenses.Get", + "service": { + "shortName": "Licenses", + "fullName": "google.cloud.compute.v1.Licenses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Licenses_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. ", + "canonical": true, + "file": "licenses.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.Licenses.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "LicensesClient", + "fullName": "google.cloud.compute.v1.LicensesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.Licenses.GetIamPolicy", + "service": { + "shortName": "Licenses", + "fullName": "google.cloud.compute.v1.Licenses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Licenses_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Create a License resource in the specified project. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. ", + "canonical": true, + "file": "licenses.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Licenses.Insert", + "async": true, + "parameters": [ + { + "name": "license_resource", + "type": ".google.cloud.compute.v1.License" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "LicensesClient", + "fullName": "google.cloud.compute.v1.LicensesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Licenses.Insert", + "service": { + "shortName": "Licenses", + "fullName": "google.cloud.compute.v1.Licenses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Licenses_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of licenses available in the specified project. This method does not get any licenses that belong to other projects, including licenses attached to publicly-available images, like Debian 9. If you want to get a list of publicly-available licenses, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. ", + "canonical": true, + "file": "licenses.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Licenses.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.LicensesListResponse", + "client": { + "shortName": "LicensesClient", + "fullName": "google.cloud.compute.v1.LicensesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Licenses.List", + "service": { + "shortName": "Licenses", + "fullName": "google.cloud.compute.v1.Licenses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Licenses_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. ", + "canonical": true, + "file": "licenses.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.Licenses.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "global_set_policy_request_resource", + "type": ".google.cloud.compute.v1.GlobalSetPolicyRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "LicensesClient", + "fullName": "google.cloud.compute.v1.LicensesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.Licenses.SetIamPolicy", + "service": { + "shortName": "Licenses", + "fullName": "google.cloud.compute.v1.Licenses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Licenses_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. ", + "canonical": true, + "file": "licenses.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.Licenses.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "LicensesClient", + "fullName": "google.cloud.compute.v1.LicensesClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.Licenses.TestIamPermissions", + "service": { + "shortName": "Licenses", + "fullName": "google.cloud.compute.v1.Licenses" + } + } + } + }, + { + "regionTag": "compute_v1_generated_MachineImages_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified machine image. Deleting a machine image is permanent and cannot be undone.", + "canonical": true, + "file": "machine_images.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.MachineImages.Delete", + "async": true, + "parameters": [ + { + "name": "machine_image", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "MachineImagesClient", + "fullName": "google.cloud.compute.v1.MachineImagesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.MachineImages.Delete", + "service": { + "shortName": "MachineImages", + "fullName": "google.cloud.compute.v1.MachineImages" + } + } + } + }, + { + "regionTag": "compute_v1_generated_MachineImages_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified machine image.", + "canonical": true, + "file": "machine_images.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.MachineImages.Get", + "async": true, + "parameters": [ + { + "name": "machine_image", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.MachineImage", + "client": { + "shortName": "MachineImagesClient", + "fullName": "google.cloud.compute.v1.MachineImagesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.MachineImages.Get", + "service": { + "shortName": "MachineImages", + "fullName": "google.cloud.compute.v1.MachineImages" + } + } + } + }, + { + "regionTag": "compute_v1_generated_MachineImages_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "machine_images.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.MachineImages.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "MachineImagesClient", + "fullName": "google.cloud.compute.v1.MachineImagesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.MachineImages.GetIamPolicy", + "service": { + "shortName": "MachineImages", + "fullName": "google.cloud.compute.v1.MachineImages" + } + } + } + }, + { + "regionTag": "compute_v1_generated_MachineImages_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a machine image in the specified project using the data that is included in the request. If you are creating a new machine image to update an existing instance, your new machine image should use the same network or, if applicable, the same subnetwork as the original instance.", + "canonical": true, + "file": "machine_images.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.MachineImages.Insert", + "async": true, + "parameters": [ + { + "name": "machine_image_resource", + "type": ".google.cloud.compute.v1.MachineImage" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "source_instance", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "MachineImagesClient", + "fullName": "google.cloud.compute.v1.MachineImagesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.MachineImages.Insert", + "service": { + "shortName": "MachineImages", + "fullName": "google.cloud.compute.v1.MachineImages" + } + } + } + }, + { + "regionTag": "compute_v1_generated_MachineImages_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of machine images that are contained within the specified project.", + "canonical": true, + "file": "machine_images.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.MachineImages.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.MachineImageList", + "client": { + "shortName": "MachineImagesClient", + "fullName": "google.cloud.compute.v1.MachineImagesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.MachineImages.List", + "service": { + "shortName": "MachineImages", + "fullName": "google.cloud.compute.v1.MachineImages" + } + } + } + }, + { + "regionTag": "compute_v1_generated_MachineImages_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "machine_images.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.MachineImages.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "global_set_policy_request_resource", + "type": ".google.cloud.compute.v1.GlobalSetPolicyRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "MachineImagesClient", + "fullName": "google.cloud.compute.v1.MachineImagesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.MachineImages.SetIamPolicy", + "service": { + "shortName": "MachineImages", + "fullName": "google.cloud.compute.v1.MachineImages" + } + } + } + }, + { + "regionTag": "compute_v1_generated_MachineImages_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "machine_images.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.MachineImages.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "MachineImagesClient", + "fullName": "google.cloud.compute.v1.MachineImagesClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.MachineImages.TestIamPermissions", + "service": { + "shortName": "MachineImages", + "fullName": "google.cloud.compute.v1.MachineImages" + } + } + } + }, + { + "regionTag": "compute_v1_generated_MachineTypes_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of machine types.", + "canonical": true, + "file": "machine_types.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.MachineTypes.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.MachineTypeAggregatedList", + "client": { + "shortName": "MachineTypesClient", + "fullName": "google.cloud.compute.v1.MachineTypesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.MachineTypes.AggregatedList", + "service": { + "shortName": "MachineTypes", + "fullName": "google.cloud.compute.v1.MachineTypes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_MachineTypes_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified machine type.", + "canonical": true, + "file": "machine_types.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.MachineTypes.Get", + "async": true, + "parameters": [ + { + "name": "machine_type", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.MachineType", + "client": { + "shortName": "MachineTypesClient", + "fullName": "google.cloud.compute.v1.MachineTypesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.MachineTypes.Get", + "service": { + "shortName": "MachineTypes", + "fullName": "google.cloud.compute.v1.MachineTypes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_MachineTypes_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of machine types available to the specified project.", + "canonical": true, + "file": "machine_types.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.MachineTypes.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.MachineTypeList", + "client": { + "shortName": "MachineTypesClient", + "fullName": "google.cloud.compute.v1.MachineTypesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.MachineTypes.List", + "service": { + "shortName": "MachineTypes", + "fullName": "google.cloud.compute.v1.MachineTypes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkAttachments_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of all NetworkAttachment resources, regional and global, available to the specified project.", + "canonical": true, + "file": "network_attachments.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.NetworkAttachments.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.NetworkAttachmentAggregatedList", + "client": { + "shortName": "NetworkAttachmentsClient", + "fullName": "google.cloud.compute.v1.NetworkAttachmentsClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.NetworkAttachments.AggregatedList", + "service": { + "shortName": "NetworkAttachments", + "fullName": "google.cloud.compute.v1.NetworkAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkAttachments_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified NetworkAttachment in the given scope", + "canonical": true, + "file": "network_attachments.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.NetworkAttachments.Delete", + "async": true, + "parameters": [ + { + "name": "network_attachment", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkAttachmentsClient", + "fullName": "google.cloud.compute.v1.NetworkAttachmentsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.NetworkAttachments.Delete", + "service": { + "shortName": "NetworkAttachments", + "fullName": "google.cloud.compute.v1.NetworkAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkAttachments_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified NetworkAttachment resource in the given scope.", + "canonical": true, + "file": "network_attachments.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.NetworkAttachments.Get", + "async": true, + "parameters": [ + { + "name": "network_attachment", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.NetworkAttachment", + "client": { + "shortName": "NetworkAttachmentsClient", + "fullName": "google.cloud.compute.v1.NetworkAttachmentsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.NetworkAttachments.Get", + "service": { + "shortName": "NetworkAttachments", + "fullName": "google.cloud.compute.v1.NetworkAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkAttachments_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "network_attachments.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.NetworkAttachments.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "NetworkAttachmentsClient", + "fullName": "google.cloud.compute.v1.NetworkAttachmentsClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.NetworkAttachments.GetIamPolicy", + "service": { + "shortName": "NetworkAttachments", + "fullName": "google.cloud.compute.v1.NetworkAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkAttachments_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a NetworkAttachment in the specified project in the given scope using the parameters that are included in the request.", + "canonical": true, + "file": "network_attachments.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.NetworkAttachments.Insert", + "async": true, + "parameters": [ + { + "name": "network_attachment_resource", + "type": ".google.cloud.compute.v1.NetworkAttachment" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkAttachmentsClient", + "fullName": "google.cloud.compute.v1.NetworkAttachmentsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.NetworkAttachments.Insert", + "service": { + "shortName": "NetworkAttachments", + "fullName": "google.cloud.compute.v1.NetworkAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkAttachments_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Lists the NetworkAttachments for a project in the given scope.", + "canonical": true, + "file": "network_attachments.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.NetworkAttachments.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.NetworkAttachmentList", + "client": { + "shortName": "NetworkAttachmentsClient", + "fullName": "google.cloud.compute.v1.NetworkAttachmentsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.NetworkAttachments.List", + "service": { + "shortName": "NetworkAttachments", + "fullName": "google.cloud.compute.v1.NetworkAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkAttachments_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "network_attachments.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.NetworkAttachments.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_set_policy_request_resource", + "type": ".google.cloud.compute.v1.RegionSetPolicyRequest" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "NetworkAttachmentsClient", + "fullName": "google.cloud.compute.v1.NetworkAttachmentsClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.NetworkAttachments.SetIamPolicy", + "service": { + "shortName": "NetworkAttachments", + "fullName": "google.cloud.compute.v1.NetworkAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkAttachments_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "network_attachments.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.NetworkAttachments.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "NetworkAttachmentsClient", + "fullName": "google.cloud.compute.v1.NetworkAttachmentsClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.NetworkAttachments.TestIamPermissions", + "service": { + "shortName": "NetworkAttachments", + "fullName": "google.cloud.compute.v1.NetworkAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkEdgeSecurityServices_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of all NetworkEdgeSecurityService resources available to the specified project.", + "canonical": true, + "file": "network_edge_security_services.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServices.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.NetworkEdgeSecurityServiceAggregatedList", + "client": { + "shortName": "NetworkEdgeSecurityServicesClient", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServicesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServices.AggregatedList", + "service": { + "shortName": "NetworkEdgeSecurityServices", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkEdgeSecurityServices_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified service.", + "canonical": true, + "file": "network_edge_security_services.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServices.Delete", + "async": true, + "parameters": [ + { + "name": "network_edge_security_service", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkEdgeSecurityServicesClient", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServicesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServices.Delete", + "service": { + "shortName": "NetworkEdgeSecurityServices", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkEdgeSecurityServices_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Gets a specified NetworkEdgeSecurityService.", + "canonical": true, + "file": "network_edge_security_services.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServices.Get", + "async": true, + "parameters": [ + { + "name": "network_edge_security_service", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.NetworkEdgeSecurityService", + "client": { + "shortName": "NetworkEdgeSecurityServicesClient", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServicesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServices.Get", + "service": { + "shortName": "NetworkEdgeSecurityServices", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkEdgeSecurityServices_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a new service in the specified project using the data included in the request.", + "canonical": true, + "file": "network_edge_security_services.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServices.Insert", + "async": true, + "parameters": [ + { + "name": "network_edge_security_service_resource", + "type": ".google.cloud.compute.v1.NetworkEdgeSecurityService" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkEdgeSecurityServicesClient", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServicesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServices.Insert", + "service": { + "shortName": "NetworkEdgeSecurityServices", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkEdgeSecurityServices_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified policy with the data included in the request.", + "canonical": true, + "file": "network_edge_security_services.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServices.Patch", + "async": true, + "parameters": [ + { + "name": "network_edge_security_service", + "type": "TYPE_STRING" + }, + { + "name": "network_edge_security_service_resource", + "type": ".google.cloud.compute.v1.NetworkEdgeSecurityService" + }, + { + "name": "paths", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "update_mask", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkEdgeSecurityServicesClient", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServicesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServices.Patch", + "service": { + "shortName": "NetworkEdgeSecurityServices", + "fullName": "google.cloud.compute.v1.NetworkEdgeSecurityServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkEndpointGroups_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of network endpoint groups and sorts them by zone.", + "canonical": true, + "file": "network_endpoint_groups.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.NetworkEndpointGroupAggregatedList", + "client": { + "shortName": "NetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroupsClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.AggregatedList", + "service": { + "shortName": "NetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkEndpointGroups_AttachNetworkEndpoints_async", + "title": "AcceleratorTypes attachNetworkEndpoints Sample", + "origin": "API_DEFINITION", + "description": " Attach a list of network endpoints to the specified network endpoint group.", + "canonical": true, + "file": "network_endpoint_groups.attach_network_endpoints.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AttachNetworkEndpoints", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.AttachNetworkEndpoints", + "async": true, + "parameters": [ + { + "name": "network_endpoint_group", + "type": "TYPE_STRING" + }, + { + "name": "network_endpoint_groups_attach_endpoints_request_resource", + "type": ".google.cloud.compute.v1.NetworkEndpointGroupsAttachEndpointsRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroupsClient" + }, + "method": { + "shortName": "AttachNetworkEndpoints", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.AttachNetworkEndpoints", + "service": { + "shortName": "NetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkEndpointGroups_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified network endpoint group. The network endpoints in the NEG and the VM instances they belong to are not terminated when the NEG is deleted. Note that the NEG cannot be deleted if there are backend services referencing it.", + "canonical": true, + "file": "network_endpoint_groups.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.Delete", + "async": true, + "parameters": [ + { + "name": "network_endpoint_group", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroupsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.Delete", + "service": { + "shortName": "NetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkEndpointGroups_DetachNetworkEndpoints_async", + "title": "AcceleratorTypes detachNetworkEndpoints Sample", + "origin": "API_DEFINITION", + "description": " Detach a list of network endpoints from the specified network endpoint group.", + "canonical": true, + "file": "network_endpoint_groups.detach_network_endpoints.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DetachNetworkEndpoints", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.DetachNetworkEndpoints", + "async": true, + "parameters": [ + { + "name": "network_endpoint_group", + "type": "TYPE_STRING" + }, + { + "name": "network_endpoint_groups_detach_endpoints_request_resource", + "type": ".google.cloud.compute.v1.NetworkEndpointGroupsDetachEndpointsRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroupsClient" + }, + "method": { + "shortName": "DetachNetworkEndpoints", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.DetachNetworkEndpoints", + "service": { + "shortName": "NetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkEndpointGroups_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified network endpoint group.", + "canonical": true, + "file": "network_endpoint_groups.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.Get", + "async": true, + "parameters": [ + { + "name": "network_endpoint_group", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.NetworkEndpointGroup", + "client": { + "shortName": "NetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroupsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.Get", + "service": { + "shortName": "NetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkEndpointGroups_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a network endpoint group in the specified project using the parameters that are included in the request.", + "canonical": true, + "file": "network_endpoint_groups.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.Insert", + "async": true, + "parameters": [ + { + "name": "network_endpoint_group_resource", + "type": ".google.cloud.compute.v1.NetworkEndpointGroup" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroupsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.Insert", + "service": { + "shortName": "NetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkEndpointGroups_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of network endpoint groups that are located in the specified project and zone.", + "canonical": true, + "file": "network_endpoint_groups.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.NetworkEndpointGroupList", + "client": { + "shortName": "NetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroupsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.List", + "service": { + "shortName": "NetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkEndpointGroups_ListNetworkEndpoints_async", + "title": "AcceleratorTypes listNetworkEndpoints Sample", + "origin": "API_DEFINITION", + "description": " Lists the network endpoints in the specified network endpoint group.", + "canonical": true, + "file": "network_endpoint_groups.list_network_endpoints.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 90, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListNetworkEndpoints", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.ListNetworkEndpoints", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "network_endpoint_group", + "type": "TYPE_STRING" + }, + { + "name": "network_endpoint_groups_list_endpoints_request_resource", + "type": ".google.cloud.compute.v1.NetworkEndpointGroupsListEndpointsRequest" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.NetworkEndpointGroupsListNetworkEndpoints", + "client": { + "shortName": "NetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroupsClient" + }, + "method": { + "shortName": "ListNetworkEndpoints", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.ListNetworkEndpoints", + "service": { + "shortName": "NetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkEndpointGroups_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "network_endpoint_groups.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "NetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroupsClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups.TestIamPermissions", + "service": { + "shortName": "NetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.NetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_AddAssociation_async", + "title": "AcceleratorTypes addAssociation Sample", + "origin": "API_DEFINITION", + "description": " Inserts an association for the specified firewall policy.", + "canonical": true, + "file": "network_firewall_policies.add_association.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddAssociation", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.AddAssociation", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "firewall_policy_association_resource", + "type": ".google.cloud.compute.v1.FirewallPolicyAssociation" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "replace_existing_association", + "type": "TYPE_BOOL" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.NetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "AddAssociation", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.AddAssociation", + "service": { + "shortName": "NetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_AddRule_async", + "title": "AcceleratorTypes addRule Sample", + "origin": "API_DEFINITION", + "description": " Inserts a rule into a firewall policy.", + "canonical": true, + "file": "network_firewall_policies.add_rule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddRule", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.AddRule", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "firewall_policy_rule_resource", + "type": ".google.cloud.compute.v1.FirewallPolicyRule" + }, + { + "name": "max_priority", + "type": "TYPE_INT32" + }, + { + "name": "min_priority", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.NetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "AddRule", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.AddRule", + "service": { + "shortName": "NetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_CloneRules_async", + "title": "AcceleratorTypes cloneRules Sample", + "origin": "API_DEFINITION", + "description": " Copies rules to the specified firewall policy.", + "canonical": true, + "file": "network_firewall_policies.clone_rules.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CloneRules", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.CloneRules", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "source_firewall_policy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.NetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "CloneRules", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.CloneRules", + "service": { + "shortName": "NetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified policy.", + "canonical": true, + "file": "network_firewall_policies.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.Delete", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.NetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.Delete", + "service": { + "shortName": "NetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified network firewall policy.", + "canonical": true, + "file": "network_firewall_policies.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.Get", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.FirewallPolicy", + "client": { + "shortName": "NetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.NetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.Get", + "service": { + "shortName": "NetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_GetAssociation_async", + "title": "AcceleratorTypes getAssociation Sample", + "origin": "API_DEFINITION", + "description": " Gets an association with the specified name.", + "canonical": true, + "file": "network_firewall_policies.get_association.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAssociation", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.GetAssociation", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.FirewallPolicyAssociation", + "client": { + "shortName": "NetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.NetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "GetAssociation", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.GetAssociation", + "service": { + "shortName": "NetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "network_firewall_policies.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "NetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.NetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.GetIamPolicy", + "service": { + "shortName": "NetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_GetRule_async", + "title": "AcceleratorTypes getRule Sample", + "origin": "API_DEFINITION", + "description": " Gets a rule of the specified priority.", + "canonical": true, + "file": "network_firewall_policies.get_rule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetRule", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.GetRule", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "priority", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.FirewallPolicyRule", + "client": { + "shortName": "NetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.NetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "GetRule", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.GetRule", + "service": { + "shortName": "NetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a new policy in the specified project using the data included in the request.", + "canonical": true, + "file": "network_firewall_policies.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.Insert", + "async": true, + "parameters": [ + { + "name": "firewall_policy_resource", + "type": ".google.cloud.compute.v1.FirewallPolicy" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.NetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.Insert", + "service": { + "shortName": "NetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Lists all the policies that have been configured for the specified project.", + "canonical": true, + "file": "network_firewall_policies.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.FirewallPolicyList", + "client": { + "shortName": "NetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.NetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.List", + "service": { + "shortName": "NetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified policy with the data included in the request.", + "canonical": true, + "file": "network_firewall_policies.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.Patch", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "firewall_policy_resource", + "type": ".google.cloud.compute.v1.FirewallPolicy" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.NetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.Patch", + "service": { + "shortName": "NetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_PatchRule_async", + "title": "AcceleratorTypes patchRule Sample", + "origin": "API_DEFINITION", + "description": " Patches a rule of the specified priority.", + "canonical": true, + "file": "network_firewall_policies.patch_rule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PatchRule", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.PatchRule", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "firewall_policy_rule_resource", + "type": ".google.cloud.compute.v1.FirewallPolicyRule" + }, + { + "name": "priority", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.NetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "PatchRule", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.PatchRule", + "service": { + "shortName": "NetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_RemoveAssociation_async", + "title": "AcceleratorTypes removeAssociation Sample", + "origin": "API_DEFINITION", + "description": " Removes an association for the specified firewall policy.", + "canonical": true, + "file": "network_firewall_policies.remove_association.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveAssociation", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.RemoveAssociation", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.NetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "RemoveAssociation", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.RemoveAssociation", + "service": { + "shortName": "NetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_RemoveRule_async", + "title": "AcceleratorTypes removeRule Sample", + "origin": "API_DEFINITION", + "description": " Deletes a rule of the specified priority.", + "canonical": true, + "file": "network_firewall_policies.remove_rule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveRule", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.RemoveRule", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "priority", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.NetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "RemoveRule", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.RemoveRule", + "service": { + "shortName": "NetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "network_firewall_policies.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "global_set_policy_request_resource", + "type": ".google.cloud.compute.v1.GlobalSetPolicyRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "NetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.NetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.SetIamPolicy", + "service": { + "shortName": "NetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "network_firewall_policies.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "NetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.NetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.TestIamPermissions", + "service": { + "shortName": "NetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Networks_AddPeering_async", + "title": "AcceleratorTypes addPeering Sample", + "origin": "API_DEFINITION", + "description": " Adds a peering to the specified network.", + "canonical": true, + "file": "networks.add_peering.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddPeering", + "fullName": "google.cloud.compute.v1.Networks.AddPeering", + "async": true, + "parameters": [ + { + "name": "network", + "type": "TYPE_STRING" + }, + { + "name": "networks_add_peering_request_resource", + "type": ".google.cloud.compute.v1.NetworksAddPeeringRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworksClient", + "fullName": "google.cloud.compute.v1.NetworksClient" + }, + "method": { + "shortName": "AddPeering", + "fullName": "google.cloud.compute.v1.Networks.AddPeering", + "service": { + "shortName": "Networks", + "fullName": "google.cloud.compute.v1.Networks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Networks_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified network.", + "canonical": true, + "file": "networks.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Networks.Delete", + "async": true, + "parameters": [ + { + "name": "network", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworksClient", + "fullName": "google.cloud.compute.v1.NetworksClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Networks.Delete", + "service": { + "shortName": "Networks", + "fullName": "google.cloud.compute.v1.Networks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Networks_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified network.", + "canonical": true, + "file": "networks.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Networks.Get", + "async": true, + "parameters": [ + { + "name": "network", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Network", + "client": { + "shortName": "NetworksClient", + "fullName": "google.cloud.compute.v1.NetworksClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Networks.Get", + "service": { + "shortName": "Networks", + "fullName": "google.cloud.compute.v1.Networks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Networks_GetEffectiveFirewalls_async", + "title": "AcceleratorTypes getEffectiveFirewalls Sample", + "origin": "API_DEFINITION", + "description": " Returns the effective firewalls on a given network.", + "canonical": true, + "file": "networks.get_effective_firewalls.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetEffectiveFirewalls", + "fullName": "google.cloud.compute.v1.Networks.GetEffectiveFirewalls", + "async": true, + "parameters": [ + { + "name": "network", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.NetworksGetEffectiveFirewallsResponse", + "client": { + "shortName": "NetworksClient", + "fullName": "google.cloud.compute.v1.NetworksClient" + }, + "method": { + "shortName": "GetEffectiveFirewalls", + "fullName": "google.cloud.compute.v1.Networks.GetEffectiveFirewalls", + "service": { + "shortName": "Networks", + "fullName": "google.cloud.compute.v1.Networks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Networks_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a network in the specified project using the data included in the request.", + "canonical": true, + "file": "networks.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Networks.Insert", + "async": true, + "parameters": [ + { + "name": "network_resource", + "type": ".google.cloud.compute.v1.Network" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworksClient", + "fullName": "google.cloud.compute.v1.NetworksClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Networks.Insert", + "service": { + "shortName": "Networks", + "fullName": "google.cloud.compute.v1.Networks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Networks_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of networks available to the specified project.", + "canonical": true, + "file": "networks.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Networks.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.NetworkList", + "client": { + "shortName": "NetworksClient", + "fullName": "google.cloud.compute.v1.NetworksClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Networks.List", + "service": { + "shortName": "Networks", + "fullName": "google.cloud.compute.v1.Networks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Networks_ListPeeringRoutes_async", + "title": "AcceleratorTypes listPeeringRoutes Sample", + "origin": "API_DEFINITION", + "description": " Lists the peering routes exchanged over peering connection.", + "canonical": true, + "file": "networks.list_peering_routes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 93, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListPeeringRoutes", + "fullName": "google.cloud.compute.v1.Networks.ListPeeringRoutes", + "async": true, + "parameters": [ + { + "name": "direction", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "network", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "peering_name", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.ExchangedPeeringRoutesList", + "client": { + "shortName": "NetworksClient", + "fullName": "google.cloud.compute.v1.NetworksClient" + }, + "method": { + "shortName": "ListPeeringRoutes", + "fullName": "google.cloud.compute.v1.Networks.ListPeeringRoutes", + "service": { + "shortName": "Networks", + "fullName": "google.cloud.compute.v1.Networks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Networks_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified network with the data included in the request. Only the following fields can be modified: routingConfig.routingMode.", + "canonical": true, + "file": "networks.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.Networks.Patch", + "async": true, + "parameters": [ + { + "name": "network", + "type": "TYPE_STRING" + }, + { + "name": "network_resource", + "type": ".google.cloud.compute.v1.Network" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworksClient", + "fullName": "google.cloud.compute.v1.NetworksClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.Networks.Patch", + "service": { + "shortName": "Networks", + "fullName": "google.cloud.compute.v1.Networks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Networks_RemovePeering_async", + "title": "AcceleratorTypes removePeering Sample", + "origin": "API_DEFINITION", + "description": " Removes a peering from the specified network.", + "canonical": true, + "file": "networks.remove_peering.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemovePeering", + "fullName": "google.cloud.compute.v1.Networks.RemovePeering", + "async": true, + "parameters": [ + { + "name": "network", + "type": "TYPE_STRING" + }, + { + "name": "networks_remove_peering_request_resource", + "type": ".google.cloud.compute.v1.NetworksRemovePeeringRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworksClient", + "fullName": "google.cloud.compute.v1.NetworksClient" + }, + "method": { + "shortName": "RemovePeering", + "fullName": "google.cloud.compute.v1.Networks.RemovePeering", + "service": { + "shortName": "Networks", + "fullName": "google.cloud.compute.v1.Networks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Networks_SwitchToCustomMode_async", + "title": "AcceleratorTypes switchToCustomMode Sample", + "origin": "API_DEFINITION", + "description": " Switches the network mode from auto subnet mode to custom subnet mode.", + "canonical": true, + "file": "networks.switch_to_custom_mode.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SwitchToCustomMode", + "fullName": "google.cloud.compute.v1.Networks.SwitchToCustomMode", + "async": true, + "parameters": [ + { + "name": "network", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworksClient", + "fullName": "google.cloud.compute.v1.NetworksClient" + }, + "method": { + "shortName": "SwitchToCustomMode", + "fullName": "google.cloud.compute.v1.Networks.SwitchToCustomMode", + "service": { + "shortName": "Networks", + "fullName": "google.cloud.compute.v1.Networks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Networks_UpdatePeering_async", + "title": "AcceleratorTypes updatePeering Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified network peering with the data included in the request. You can only modify the NetworkPeering.export_custom_routes field and the NetworkPeering.import_custom_routes field.", + "canonical": true, + "file": "networks.update_peering.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdatePeering", + "fullName": "google.cloud.compute.v1.Networks.UpdatePeering", + "async": true, + "parameters": [ + { + "name": "network", + "type": "TYPE_STRING" + }, + { + "name": "networks_update_peering_request_resource", + "type": ".google.cloud.compute.v1.NetworksUpdatePeeringRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NetworksClient", + "fullName": "google.cloud.compute.v1.NetworksClient" + }, + "method": { + "shortName": "UpdatePeering", + "fullName": "google.cloud.compute.v1.Networks.UpdatePeering", + "service": { + "shortName": "Networks", + "fullName": "google.cloud.compute.v1.Networks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeGroups_AddNodes_async", + "title": "AcceleratorTypes addNodes Sample", + "origin": "API_DEFINITION", + "description": " Adds specified number of nodes to the node group.", + "canonical": true, + "file": "node_groups.add_nodes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddNodes", + "fullName": "google.cloud.compute.v1.NodeGroups.AddNodes", + "async": true, + "parameters": [ + { + "name": "node_group", + "type": "TYPE_STRING" + }, + { + "name": "node_groups_add_nodes_request_resource", + "type": ".google.cloud.compute.v1.NodeGroupsAddNodesRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NodeGroupsClient", + "fullName": "google.cloud.compute.v1.NodeGroupsClient" + }, + "method": { + "shortName": "AddNodes", + "fullName": "google.cloud.compute.v1.NodeGroups.AddNodes", + "service": { + "shortName": "NodeGroups", + "fullName": "google.cloud.compute.v1.NodeGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeGroups_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of node groups. Note: use nodeGroups.listNodes for more details about each group.", + "canonical": true, + "file": "node_groups.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.NodeGroups.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.NodeGroupAggregatedList", + "client": { + "shortName": "NodeGroupsClient", + "fullName": "google.cloud.compute.v1.NodeGroupsClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.NodeGroups.AggregatedList", + "service": { + "shortName": "NodeGroups", + "fullName": "google.cloud.compute.v1.NodeGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeGroups_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified NodeGroup resource.", + "canonical": true, + "file": "node_groups.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.NodeGroups.Delete", + "async": true, + "parameters": [ + { + "name": "node_group", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NodeGroupsClient", + "fullName": "google.cloud.compute.v1.NodeGroupsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.NodeGroups.Delete", + "service": { + "shortName": "NodeGroups", + "fullName": "google.cloud.compute.v1.NodeGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeGroups_DeleteNodes_async", + "title": "AcceleratorTypes deleteNodes Sample", + "origin": "API_DEFINITION", + "description": " Deletes specified nodes from the node group.", + "canonical": true, + "file": "node_groups.delete_nodes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteNodes", + "fullName": "google.cloud.compute.v1.NodeGroups.DeleteNodes", + "async": true, + "parameters": [ + { + "name": "node_group", + "type": "TYPE_STRING" + }, + { + "name": "node_groups_delete_nodes_request_resource", + "type": ".google.cloud.compute.v1.NodeGroupsDeleteNodesRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NodeGroupsClient", + "fullName": "google.cloud.compute.v1.NodeGroupsClient" + }, + "method": { + "shortName": "DeleteNodes", + "fullName": "google.cloud.compute.v1.NodeGroups.DeleteNodes", + "service": { + "shortName": "NodeGroups", + "fullName": "google.cloud.compute.v1.NodeGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeGroups_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified NodeGroup. Get a list of available NodeGroups by making a list() request. Note: the \"nodes\" field should not be used. Use nodeGroups.listNodes instead.", + "canonical": true, + "file": "node_groups.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.NodeGroups.Get", + "async": true, + "parameters": [ + { + "name": "node_group", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.NodeGroup", + "client": { + "shortName": "NodeGroupsClient", + "fullName": "google.cloud.compute.v1.NodeGroupsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.NodeGroups.Get", + "service": { + "shortName": "NodeGroups", + "fullName": "google.cloud.compute.v1.NodeGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeGroups_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "node_groups.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.NodeGroups.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "NodeGroupsClient", + "fullName": "google.cloud.compute.v1.NodeGroupsClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.NodeGroups.GetIamPolicy", + "service": { + "shortName": "NodeGroups", + "fullName": "google.cloud.compute.v1.NodeGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeGroups_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a NodeGroup resource in the specified project using the data included in the request.", + "canonical": true, + "file": "node_groups.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.NodeGroups.Insert", + "async": true, + "parameters": [ + { + "name": "initial_node_count", + "type": "TYPE_INT32" + }, + { + "name": "node_group_resource", + "type": ".google.cloud.compute.v1.NodeGroup" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NodeGroupsClient", + "fullName": "google.cloud.compute.v1.NodeGroupsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.NodeGroups.Insert", + "service": { + "shortName": "NodeGroups", + "fullName": "google.cloud.compute.v1.NodeGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeGroups_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of node groups available to the specified project. Note: use nodeGroups.listNodes for more details about each group.", + "canonical": true, + "file": "node_groups.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.NodeGroups.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.NodeGroupList", + "client": { + "shortName": "NodeGroupsClient", + "fullName": "google.cloud.compute.v1.NodeGroupsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.NodeGroups.List", + "service": { + "shortName": "NodeGroups", + "fullName": "google.cloud.compute.v1.NodeGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeGroups_ListNodes_async", + "title": "AcceleratorTypes listNodes Sample", + "origin": "API_DEFINITION", + "description": " Lists nodes in the node group.", + "canonical": true, + "file": "node_groups.list_nodes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListNodes", + "fullName": "google.cloud.compute.v1.NodeGroups.ListNodes", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "node_group", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.NodeGroupsListNodes", + "client": { + "shortName": "NodeGroupsClient", + "fullName": "google.cloud.compute.v1.NodeGroupsClient" + }, + "method": { + "shortName": "ListNodes", + "fullName": "google.cloud.compute.v1.NodeGroups.ListNodes", + "service": { + "shortName": "NodeGroups", + "fullName": "google.cloud.compute.v1.NodeGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeGroups_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified node group.", + "canonical": true, + "file": "node_groups.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.NodeGroups.Patch", + "async": true, + "parameters": [ + { + "name": "node_group", + "type": "TYPE_STRING" + }, + { + "name": "node_group_resource", + "type": ".google.cloud.compute.v1.NodeGroup" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NodeGroupsClient", + "fullName": "google.cloud.compute.v1.NodeGroupsClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.NodeGroups.Patch", + "service": { + "shortName": "NodeGroups", + "fullName": "google.cloud.compute.v1.NodeGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeGroups_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "node_groups.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.NodeGroups.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + }, + { + "name": "zone_set_policy_request_resource", + "type": ".google.cloud.compute.v1.ZoneSetPolicyRequest" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "NodeGroupsClient", + "fullName": "google.cloud.compute.v1.NodeGroupsClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.NodeGroups.SetIamPolicy", + "service": { + "shortName": "NodeGroups", + "fullName": "google.cloud.compute.v1.NodeGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeGroups_SetNodeTemplate_async", + "title": "AcceleratorTypes setNodeTemplate Sample", + "origin": "API_DEFINITION", + "description": " Updates the node template of the node group.", + "canonical": true, + "file": "node_groups.set_node_template.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetNodeTemplate", + "fullName": "google.cloud.compute.v1.NodeGroups.SetNodeTemplate", + "async": true, + "parameters": [ + { + "name": "node_group", + "type": "TYPE_STRING" + }, + { + "name": "node_groups_set_node_template_request_resource", + "type": ".google.cloud.compute.v1.NodeGroupsSetNodeTemplateRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NodeGroupsClient", + "fullName": "google.cloud.compute.v1.NodeGroupsClient" + }, + "method": { + "shortName": "SetNodeTemplate", + "fullName": "google.cloud.compute.v1.NodeGroups.SetNodeTemplate", + "service": { + "shortName": "NodeGroups", + "fullName": "google.cloud.compute.v1.NodeGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeGroups_SimulateMaintenanceEvent_async", + "title": "AcceleratorTypes simulateMaintenanceEvent Sample", + "origin": "API_DEFINITION", + "description": " Simulates maintenance event on specified nodes from the node group.", + "canonical": true, + "file": "node_groups.simulate_maintenance_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SimulateMaintenanceEvent", + "fullName": "google.cloud.compute.v1.NodeGroups.SimulateMaintenanceEvent", + "async": true, + "parameters": [ + { + "name": "node_group", + "type": "TYPE_STRING" + }, + { + "name": "node_groups_simulate_maintenance_event_request_resource", + "type": ".google.cloud.compute.v1.NodeGroupsSimulateMaintenanceEventRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NodeGroupsClient", + "fullName": "google.cloud.compute.v1.NodeGroupsClient" + }, + "method": { + "shortName": "SimulateMaintenanceEvent", + "fullName": "google.cloud.compute.v1.NodeGroups.SimulateMaintenanceEvent", + "service": { + "shortName": "NodeGroups", + "fullName": "google.cloud.compute.v1.NodeGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeGroups_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "node_groups.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.NodeGroups.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "NodeGroupsClient", + "fullName": "google.cloud.compute.v1.NodeGroupsClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.NodeGroups.TestIamPermissions", + "service": { + "shortName": "NodeGroups", + "fullName": "google.cloud.compute.v1.NodeGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeTemplates_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of node templates.", + "canonical": true, + "file": "node_templates.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.NodeTemplates.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.NodeTemplateAggregatedList", + "client": { + "shortName": "NodeTemplatesClient", + "fullName": "google.cloud.compute.v1.NodeTemplatesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.NodeTemplates.AggregatedList", + "service": { + "shortName": "NodeTemplates", + "fullName": "google.cloud.compute.v1.NodeTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeTemplates_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified NodeTemplate resource.", + "canonical": true, + "file": "node_templates.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.NodeTemplates.Delete", + "async": true, + "parameters": [ + { + "name": "node_template", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NodeTemplatesClient", + "fullName": "google.cloud.compute.v1.NodeTemplatesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.NodeTemplates.Delete", + "service": { + "shortName": "NodeTemplates", + "fullName": "google.cloud.compute.v1.NodeTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeTemplates_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified node template.", + "canonical": true, + "file": "node_templates.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.NodeTemplates.Get", + "async": true, + "parameters": [ + { + "name": "node_template", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.NodeTemplate", + "client": { + "shortName": "NodeTemplatesClient", + "fullName": "google.cloud.compute.v1.NodeTemplatesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.NodeTemplates.Get", + "service": { + "shortName": "NodeTemplates", + "fullName": "google.cloud.compute.v1.NodeTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeTemplates_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "node_templates.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.NodeTemplates.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "NodeTemplatesClient", + "fullName": "google.cloud.compute.v1.NodeTemplatesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.NodeTemplates.GetIamPolicy", + "service": { + "shortName": "NodeTemplates", + "fullName": "google.cloud.compute.v1.NodeTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeTemplates_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a NodeTemplate resource in the specified project using the data included in the request.", + "canonical": true, + "file": "node_templates.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.NodeTemplates.Insert", + "async": true, + "parameters": [ + { + "name": "node_template_resource", + "type": ".google.cloud.compute.v1.NodeTemplate" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "NodeTemplatesClient", + "fullName": "google.cloud.compute.v1.NodeTemplatesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.NodeTemplates.Insert", + "service": { + "shortName": "NodeTemplates", + "fullName": "google.cloud.compute.v1.NodeTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeTemplates_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of node templates available to the specified project.", + "canonical": true, + "file": "node_templates.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.NodeTemplates.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.NodeTemplateList", + "client": { + "shortName": "NodeTemplatesClient", + "fullName": "google.cloud.compute.v1.NodeTemplatesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.NodeTemplates.List", + "service": { + "shortName": "NodeTemplates", + "fullName": "google.cloud.compute.v1.NodeTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeTemplates_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "node_templates.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.NodeTemplates.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_set_policy_request_resource", + "type": ".google.cloud.compute.v1.RegionSetPolicyRequest" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "NodeTemplatesClient", + "fullName": "google.cloud.compute.v1.NodeTemplatesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.NodeTemplates.SetIamPolicy", + "service": { + "shortName": "NodeTemplates", + "fullName": "google.cloud.compute.v1.NodeTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeTemplates_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "node_templates.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.NodeTemplates.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "NodeTemplatesClient", + "fullName": "google.cloud.compute.v1.NodeTemplatesClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.NodeTemplates.TestIamPermissions", + "service": { + "shortName": "NodeTemplates", + "fullName": "google.cloud.compute.v1.NodeTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeTypes_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of node types.", + "canonical": true, + "file": "node_types.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.NodeTypes.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.NodeTypeAggregatedList", + "client": { + "shortName": "NodeTypesClient", + "fullName": "google.cloud.compute.v1.NodeTypesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.NodeTypes.AggregatedList", + "service": { + "shortName": "NodeTypes", + "fullName": "google.cloud.compute.v1.NodeTypes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeTypes_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified node type.", + "canonical": true, + "file": "node_types.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.NodeTypes.Get", + "async": true, + "parameters": [ + { + "name": "node_type", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.NodeType", + "client": { + "shortName": "NodeTypesClient", + "fullName": "google.cloud.compute.v1.NodeTypesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.NodeTypes.Get", + "service": { + "shortName": "NodeTypes", + "fullName": "google.cloud.compute.v1.NodeTypes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_NodeTypes_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of node types available to the specified project.", + "canonical": true, + "file": "node_types.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.NodeTypes.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.NodeTypeList", + "client": { + "shortName": "NodeTypesClient", + "fullName": "google.cloud.compute.v1.NodeTypesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.NodeTypes.List", + "service": { + "shortName": "NodeTypes", + "fullName": "google.cloud.compute.v1.NodeTypes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PacketMirrorings_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of packetMirrorings.", + "canonical": true, + "file": "packet_mirrorings.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.PacketMirrorings.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.PacketMirroringAggregatedList", + "client": { + "shortName": "PacketMirroringsClient", + "fullName": "google.cloud.compute.v1.PacketMirroringsClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.PacketMirrorings.AggregatedList", + "service": { + "shortName": "PacketMirrorings", + "fullName": "google.cloud.compute.v1.PacketMirrorings" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PacketMirrorings_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified PacketMirroring resource.", + "canonical": true, + "file": "packet_mirrorings.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.PacketMirrorings.Delete", + "async": true, + "parameters": [ + { + "name": "packet_mirroring", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "PacketMirroringsClient", + "fullName": "google.cloud.compute.v1.PacketMirroringsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.PacketMirrorings.Delete", + "service": { + "shortName": "PacketMirrorings", + "fullName": "google.cloud.compute.v1.PacketMirrorings" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PacketMirrorings_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified PacketMirroring resource.", + "canonical": true, + "file": "packet_mirrorings.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.PacketMirrorings.Get", + "async": true, + "parameters": [ + { + "name": "packet_mirroring", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.PacketMirroring", + "client": { + "shortName": "PacketMirroringsClient", + "fullName": "google.cloud.compute.v1.PacketMirroringsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.PacketMirrorings.Get", + "service": { + "shortName": "PacketMirrorings", + "fullName": "google.cloud.compute.v1.PacketMirrorings" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PacketMirrorings_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a PacketMirroring resource in the specified project and region using the data included in the request.", + "canonical": true, + "file": "packet_mirrorings.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.PacketMirrorings.Insert", + "async": true, + "parameters": [ + { + "name": "packet_mirroring_resource", + "type": ".google.cloud.compute.v1.PacketMirroring" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "PacketMirroringsClient", + "fullName": "google.cloud.compute.v1.PacketMirroringsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.PacketMirrorings.Insert", + "service": { + "shortName": "PacketMirrorings", + "fullName": "google.cloud.compute.v1.PacketMirrorings" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PacketMirrorings_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of PacketMirroring resources available to the specified project and region.", + "canonical": true, + "file": "packet_mirrorings.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.PacketMirrorings.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.PacketMirroringList", + "client": { + "shortName": "PacketMirroringsClient", + "fullName": "google.cloud.compute.v1.PacketMirroringsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.PacketMirrorings.List", + "service": { + "shortName": "PacketMirrorings", + "fullName": "google.cloud.compute.v1.PacketMirrorings" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PacketMirrorings_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified PacketMirroring resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.", + "canonical": true, + "file": "packet_mirrorings.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.PacketMirrorings.Patch", + "async": true, + "parameters": [ + { + "name": "packet_mirroring", + "type": "TYPE_STRING" + }, + { + "name": "packet_mirroring_resource", + "type": ".google.cloud.compute.v1.PacketMirroring" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "PacketMirroringsClient", + "fullName": "google.cloud.compute.v1.PacketMirroringsClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.PacketMirrorings.Patch", + "service": { + "shortName": "PacketMirrorings", + "fullName": "google.cloud.compute.v1.PacketMirrorings" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PacketMirrorings_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "packet_mirrorings.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.PacketMirrorings.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "PacketMirroringsClient", + "fullName": "google.cloud.compute.v1.PacketMirroringsClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.PacketMirrorings.TestIamPermissions", + "service": { + "shortName": "PacketMirrorings", + "fullName": "google.cloud.compute.v1.PacketMirrorings" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Projects_DisableXpnHost_async", + "title": "AcceleratorTypes disableXpnHost Sample", + "origin": "API_DEFINITION", + "description": " Disable this project as a shared VPC host project.", + "canonical": true, + "file": "projects.disable_xpn_host.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DisableXpnHost", + "fullName": "google.cloud.compute.v1.Projects.DisableXpnHost", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.compute.v1.ProjectsClient" + }, + "method": { + "shortName": "DisableXpnHost", + "fullName": "google.cloud.compute.v1.Projects.DisableXpnHost", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.compute.v1.Projects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Projects_DisableXpnResource_async", + "title": "AcceleratorTypes disableXpnResource Sample", + "origin": "API_DEFINITION", + "description": " Disable a service resource (also known as service project) associated with this host project.", + "canonical": true, + "file": "projects.disable_xpn_resource.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DisableXpnResource", + "fullName": "google.cloud.compute.v1.Projects.DisableXpnResource", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "projects_disable_xpn_resource_request_resource", + "type": ".google.cloud.compute.v1.ProjectsDisableXpnResourceRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.compute.v1.ProjectsClient" + }, + "method": { + "shortName": "DisableXpnResource", + "fullName": "google.cloud.compute.v1.Projects.DisableXpnResource", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.compute.v1.Projects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Projects_EnableXpnHost_async", + "title": "AcceleratorTypes enableXpnHost Sample", + "origin": "API_DEFINITION", + "description": " Enable this project as a shared VPC host project.", + "canonical": true, + "file": "projects.enable_xpn_host.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "EnableXpnHost", + "fullName": "google.cloud.compute.v1.Projects.EnableXpnHost", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.compute.v1.ProjectsClient" + }, + "method": { + "shortName": "EnableXpnHost", + "fullName": "google.cloud.compute.v1.Projects.EnableXpnHost", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.compute.v1.Projects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Projects_EnableXpnResource_async", + "title": "AcceleratorTypes enableXpnResource Sample", + "origin": "API_DEFINITION", + "description": " Enable service resource (a.k.a service project) for a host project, so that subnets in the host project can be used by instances in the service project.", + "canonical": true, + "file": "projects.enable_xpn_resource.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "EnableXpnResource", + "fullName": "google.cloud.compute.v1.Projects.EnableXpnResource", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "projects_enable_xpn_resource_request_resource", + "type": ".google.cloud.compute.v1.ProjectsEnableXpnResourceRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.compute.v1.ProjectsClient" + }, + "method": { + "shortName": "EnableXpnResource", + "fullName": "google.cloud.compute.v1.Projects.EnableXpnResource", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.compute.v1.Projects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Projects_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified Project resource. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request.", + "canonical": true, + "file": "projects.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Projects.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Project", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.compute.v1.ProjectsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Projects.Get", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.compute.v1.Projects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Projects_GetXpnHost_async", + "title": "AcceleratorTypes getXpnHost Sample", + "origin": "API_DEFINITION", + "description": " Gets the shared VPC host project that this project links to. May be empty if no link exists.", + "canonical": true, + "file": "projects.get_xpn_host.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetXpnHost", + "fullName": "google.cloud.compute.v1.Projects.GetXpnHost", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Project", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.compute.v1.ProjectsClient" + }, + "method": { + "shortName": "GetXpnHost", + "fullName": "google.cloud.compute.v1.Projects.GetXpnHost", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.compute.v1.Projects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Projects_GetXpnResources_async", + "title": "AcceleratorTypes getXpnResources Sample", + "origin": "API_DEFINITION", + "description": " Gets service resources (a.k.a service project) associated with this host project.", + "canonical": true, + "file": "projects.get_xpn_resources.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetXpnResources", + "fullName": "google.cloud.compute.v1.Projects.GetXpnResources", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.ProjectsGetXpnResources", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.compute.v1.ProjectsClient" + }, + "method": { + "shortName": "GetXpnResources", + "fullName": "google.cloud.compute.v1.Projects.GetXpnResources", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.compute.v1.Projects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Projects_ListXpnHosts_async", + "title": "AcceleratorTypes listXpnHosts Sample", + "origin": "API_DEFINITION", + "description": " Lists all shared VPC host projects visible to the user in an organization.", + "canonical": true, + "file": "projects.list_xpn_hosts.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListXpnHosts", + "fullName": "google.cloud.compute.v1.Projects.ListXpnHosts", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "projects_list_xpn_hosts_request_resource", + "type": ".google.cloud.compute.v1.ProjectsListXpnHostsRequest" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.XpnHostList", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.compute.v1.ProjectsClient" + }, + "method": { + "shortName": "ListXpnHosts", + "fullName": "google.cloud.compute.v1.Projects.ListXpnHosts", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.compute.v1.Projects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Projects_MoveDisk_async", + "title": "AcceleratorTypes moveDisk Sample", + "origin": "API_DEFINITION", + "description": " Moves a persistent disk from one zone to another.", + "canonical": true, + "file": "projects.move_disk.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MoveDisk", + "fullName": "google.cloud.compute.v1.Projects.MoveDisk", + "async": true, + "parameters": [ + { + "name": "disk_move_request_resource", + "type": ".google.cloud.compute.v1.DiskMoveRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.compute.v1.ProjectsClient" + }, + "method": { + "shortName": "MoveDisk", + "fullName": "google.cloud.compute.v1.Projects.MoveDisk", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.compute.v1.Projects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Projects_MoveInstance_async", + "title": "AcceleratorTypes moveInstance Sample", + "origin": "API_DEFINITION", + "description": " Moves an instance and its attached persistent disks from one zone to another. *Note*: Moving VMs or disks by using this method might cause unexpected behavior. For more information, see the [known issue](/compute/docs/troubleshooting/known-issues#moving_vms_or_disks_using_the_moveinstance_api_or_the_causes_unexpected_behavior).", + "canonical": true, + "file": "projects.move_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MoveInstance", + "fullName": "google.cloud.compute.v1.Projects.MoveInstance", + "async": true, + "parameters": [ + { + "name": "instance_move_request_resource", + "type": ".google.cloud.compute.v1.InstanceMoveRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.compute.v1.ProjectsClient" + }, + "method": { + "shortName": "MoveInstance", + "fullName": "google.cloud.compute.v1.Projects.MoveInstance", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.compute.v1.Projects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Projects_SetCommonInstanceMetadata_async", + "title": "AcceleratorTypes setCommonInstanceMetadata Sample", + "origin": "API_DEFINITION", + "description": " Sets metadata common to all instances within the specified project using the data included in the request.", + "canonical": true, + "file": "projects.set_common_instance_metadata.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetCommonInstanceMetadata", + "fullName": "google.cloud.compute.v1.Projects.SetCommonInstanceMetadata", + "async": true, + "parameters": [ + { + "name": "metadata_resource", + "type": ".google.cloud.compute.v1.Metadata" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.compute.v1.ProjectsClient" + }, + "method": { + "shortName": "SetCommonInstanceMetadata", + "fullName": "google.cloud.compute.v1.Projects.SetCommonInstanceMetadata", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.compute.v1.Projects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Projects_SetDefaultNetworkTier_async", + "title": "AcceleratorTypes setDefaultNetworkTier Sample", + "origin": "API_DEFINITION", + "description": " Sets the default network tier of the project. The default network tier is used when an address/forwardingRule/instance is created without specifying the network tier field.", + "canonical": true, + "file": "projects.set_default_network_tier.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetDefaultNetworkTier", + "fullName": "google.cloud.compute.v1.Projects.SetDefaultNetworkTier", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "projects_set_default_network_tier_request_resource", + "type": ".google.cloud.compute.v1.ProjectsSetDefaultNetworkTierRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.compute.v1.ProjectsClient" + }, + "method": { + "shortName": "SetDefaultNetworkTier", + "fullName": "google.cloud.compute.v1.Projects.SetDefaultNetworkTier", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.compute.v1.Projects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Projects_SetUsageExportBucket_async", + "title": "AcceleratorTypes setUsageExportBucket Sample", + "origin": "API_DEFINITION", + "description": " Enables the usage export feature and sets the usage export bucket where reports are stored. If you provide an empty request body using this method, the usage export feature will be disabled.", + "canonical": true, + "file": "projects.set_usage_export_bucket.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetUsageExportBucket", + "fullName": "google.cloud.compute.v1.Projects.SetUsageExportBucket", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "usage_export_location_resource", + "type": ".google.cloud.compute.v1.UsageExportLocation" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.compute.v1.ProjectsClient" + }, + "method": { + "shortName": "SetUsageExportBucket", + "fullName": "google.cloud.compute.v1.Projects.SetUsageExportBucket", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.compute.v1.Projects" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PublicAdvertisedPrefixes_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified PublicAdvertisedPrefix", + "canonical": true, + "file": "public_advertised_prefixes.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixes.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "public_advertised_prefix", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "PublicAdvertisedPrefixesClient", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixes.Delete", + "service": { + "shortName": "PublicAdvertisedPrefixes", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PublicAdvertisedPrefixes_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified PublicAdvertisedPrefix resource.", + "canonical": true, + "file": "public_advertised_prefixes.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixes.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "public_advertised_prefix", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.PublicAdvertisedPrefix", + "client": { + "shortName": "PublicAdvertisedPrefixesClient", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixes.Get", + "service": { + "shortName": "PublicAdvertisedPrefixes", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PublicAdvertisedPrefixes_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a PublicAdvertisedPrefix in the specified project using the parameters that are included in the request.", + "canonical": true, + "file": "public_advertised_prefixes.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixes.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "public_advertised_prefix_resource", + "type": ".google.cloud.compute.v1.PublicAdvertisedPrefix" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "PublicAdvertisedPrefixesClient", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixes.Insert", + "service": { + "shortName": "PublicAdvertisedPrefixes", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PublicAdvertisedPrefixes_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Lists the PublicAdvertisedPrefixes for a project.", + "canonical": true, + "file": "public_advertised_prefixes.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixes.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.PublicAdvertisedPrefixList", + "client": { + "shortName": "PublicAdvertisedPrefixesClient", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixes.List", + "service": { + "shortName": "PublicAdvertisedPrefixes", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PublicAdvertisedPrefixes_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified Router resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.", + "canonical": true, + "file": "public_advertised_prefixes.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixes.Patch", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "public_advertised_prefix", + "type": "TYPE_STRING" + }, + { + "name": "public_advertised_prefix_resource", + "type": ".google.cloud.compute.v1.PublicAdvertisedPrefix" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "PublicAdvertisedPrefixesClient", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixes.Patch", + "service": { + "shortName": "PublicAdvertisedPrefixes", + "fullName": "google.cloud.compute.v1.PublicAdvertisedPrefixes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PublicDelegatedPrefixes_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Lists all PublicDelegatedPrefix resources owned by the specific project across all scopes.", + "canonical": true, + "file": "public_delegated_prefixes.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.PublicDelegatedPrefixAggregatedList", + "client": { + "shortName": "PublicDelegatedPrefixesClient", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes.AggregatedList", + "service": { + "shortName": "PublicDelegatedPrefixes", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PublicDelegatedPrefixes_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified PublicDelegatedPrefix in the given region.", + "canonical": true, + "file": "public_delegated_prefixes.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "public_delegated_prefix", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "PublicDelegatedPrefixesClient", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes.Delete", + "service": { + "shortName": "PublicDelegatedPrefixes", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PublicDelegatedPrefixes_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified PublicDelegatedPrefix resource in the given region.", + "canonical": true, + "file": "public_delegated_prefixes.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "public_delegated_prefix", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.PublicDelegatedPrefix", + "client": { + "shortName": "PublicDelegatedPrefixesClient", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes.Get", + "service": { + "shortName": "PublicDelegatedPrefixes", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PublicDelegatedPrefixes_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a PublicDelegatedPrefix in the specified project in the given region using the parameters that are included in the request.", + "canonical": true, + "file": "public_delegated_prefixes.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "public_delegated_prefix_resource", + "type": ".google.cloud.compute.v1.PublicDelegatedPrefix" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "PublicDelegatedPrefixesClient", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes.Insert", + "service": { + "shortName": "PublicDelegatedPrefixes", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PublicDelegatedPrefixes_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Lists the PublicDelegatedPrefixes for a project in the given region.", + "canonical": true, + "file": "public_delegated_prefixes.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.PublicDelegatedPrefixList", + "client": { + "shortName": "PublicDelegatedPrefixesClient", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes.List", + "service": { + "shortName": "PublicDelegatedPrefixes", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_PublicDelegatedPrefixes_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified PublicDelegatedPrefix resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.", + "canonical": true, + "file": "public_delegated_prefixes.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes.Patch", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "public_delegated_prefix", + "type": "TYPE_STRING" + }, + { + "name": "public_delegated_prefix_resource", + "type": ".google.cloud.compute.v1.PublicDelegatedPrefix" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "PublicDelegatedPrefixesClient", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes.Patch", + "service": { + "shortName": "PublicDelegatedPrefixes", + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionAutoscalers_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified autoscaler.", + "canonical": true, + "file": "region_autoscalers.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionAutoscalers.Delete", + "async": true, + "parameters": [ + { + "name": "autoscaler", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionAutoscalersClient", + "fullName": "google.cloud.compute.v1.RegionAutoscalersClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionAutoscalers.Delete", + "service": { + "shortName": "RegionAutoscalers", + "fullName": "google.cloud.compute.v1.RegionAutoscalers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionAutoscalers_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified autoscaler.", + "canonical": true, + "file": "region_autoscalers.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionAutoscalers.Get", + "async": true, + "parameters": [ + { + "name": "autoscaler", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Autoscaler", + "client": { + "shortName": "RegionAutoscalersClient", + "fullName": "google.cloud.compute.v1.RegionAutoscalersClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionAutoscalers.Get", + "service": { + "shortName": "RegionAutoscalers", + "fullName": "google.cloud.compute.v1.RegionAutoscalers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionAutoscalers_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates an autoscaler in the specified project using the data included in the request.", + "canonical": true, + "file": "region_autoscalers.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionAutoscalers.Insert", + "async": true, + "parameters": [ + { + "name": "autoscaler_resource", + "type": ".google.cloud.compute.v1.Autoscaler" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionAutoscalersClient", + "fullName": "google.cloud.compute.v1.RegionAutoscalersClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionAutoscalers.Insert", + "service": { + "shortName": "RegionAutoscalers", + "fullName": "google.cloud.compute.v1.RegionAutoscalers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionAutoscalers_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of autoscalers contained within the specified region.", + "canonical": true, + "file": "region_autoscalers.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionAutoscalers.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.RegionAutoscalerList", + "client": { + "shortName": "RegionAutoscalersClient", + "fullName": "google.cloud.compute.v1.RegionAutoscalersClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionAutoscalers.List", + "service": { + "shortName": "RegionAutoscalers", + "fullName": "google.cloud.compute.v1.RegionAutoscalers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionAutoscalers_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Updates an autoscaler in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.", + "canonical": true, + "file": "region_autoscalers.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionAutoscalers.Patch", + "async": true, + "parameters": [ + { + "name": "autoscaler", + "type": "TYPE_STRING" + }, + { + "name": "autoscaler_resource", + "type": ".google.cloud.compute.v1.Autoscaler" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionAutoscalersClient", + "fullName": "google.cloud.compute.v1.RegionAutoscalersClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionAutoscalers.Patch", + "service": { + "shortName": "RegionAutoscalers", + "fullName": "google.cloud.compute.v1.RegionAutoscalers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionAutoscalers_Update_async", + "title": "AcceleratorTypes update Sample", + "origin": "API_DEFINITION", + "description": " Updates an autoscaler in the specified project using the data included in the request.", + "canonical": true, + "file": "region_autoscalers.update.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.RegionAutoscalers.Update", + "async": true, + "parameters": [ + { + "name": "autoscaler", + "type": "TYPE_STRING" + }, + { + "name": "autoscaler_resource", + "type": ".google.cloud.compute.v1.Autoscaler" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionAutoscalersClient", + "fullName": "google.cloud.compute.v1.RegionAutoscalersClient" + }, + "method": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.RegionAutoscalers.Update", + "service": { + "shortName": "RegionAutoscalers", + "fullName": "google.cloud.compute.v1.RegionAutoscalers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionBackendServices_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified regional BackendService resource.", + "canonical": true, + "file": "region_backend_services.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionBackendServices.Delete", + "async": true, + "parameters": [ + { + "name": "backend_service", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionBackendServicesClient", + "fullName": "google.cloud.compute.v1.RegionBackendServicesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionBackendServices.Delete", + "service": { + "shortName": "RegionBackendServices", + "fullName": "google.cloud.compute.v1.RegionBackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionBackendServices_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified regional BackendService resource.", + "canonical": true, + "file": "region_backend_services.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionBackendServices.Get", + "async": true, + "parameters": [ + { + "name": "backend_service", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.BackendService", + "client": { + "shortName": "RegionBackendServicesClient", + "fullName": "google.cloud.compute.v1.RegionBackendServicesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionBackendServices.Get", + "service": { + "shortName": "RegionBackendServices", + "fullName": "google.cloud.compute.v1.RegionBackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionBackendServices_GetHealth_async", + "title": "AcceleratorTypes getHealth Sample", + "origin": "API_DEFINITION", + "description": " Gets the most recent health check results for this regional BackendService.", + "canonical": true, + "file": "region_backend_services.get_health.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetHealth", + "fullName": "google.cloud.compute.v1.RegionBackendServices.GetHealth", + "async": true, + "parameters": [ + { + "name": "backend_service", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource_group_reference_resource", + "type": ".google.cloud.compute.v1.ResourceGroupReference" + } + ], + "resultType": ".google.cloud.compute.v1.BackendServiceGroupHealth", + "client": { + "shortName": "RegionBackendServicesClient", + "fullName": "google.cloud.compute.v1.RegionBackendServicesClient" + }, + "method": { + "shortName": "GetHealth", + "fullName": "google.cloud.compute.v1.RegionBackendServices.GetHealth", + "service": { + "shortName": "RegionBackendServices", + "fullName": "google.cloud.compute.v1.RegionBackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionBackendServices_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "region_backend_services.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.RegionBackendServices.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "RegionBackendServicesClient", + "fullName": "google.cloud.compute.v1.RegionBackendServicesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.RegionBackendServices.GetIamPolicy", + "service": { + "shortName": "RegionBackendServices", + "fullName": "google.cloud.compute.v1.RegionBackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionBackendServices_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a regional BackendService resource in the specified project using the data included in the request. For more information, see Backend services overview.", + "canonical": true, + "file": "region_backend_services.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionBackendServices.Insert", + "async": true, + "parameters": [ + { + "name": "backend_service_resource", + "type": ".google.cloud.compute.v1.BackendService" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionBackendServicesClient", + "fullName": "google.cloud.compute.v1.RegionBackendServicesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionBackendServices.Insert", + "service": { + "shortName": "RegionBackendServices", + "fullName": "google.cloud.compute.v1.RegionBackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionBackendServices_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of regional BackendService resources available to the specified project in the given region.", + "canonical": true, + "file": "region_backend_services.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionBackendServices.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.BackendServiceList", + "client": { + "shortName": "RegionBackendServicesClient", + "fullName": "google.cloud.compute.v1.RegionBackendServicesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionBackendServices.List", + "service": { + "shortName": "RegionBackendServices", + "fullName": "google.cloud.compute.v1.RegionBackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionBackendServices_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified regional BackendService resource with the data included in the request. For more information, see Understanding backend services This method supports PATCH semantics and uses the JSON merge patch format and processing rules.", + "canonical": true, + "file": "region_backend_services.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionBackendServices.Patch", + "async": true, + "parameters": [ + { + "name": "backend_service", + "type": "TYPE_STRING" + }, + { + "name": "backend_service_resource", + "type": ".google.cloud.compute.v1.BackendService" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionBackendServicesClient", + "fullName": "google.cloud.compute.v1.RegionBackendServicesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionBackendServices.Patch", + "service": { + "shortName": "RegionBackendServices", + "fullName": "google.cloud.compute.v1.RegionBackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionBackendServices_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "region_backend_services.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.RegionBackendServices.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_set_policy_request_resource", + "type": ".google.cloud.compute.v1.RegionSetPolicyRequest" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "RegionBackendServicesClient", + "fullName": "google.cloud.compute.v1.RegionBackendServicesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.RegionBackendServices.SetIamPolicy", + "service": { + "shortName": "RegionBackendServices", + "fullName": "google.cloud.compute.v1.RegionBackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionBackendServices_Update_async", + "title": "AcceleratorTypes update Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified regional BackendService resource with the data included in the request. For more information, see Backend services overview .", + "canonical": true, + "file": "region_backend_services.update.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.RegionBackendServices.Update", + "async": true, + "parameters": [ + { + "name": "backend_service", + "type": "TYPE_STRING" + }, + { + "name": "backend_service_resource", + "type": ".google.cloud.compute.v1.BackendService" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionBackendServicesClient", + "fullName": "google.cloud.compute.v1.RegionBackendServicesClient" + }, + "method": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.RegionBackendServices.Update", + "service": { + "shortName": "RegionBackendServices", + "fullName": "google.cloud.compute.v1.RegionBackendServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionCommitments_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of commitments by region.", + "canonical": true, + "file": "region_commitments.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.RegionCommitments.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.CommitmentAggregatedList", + "client": { + "shortName": "RegionCommitmentsClient", + "fullName": "google.cloud.compute.v1.RegionCommitmentsClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.RegionCommitments.AggregatedList", + "service": { + "shortName": "RegionCommitments", + "fullName": "google.cloud.compute.v1.RegionCommitments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionCommitments_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified commitment resource.", + "canonical": true, + "file": "region_commitments.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionCommitments.Get", + "async": true, + "parameters": [ + { + "name": "commitment", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Commitment", + "client": { + "shortName": "RegionCommitmentsClient", + "fullName": "google.cloud.compute.v1.RegionCommitmentsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionCommitments.Get", + "service": { + "shortName": "RegionCommitments", + "fullName": "google.cloud.compute.v1.RegionCommitments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionCommitments_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a commitment in the specified project using the data included in the request.", + "canonical": true, + "file": "region_commitments.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionCommitments.Insert", + "async": true, + "parameters": [ + { + "name": "commitment_resource", + "type": ".google.cloud.compute.v1.Commitment" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionCommitmentsClient", + "fullName": "google.cloud.compute.v1.RegionCommitmentsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionCommitments.Insert", + "service": { + "shortName": "RegionCommitments", + "fullName": "google.cloud.compute.v1.RegionCommitments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionCommitments_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of commitments contained within the specified region.", + "canonical": true, + "file": "region_commitments.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionCommitments.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.CommitmentList", + "client": { + "shortName": "RegionCommitmentsClient", + "fullName": "google.cloud.compute.v1.RegionCommitmentsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionCommitments.List", + "service": { + "shortName": "RegionCommitments", + "fullName": "google.cloud.compute.v1.RegionCommitments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionCommitments_Update_async", + "title": "AcceleratorTypes update Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified commitment with the data included in the request. Update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: auto_renew.", + "canonical": true, + "file": "region_commitments.update.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.RegionCommitments.Update", + "async": true, + "parameters": [ + { + "name": "commitment", + "type": "TYPE_STRING" + }, + { + "name": "commitment_resource", + "type": ".google.cloud.compute.v1.Commitment" + }, + { + "name": "paths", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "update_mask", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionCommitmentsClient", + "fullName": "google.cloud.compute.v1.RegionCommitmentsClient" + }, + "method": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.RegionCommitments.Update", + "service": { + "shortName": "RegionCommitments", + "fullName": "google.cloud.compute.v1.RegionCommitments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionDisks_AddResourcePolicies_async", + "title": "AcceleratorTypes addResourcePolicies Sample", + "origin": "API_DEFINITION", + "description": " Adds existing resource policies to a regional disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation.", + "canonical": true, + "file": "region_disks.add_resource_policies.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddResourcePolicies", + "fullName": "google.cloud.compute.v1.RegionDisks.AddResourcePolicies", + "async": true, + "parameters": [ + { + "name": "disk", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_disks_add_resource_policies_request_resource", + "type": ".google.cloud.compute.v1.RegionDisksAddResourcePoliciesRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionDisksClient", + "fullName": "google.cloud.compute.v1.RegionDisksClient" + }, + "method": { + "shortName": "AddResourcePolicies", + "fullName": "google.cloud.compute.v1.RegionDisks.AddResourcePolicies", + "service": { + "shortName": "RegionDisks", + "fullName": "google.cloud.compute.v1.RegionDisks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionDisks_CreateSnapshot_async", + "title": "AcceleratorTypes createSnapshot Sample", + "origin": "API_DEFINITION", + "description": " Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project.", + "canonical": true, + "file": "region_disks.create_snapshot.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateSnapshot", + "fullName": "google.cloud.compute.v1.RegionDisks.CreateSnapshot", + "async": true, + "parameters": [ + { + "name": "disk", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "snapshot_resource", + "type": ".google.cloud.compute.v1.Snapshot" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionDisksClient", + "fullName": "google.cloud.compute.v1.RegionDisksClient" + }, + "method": { + "shortName": "CreateSnapshot", + "fullName": "google.cloud.compute.v1.RegionDisks.CreateSnapshot", + "service": { + "shortName": "RegionDisks", + "fullName": "google.cloud.compute.v1.RegionDisks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionDisks_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified regional persistent disk. Deleting a regional disk removes all the replicas of its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots.", + "canonical": true, + "file": "region_disks.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionDisks.Delete", + "async": true, + "parameters": [ + { + "name": "disk", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionDisksClient", + "fullName": "google.cloud.compute.v1.RegionDisksClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionDisks.Delete", + "service": { + "shortName": "RegionDisks", + "fullName": "google.cloud.compute.v1.RegionDisks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionDisks_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns a specified regional persistent disk.", + "canonical": true, + "file": "region_disks.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionDisks.Get", + "async": true, + "parameters": [ + { + "name": "disk", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Disk", + "client": { + "shortName": "RegionDisksClient", + "fullName": "google.cloud.compute.v1.RegionDisksClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionDisks.Get", + "service": { + "shortName": "RegionDisks", + "fullName": "google.cloud.compute.v1.RegionDisks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionDisks_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "region_disks.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.RegionDisks.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "RegionDisksClient", + "fullName": "google.cloud.compute.v1.RegionDisksClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.RegionDisks.GetIamPolicy", + "service": { + "shortName": "RegionDisks", + "fullName": "google.cloud.compute.v1.RegionDisks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionDisks_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a persistent regional disk in the specified project using the data included in the request.", + "canonical": true, + "file": "region_disks.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionDisks.Insert", + "async": true, + "parameters": [ + { + "name": "disk_resource", + "type": ".google.cloud.compute.v1.Disk" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "source_image", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionDisksClient", + "fullName": "google.cloud.compute.v1.RegionDisksClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionDisks.Insert", + "service": { + "shortName": "RegionDisks", + "fullName": "google.cloud.compute.v1.RegionDisks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionDisks_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of persistent disks contained within the specified region.", + "canonical": true, + "file": "region_disks.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionDisks.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.DiskList", + "client": { + "shortName": "RegionDisksClient", + "fullName": "google.cloud.compute.v1.RegionDisksClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionDisks.List", + "service": { + "shortName": "RegionDisks", + "fullName": "google.cloud.compute.v1.RegionDisks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionDisks_RemoveResourcePolicies_async", + "title": "AcceleratorTypes removeResourcePolicies Sample", + "origin": "API_DEFINITION", + "description": " Removes resource policies from a regional disk.", + "canonical": true, + "file": "region_disks.remove_resource_policies.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveResourcePolicies", + "fullName": "google.cloud.compute.v1.RegionDisks.RemoveResourcePolicies", + "async": true, + "parameters": [ + { + "name": "disk", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_disks_remove_resource_policies_request_resource", + "type": ".google.cloud.compute.v1.RegionDisksRemoveResourcePoliciesRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionDisksClient", + "fullName": "google.cloud.compute.v1.RegionDisksClient" + }, + "method": { + "shortName": "RemoveResourcePolicies", + "fullName": "google.cloud.compute.v1.RegionDisks.RemoveResourcePolicies", + "service": { + "shortName": "RegionDisks", + "fullName": "google.cloud.compute.v1.RegionDisks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionDisks_Resize_async", + "title": "AcceleratorTypes resize Sample", + "origin": "API_DEFINITION", + "description": " Resizes the specified regional persistent disk.", + "canonical": true, + "file": "region_disks.resize.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Resize", + "fullName": "google.cloud.compute.v1.RegionDisks.Resize", + "async": true, + "parameters": [ + { + "name": "disk", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_disks_resize_request_resource", + "type": ".google.cloud.compute.v1.RegionDisksResizeRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionDisksClient", + "fullName": "google.cloud.compute.v1.RegionDisksClient" + }, + "method": { + "shortName": "Resize", + "fullName": "google.cloud.compute.v1.RegionDisks.Resize", + "service": { + "shortName": "RegionDisks", + "fullName": "google.cloud.compute.v1.RegionDisks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionDisks_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "region_disks.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.RegionDisks.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_set_policy_request_resource", + "type": ".google.cloud.compute.v1.RegionSetPolicyRequest" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "RegionDisksClient", + "fullName": "google.cloud.compute.v1.RegionDisksClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.RegionDisks.SetIamPolicy", + "service": { + "shortName": "RegionDisks", + "fullName": "google.cloud.compute.v1.RegionDisks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionDisks_SetLabels_async", + "title": "AcceleratorTypes setLabels Sample", + "origin": "API_DEFINITION", + "description": " Sets the labels on the target regional disk.", + "canonical": true, + "file": "region_disks.set_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.RegionDisks.SetLabels", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_set_labels_request_resource", + "type": ".google.cloud.compute.v1.RegionSetLabelsRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionDisksClient", + "fullName": "google.cloud.compute.v1.RegionDisksClient" + }, + "method": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.RegionDisks.SetLabels", + "service": { + "shortName": "RegionDisks", + "fullName": "google.cloud.compute.v1.RegionDisks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionDisks_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "region_disks.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.RegionDisks.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "RegionDisksClient", + "fullName": "google.cloud.compute.v1.RegionDisksClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.RegionDisks.TestIamPermissions", + "service": { + "shortName": "RegionDisks", + "fullName": "google.cloud.compute.v1.RegionDisks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionDisks_Update_async", + "title": "AcceleratorTypes update Sample", + "origin": "API_DEFINITION", + "description": " Update the specified disk with the data included in the request. Update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: user_license.", + "canonical": true, + "file": "region_disks.update.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.RegionDisks.Update", + "async": true, + "parameters": [ + { + "name": "disk", + "type": "TYPE_STRING" + }, + { + "name": "disk_resource", + "type": ".google.cloud.compute.v1.Disk" + }, + { + "name": "paths", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "update_mask", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionDisksClient", + "fullName": "google.cloud.compute.v1.RegionDisksClient" + }, + "method": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.RegionDisks.Update", + "service": { + "shortName": "RegionDisks", + "fullName": "google.cloud.compute.v1.RegionDisks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionDiskTypes_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified regional disk type.", + "canonical": true, + "file": "region_disk_types.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionDiskTypes.Get", + "async": true, + "parameters": [ + { + "name": "disk_type", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.DiskType", + "client": { + "shortName": "RegionDiskTypesClient", + "fullName": "google.cloud.compute.v1.RegionDiskTypesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionDiskTypes.Get", + "service": { + "shortName": "RegionDiskTypes", + "fullName": "google.cloud.compute.v1.RegionDiskTypes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionDiskTypes_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of regional disk types available to the specified project.", + "canonical": true, + "file": "region_disk_types.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionDiskTypes.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.RegionDiskTypeList", + "client": { + "shortName": "RegionDiskTypesClient", + "fullName": "google.cloud.compute.v1.RegionDiskTypesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionDiskTypes.List", + "service": { + "shortName": "RegionDiskTypes", + "fullName": "google.cloud.compute.v1.RegionDiskTypes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionHealthChecks_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified HealthCheck resource.", + "canonical": true, + "file": "region_health_checks.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.Delete", + "async": true, + "parameters": [ + { + "name": "health_check", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionHealthChecksClient", + "fullName": "google.cloud.compute.v1.RegionHealthChecksClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.Delete", + "service": { + "shortName": "RegionHealthChecks", + "fullName": "google.cloud.compute.v1.RegionHealthChecks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionHealthChecks_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified HealthCheck resource.", + "canonical": true, + "file": "region_health_checks.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.Get", + "async": true, + "parameters": [ + { + "name": "health_check", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.HealthCheck", + "client": { + "shortName": "RegionHealthChecksClient", + "fullName": "google.cloud.compute.v1.RegionHealthChecksClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.Get", + "service": { + "shortName": "RegionHealthChecks", + "fullName": "google.cloud.compute.v1.RegionHealthChecks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionHealthChecks_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a HealthCheck resource in the specified project using the data included in the request.", + "canonical": true, + "file": "region_health_checks.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.Insert", + "async": true, + "parameters": [ + { + "name": "health_check_resource", + "type": ".google.cloud.compute.v1.HealthCheck" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionHealthChecksClient", + "fullName": "google.cloud.compute.v1.RegionHealthChecksClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.Insert", + "service": { + "shortName": "RegionHealthChecks", + "fullName": "google.cloud.compute.v1.RegionHealthChecks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionHealthChecks_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of HealthCheck resources available to the specified project.", + "canonical": true, + "file": "region_health_checks.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.HealthCheckList", + "client": { + "shortName": "RegionHealthChecksClient", + "fullName": "google.cloud.compute.v1.RegionHealthChecksClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.List", + "service": { + "shortName": "RegionHealthChecks", + "fullName": "google.cloud.compute.v1.RegionHealthChecks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionHealthChecks_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Updates a HealthCheck resource in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.", + "canonical": true, + "file": "region_health_checks.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.Patch", + "async": true, + "parameters": [ + { + "name": "health_check", + "type": "TYPE_STRING" + }, + { + "name": "health_check_resource", + "type": ".google.cloud.compute.v1.HealthCheck" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionHealthChecksClient", + "fullName": "google.cloud.compute.v1.RegionHealthChecksClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.Patch", + "service": { + "shortName": "RegionHealthChecks", + "fullName": "google.cloud.compute.v1.RegionHealthChecks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionHealthChecks_Update_async", + "title": "AcceleratorTypes update Sample", + "origin": "API_DEFINITION", + "description": " Updates a HealthCheck resource in the specified project using the data included in the request.", + "canonical": true, + "file": "region_health_checks.update.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.Update", + "async": true, + "parameters": [ + { + "name": "health_check", + "type": "TYPE_STRING" + }, + { + "name": "health_check_resource", + "type": ".google.cloud.compute.v1.HealthCheck" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionHealthChecksClient", + "fullName": "google.cloud.compute.v1.RegionHealthChecksClient" + }, + "method": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.Update", + "service": { + "shortName": "RegionHealthChecks", + "fullName": "google.cloud.compute.v1.RegionHealthChecks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionHealthCheckServices_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified regional HealthCheckService.", + "canonical": true, + "file": "region_health_check_services.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.Delete", + "async": true, + "parameters": [ + { + "name": "health_check_service", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionHealthCheckServicesClient", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServicesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.Delete", + "service": { + "shortName": "RegionHealthCheckServices", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionHealthCheckServices_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified regional HealthCheckService resource.", + "canonical": true, + "file": "region_health_check_services.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.Get", + "async": true, + "parameters": [ + { + "name": "health_check_service", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.HealthCheckService", + "client": { + "shortName": "RegionHealthCheckServicesClient", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServicesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.Get", + "service": { + "shortName": "RegionHealthCheckServices", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionHealthCheckServices_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a regional HealthCheckService resource in the specified project and region using the data included in the request.", + "canonical": true, + "file": "region_health_check_services.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.Insert", + "async": true, + "parameters": [ + { + "name": "health_check_service_resource", + "type": ".google.cloud.compute.v1.HealthCheckService" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionHealthCheckServicesClient", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServicesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.Insert", + "service": { + "shortName": "RegionHealthCheckServices", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionHealthCheckServices_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Lists all the HealthCheckService resources that have been configured for the specified project in the given region.", + "canonical": true, + "file": "region_health_check_services.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.HealthCheckServicesList", + "client": { + "shortName": "RegionHealthCheckServicesClient", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServicesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.List", + "service": { + "shortName": "RegionHealthCheckServices", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionHealthCheckServices_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified regional HealthCheckService resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.", + "canonical": true, + "file": "region_health_check_services.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.Patch", + "async": true, + "parameters": [ + { + "name": "health_check_service", + "type": "TYPE_STRING" + }, + { + "name": "health_check_service_resource", + "type": ".google.cloud.compute.v1.HealthCheckService" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionHealthCheckServicesClient", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServicesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.Patch", + "service": { + "shortName": "RegionHealthCheckServices", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_AbandonInstances_async", + "title": "AcceleratorTypes abandonInstances Sample", + "origin": "API_DEFINITION", + "description": " Flags the specified instances to be immediately removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.", + "canonical": true, + "file": "region_instance_group_managers.abandon_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AbandonInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.AbandonInstances", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_instance_group_managers_abandon_instances_request_resource", + "type": ".google.cloud.compute.v1.RegionInstanceGroupManagersAbandonInstancesRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "AbandonInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.AbandonInstances", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_ApplyUpdatesToInstances_async", + "title": "AcceleratorTypes applyUpdatesToInstances Sample", + "origin": "API_DEFINITION", + "description": " Apply updates to selected instances the managed instance group.", + "canonical": true, + "file": "region_instance_group_managers.apply_updates_to_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ApplyUpdatesToInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ApplyUpdatesToInstances", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_instance_group_managers_apply_updates_request_resource", + "type": ".google.cloud.compute.v1.RegionInstanceGroupManagersApplyUpdatesRequest" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "ApplyUpdatesToInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ApplyUpdatesToInstances", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_CreateInstances_async", + "title": "AcceleratorTypes createInstances Sample", + "origin": "API_DEFINITION", + "description": " Creates instances with per-instance configurations in this regional managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method.", + "canonical": true, + "file": "region_instance_group_managers.create_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.CreateInstances", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_instance_group_managers_create_instances_request_resource", + "type": ".google.cloud.compute.v1.RegionInstanceGroupManagersCreateInstancesRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "CreateInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.CreateInstances", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified managed instance group and all of the instances in that group.", + "canonical": true, + "file": "region_instance_group_managers.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Delete", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Delete", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_DeleteInstances_async", + "title": "AcceleratorTypes deleteInstances Sample", + "origin": "API_DEFINITION", + "description": " Flags the specified instances in the managed instance group to be immediately deleted. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. The deleteInstances operation is marked DONE if the deleteInstances request is successful. The underlying actions take additional time. You must separately verify the status of the deleting action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.", + "canonical": true, + "file": "region_instance_group_managers.delete_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.DeleteInstances", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_instance_group_managers_delete_instances_request_resource", + "type": ".google.cloud.compute.v1.RegionInstanceGroupManagersDeleteInstancesRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "DeleteInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.DeleteInstances", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_DeletePerInstanceConfigs_async", + "title": "AcceleratorTypes deletePerInstanceConfigs Sample", + "origin": "API_DEFINITION", + "description": " Deletes selected per-instance configurations for the managed instance group.", + "canonical": true, + "file": "region_instance_group_managers.delete_per_instance_configs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeletePerInstanceConfigs", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.DeletePerInstanceConfigs", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_instance_group_manager_delete_instance_config_req_resource", + "type": ".google.cloud.compute.v1.RegionInstanceGroupManagerDeleteInstanceConfigReq" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "DeletePerInstanceConfigs", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.DeletePerInstanceConfigs", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns all of the details about the specified managed instance group.", + "canonical": true, + "file": "region_instance_group_managers.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Get", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceGroupManager", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Get", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. A regional managed instance group can contain up to 2000 instances.", + "canonical": true, + "file": "region_instance_group_managers.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Insert", + "async": true, + "parameters": [ + { + "name": "instance_group_manager_resource", + "type": ".google.cloud.compute.v1.InstanceGroupManager" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Insert", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of managed instance groups that are contained within the specified region.", + "canonical": true, + "file": "region_instance_group_managers.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.RegionInstanceGroupManagerList", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.List", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_ListErrors_async", + "title": "AcceleratorTypes listErrors Sample", + "origin": "API_DEFINITION", + "description": " Lists all errors thrown by actions on instances for a given regional managed instance group. The filter and orderBy query parameters are not supported.", + "canonical": true, + "file": "region_instance_group_managers.list_errors.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListErrors", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ListErrors", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.RegionInstanceGroupManagersListErrorsResponse", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "ListErrors", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ListErrors", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_ListManagedInstances_async", + "title": "AcceleratorTypes listManagedInstances Sample", + "origin": "API_DEFINITION", + "description": " Lists the instances in the managed instance group and instances that are scheduled to be created. The list includes any current actions that the group has scheduled for its instances. The orderBy query parameter is not supported. The `pageToken` query parameter is supported only in the alpha and beta API and only if the group's `listManagedInstancesResults` field is set to `PAGINATED`.", + "canonical": true, + "file": "region_instance_group_managers.list_managed_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListManagedInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ListManagedInstances", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.RegionInstanceGroupManagersListInstancesResponse", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "ListManagedInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ListManagedInstances", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_ListPerInstanceConfigs_async", + "title": "AcceleratorTypes listPerInstanceConfigs Sample", + "origin": "API_DEFINITION", + "description": " Lists all of the per-instance configurations defined for the managed instance group. The orderBy query parameter is not supported.", + "canonical": true, + "file": "region_instance_group_managers.list_per_instance_configs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListPerInstanceConfigs", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ListPerInstanceConfigs", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.RegionInstanceGroupManagersListInstanceConfigsResp", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "ListPerInstanceConfigs", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ListPerInstanceConfigs", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listmanagedinstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. If you update your group to specify a new template or instance configuration, it's possible that your intended specification for each VM in the group is different from the current state of that VM. To learn how to apply an updated configuration to the VMs in a MIG, see Updating instances in a MIG.", + "canonical": true, + "file": "region_instance_group_managers.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Patch", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "instance_group_manager_resource", + "type": ".google.cloud.compute.v1.InstanceGroupManager" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Patch", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_PatchPerInstanceConfigs_async", + "title": "AcceleratorTypes patchPerInstanceConfigs Sample", + "origin": "API_DEFINITION", + "description": " Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch.", + "canonical": true, + "file": "region_instance_group_managers.patch_per_instance_configs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PatchPerInstanceConfigs", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.PatchPerInstanceConfigs", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_instance_group_manager_patch_instance_config_req_resource", + "type": ".google.cloud.compute.v1.RegionInstanceGroupManagerPatchInstanceConfigReq" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "PatchPerInstanceConfigs", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.PatchPerInstanceConfigs", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_RecreateInstances_async", + "title": "AcceleratorTypes recreateInstances Sample", + "origin": "API_DEFINITION", + "description": " Flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group's current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.", + "canonical": true, + "file": "region_instance_group_managers.recreate_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RecreateInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.RecreateInstances", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_instance_group_managers_recreate_request_resource", + "type": ".google.cloud.compute.v1.RegionInstanceGroupManagersRecreateRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "RecreateInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.RecreateInstances", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_Resize_async", + "title": "AcceleratorTypes resize Sample", + "origin": "API_DEFINITION", + "description": " Changes the intended size of the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes one or more instances. The resize operation is marked DONE if the resize request is successful. The underlying actions take additional time. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted.", + "canonical": true, + "file": "region_instance_group_managers.resize.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Resize", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Resize", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "size", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "Resize", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Resize", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_SetInstanceTemplate_async", + "title": "AcceleratorTypes setInstanceTemplate Sample", + "origin": "API_DEFINITION", + "description": " Sets the instance template to use when creating new instances or recreating instances in this group. Existing instances are not affected.", + "canonical": true, + "file": "region_instance_group_managers.set_instance_template.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInstanceTemplate", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.SetInstanceTemplate", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_instance_group_managers_set_template_request_resource", + "type": ".google.cloud.compute.v1.RegionInstanceGroupManagersSetTemplateRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "SetInstanceTemplate", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.SetInstanceTemplate", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_SetTargetPools_async", + "title": "AcceleratorTypes setTargetPools Sample", + "origin": "API_DEFINITION", + "description": " Modifies the target pools to which all new instances in this group are assigned. Existing instances in the group are not affected.", + "canonical": true, + "file": "region_instance_group_managers.set_target_pools.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetTargetPools", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.SetTargetPools", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_instance_group_managers_set_target_pools_request_resource", + "type": ".google.cloud.compute.v1.RegionInstanceGroupManagersSetTargetPoolsRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "SetTargetPools", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.SetTargetPools", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_UpdatePerInstanceConfigs_async", + "title": "AcceleratorTypes updatePerInstanceConfigs Sample", + "origin": "API_DEFINITION", + "description": " Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch.", + "canonical": true, + "file": "region_instance_group_managers.update_per_instance_configs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdatePerInstanceConfigs", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.UpdatePerInstanceConfigs", + "async": true, + "parameters": [ + { + "name": "instance_group_manager", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_instance_group_manager_update_instance_config_req_resource", + "type": ".google.cloud.compute.v1.RegionInstanceGroupManagerUpdateInstanceConfigReq" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceGroupManagersClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagersClient" + }, + "method": { + "shortName": "UpdatePerInstanceConfigs", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.UpdatePerInstanceConfigs", + "service": { + "shortName": "RegionInstanceGroupManagers", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroups_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified instance group resource.", + "canonical": true, + "file": "region_instance_groups.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionInstanceGroups.Get", + "async": true, + "parameters": [ + { + "name": "instance_group", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceGroup", + "client": { + "shortName": "RegionInstanceGroupsClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionInstanceGroups.Get", + "service": { + "shortName": "RegionInstanceGroups", + "fullName": "google.cloud.compute.v1.RegionInstanceGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroups_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of instance group resources contained within the specified region.", + "canonical": true, + "file": "region_instance_groups.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionInstanceGroups.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.RegionInstanceGroupList", + "client": { + "shortName": "RegionInstanceGroupsClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionInstanceGroups.List", + "service": { + "shortName": "RegionInstanceGroups", + "fullName": "google.cloud.compute.v1.RegionInstanceGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroups_ListInstances_async", + "title": "AcceleratorTypes listInstances Sample", + "origin": "API_DEFINITION", + "description": " Lists the instances in the specified instance group and displays information about the named ports. Depending on the specified options, this method can list all instances or only the instances that are running. The orderBy query parameter is not supported.", + "canonical": true, + "file": "region_instance_groups.list_instances.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 90, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroups.ListInstances", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "instance_group", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_instance_groups_list_instances_request_resource", + "type": ".google.cloud.compute.v1.RegionInstanceGroupsListInstancesRequest" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.RegionInstanceGroupsListInstances", + "client": { + "shortName": "RegionInstanceGroupsClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupsClient" + }, + "method": { + "shortName": "ListInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroups.ListInstances", + "service": { + "shortName": "RegionInstanceGroups", + "fullName": "google.cloud.compute.v1.RegionInstanceGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceGroups_SetNamedPorts_async", + "title": "AcceleratorTypes setNamedPorts Sample", + "origin": "API_DEFINITION", + "description": " Sets the named ports for the specified regional instance group.", + "canonical": true, + "file": "region_instance_groups.set_named_ports.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetNamedPorts", + "fullName": "google.cloud.compute.v1.RegionInstanceGroups.SetNamedPorts", + "async": true, + "parameters": [ + { + "name": "instance_group", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_instance_groups_set_named_ports_request_resource", + "type": ".google.cloud.compute.v1.RegionInstanceGroupsSetNamedPortsRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceGroupsClient", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupsClient" + }, + "method": { + "shortName": "SetNamedPorts", + "fullName": "google.cloud.compute.v1.RegionInstanceGroups.SetNamedPorts", + "service": { + "shortName": "RegionInstanceGroups", + "fullName": "google.cloud.compute.v1.RegionInstanceGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstances_BulkInsert_async", + "title": "AcceleratorTypes bulkInsert Sample", + "origin": "API_DEFINITION", + "description": " Creates multiple instances in a given region. Count specifies the number of instances to create.", + "canonical": true, + "file": "region_instances.bulk_insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BulkInsert", + "fullName": "google.cloud.compute.v1.RegionInstances.BulkInsert", + "async": true, + "parameters": [ + { + "name": "bulk_insert_instance_resource_resource", + "type": ".google.cloud.compute.v1.BulkInsertInstanceResource" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstancesClient", + "fullName": "google.cloud.compute.v1.RegionInstancesClient" + }, + "method": { + "shortName": "BulkInsert", + "fullName": "google.cloud.compute.v1.RegionInstances.BulkInsert", + "service": { + "shortName": "RegionInstances", + "fullName": "google.cloud.compute.v1.RegionInstances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceTemplates_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified instance template. Deleting an instance template is permanent and cannot be undone.", + "canonical": true, + "file": "region_instance_templates.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionInstanceTemplates.Delete", + "async": true, + "parameters": [ + { + "name": "instance_template", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceTemplatesClient", + "fullName": "google.cloud.compute.v1.RegionInstanceTemplatesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionInstanceTemplates.Delete", + "service": { + "shortName": "RegionInstanceTemplates", + "fullName": "google.cloud.compute.v1.RegionInstanceTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceTemplates_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified instance template.", + "canonical": true, + "file": "region_instance_templates.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionInstanceTemplates.Get", + "async": true, + "parameters": [ + { + "name": "instance_template", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceTemplate", + "client": { + "shortName": "RegionInstanceTemplatesClient", + "fullName": "google.cloud.compute.v1.RegionInstanceTemplatesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionInstanceTemplates.Get", + "service": { + "shortName": "RegionInstanceTemplates", + "fullName": "google.cloud.compute.v1.RegionInstanceTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceTemplates_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates an instance template in the specified project and region using the global instance template whose URL is included in the request.", + "canonical": true, + "file": "region_instance_templates.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionInstanceTemplates.Insert", + "async": true, + "parameters": [ + { + "name": "instance_template_resource", + "type": ".google.cloud.compute.v1.InstanceTemplate" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionInstanceTemplatesClient", + "fullName": "google.cloud.compute.v1.RegionInstanceTemplatesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionInstanceTemplates.Insert", + "service": { + "shortName": "RegionInstanceTemplates", + "fullName": "google.cloud.compute.v1.RegionInstanceTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionInstanceTemplates_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of instance templates that are contained within the specified project and region.", + "canonical": true, + "file": "region_instance_templates.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionInstanceTemplates.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.InstanceTemplateList", + "client": { + "shortName": "RegionInstanceTemplatesClient", + "fullName": "google.cloud.compute.v1.RegionInstanceTemplatesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionInstanceTemplates.List", + "service": { + "shortName": "RegionInstanceTemplates", + "fullName": "google.cloud.compute.v1.RegionInstanceTemplates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkEndpointGroups_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified network endpoint group. Note that the NEG cannot be deleted if it is configured as a backend of a backend service.", + "canonical": true, + "file": "region_network_endpoint_groups.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionNetworkEndpointGroups.Delete", + "async": true, + "parameters": [ + { + "name": "network_endpoint_group", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionNetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.RegionNetworkEndpointGroupsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionNetworkEndpointGroups.Delete", + "service": { + "shortName": "RegionNetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.RegionNetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkEndpointGroups_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified network endpoint group.", + "canonical": true, + "file": "region_network_endpoint_groups.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionNetworkEndpointGroups.Get", + "async": true, + "parameters": [ + { + "name": "network_endpoint_group", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.NetworkEndpointGroup", + "client": { + "shortName": "RegionNetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.RegionNetworkEndpointGroupsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionNetworkEndpointGroups.Get", + "service": { + "shortName": "RegionNetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.RegionNetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkEndpointGroups_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a network endpoint group in the specified project using the parameters that are included in the request.", + "canonical": true, + "file": "region_network_endpoint_groups.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionNetworkEndpointGroups.Insert", + "async": true, + "parameters": [ + { + "name": "network_endpoint_group_resource", + "type": ".google.cloud.compute.v1.NetworkEndpointGroup" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionNetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.RegionNetworkEndpointGroupsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionNetworkEndpointGroups.Insert", + "service": { + "shortName": "RegionNetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.RegionNetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkEndpointGroups_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of regional network endpoint groups available to the specified project in the given region.", + "canonical": true, + "file": "region_network_endpoint_groups.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionNetworkEndpointGroups.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.NetworkEndpointGroupList", + "client": { + "shortName": "RegionNetworkEndpointGroupsClient", + "fullName": "google.cloud.compute.v1.RegionNetworkEndpointGroupsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionNetworkEndpointGroups.List", + "service": { + "shortName": "RegionNetworkEndpointGroups", + "fullName": "google.cloud.compute.v1.RegionNetworkEndpointGroups" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_AddAssociation_async", + "title": "AcceleratorTypes addAssociation Sample", + "origin": "API_DEFINITION", + "description": " Inserts an association for the specified network firewall policy.", + "canonical": true, + "file": "region_network_firewall_policies.add_association.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 76, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddAssociation", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.AddAssociation", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "firewall_policy_association_resource", + "type": ".google.cloud.compute.v1.FirewallPolicyAssociation" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "replace_existing_association", + "type": "TYPE_BOOL" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "AddAssociation", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.AddAssociation", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_AddRule_async", + "title": "AcceleratorTypes addRule Sample", + "origin": "API_DEFINITION", + "description": " Inserts a rule into a network firewall policy.", + "canonical": true, + "file": "region_network_firewall_policies.add_rule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddRule", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.AddRule", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "firewall_policy_rule_resource", + "type": ".google.cloud.compute.v1.FirewallPolicyRule" + }, + { + "name": "max_priority", + "type": "TYPE_INT32" + }, + { + "name": "min_priority", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "AddRule", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.AddRule", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_CloneRules_async", + "title": "AcceleratorTypes cloneRules Sample", + "origin": "API_DEFINITION", + "description": " Copies rules to the specified network firewall policy.", + "canonical": true, + "file": "region_network_firewall_policies.clone_rules.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CloneRules", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.CloneRules", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "source_firewall_policy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "CloneRules", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.CloneRules", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified network firewall policy.", + "canonical": true, + "file": "region_network_firewall_policies.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.Delete", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.Delete", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified network firewall policy.", + "canonical": true, + "file": "region_network_firewall_policies.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.Get", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.FirewallPolicy", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.Get", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_GetAssociation_async", + "title": "AcceleratorTypes getAssociation Sample", + "origin": "API_DEFINITION", + "description": " Gets an association with the specified name.", + "canonical": true, + "file": "region_network_firewall_policies.get_association.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAssociation", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.GetAssociation", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.FirewallPolicyAssociation", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "GetAssociation", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.GetAssociation", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_GetEffectiveFirewalls_async", + "title": "AcceleratorTypes getEffectiveFirewalls Sample", + "origin": "API_DEFINITION", + "description": " Returns the effective firewalls on a given network.", + "canonical": true, + "file": "region_network_firewall_policies.get_effective_firewalls.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetEffectiveFirewalls", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.GetEffectiveFirewalls", + "async": true, + "parameters": [ + { + "name": "network", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "GetEffectiveFirewalls", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.GetEffectiveFirewalls", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "region_network_firewall_policies.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.GetIamPolicy", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_GetRule_async", + "title": "AcceleratorTypes getRule Sample", + "origin": "API_DEFINITION", + "description": " Gets a rule of the specified priority.", + "canonical": true, + "file": "region_network_firewall_policies.get_rule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetRule", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.GetRule", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "priority", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.FirewallPolicyRule", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "GetRule", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.GetRule", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a new network firewall policy in the specified project and region.", + "canonical": true, + "file": "region_network_firewall_policies.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.Insert", + "async": true, + "parameters": [ + { + "name": "firewall_policy_resource", + "type": ".google.cloud.compute.v1.FirewallPolicy" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.Insert", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Lists all the network firewall policies that have been configured for the specified project in the given region.", + "canonical": true, + "file": "region_network_firewall_policies.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.FirewallPolicyList", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.List", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified network firewall policy.", + "canonical": true, + "file": "region_network_firewall_policies.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.Patch", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "firewall_policy_resource", + "type": ".google.cloud.compute.v1.FirewallPolicy" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.Patch", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_PatchRule_async", + "title": "AcceleratorTypes patchRule Sample", + "origin": "API_DEFINITION", + "description": " Patches a rule of the specified priority.", + "canonical": true, + "file": "region_network_firewall_policies.patch_rule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 76, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PatchRule", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.PatchRule", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "firewall_policy_rule_resource", + "type": ".google.cloud.compute.v1.FirewallPolicyRule" + }, + { + "name": "priority", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "PatchRule", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.PatchRule", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_RemoveAssociation_async", + "title": "AcceleratorTypes removeAssociation Sample", + "origin": "API_DEFINITION", + "description": " Removes an association for the specified network firewall policy.", + "canonical": true, + "file": "region_network_firewall_policies.remove_association.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveAssociation", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.RemoveAssociation", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "RemoveAssociation", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.RemoveAssociation", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_RemoveRule_async", + "title": "AcceleratorTypes removeRule Sample", + "origin": "API_DEFINITION", + "description": " Deletes a rule of the specified priority.", + "canonical": true, + "file": "region_network_firewall_policies.remove_rule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveRule", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.RemoveRule", + "async": true, + "parameters": [ + { + "name": "firewall_policy", + "type": "TYPE_STRING" + }, + { + "name": "priority", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "RemoveRule", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.RemoveRule", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "region_network_firewall_policies.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_set_policy_request_resource", + "type": ".google.cloud.compute.v1.RegionSetPolicyRequest" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.SetIamPolicy", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNetworkFirewallPolicies_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "region_network_firewall_policies.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "RegionNetworkFirewallPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies.TestIamPermissions", + "service": { + "shortName": "RegionNetworkFirewallPolicies", + "fullName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNotificationEndpoints_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified NotificationEndpoint in the given region", + "canonical": true, + "file": "region_notification_endpoints.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionNotificationEndpoints.Delete", + "async": true, + "parameters": [ + { + "name": "notification_endpoint", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionNotificationEndpointsClient", + "fullName": "google.cloud.compute.v1.RegionNotificationEndpointsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionNotificationEndpoints.Delete", + "service": { + "shortName": "RegionNotificationEndpoints", + "fullName": "google.cloud.compute.v1.RegionNotificationEndpoints" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNotificationEndpoints_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified NotificationEndpoint resource in the given region.", + "canonical": true, + "file": "region_notification_endpoints.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionNotificationEndpoints.Get", + "async": true, + "parameters": [ + { + "name": "notification_endpoint", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.NotificationEndpoint", + "client": { + "shortName": "RegionNotificationEndpointsClient", + "fullName": "google.cloud.compute.v1.RegionNotificationEndpointsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionNotificationEndpoints.Get", + "service": { + "shortName": "RegionNotificationEndpoints", + "fullName": "google.cloud.compute.v1.RegionNotificationEndpoints" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNotificationEndpoints_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Create a NotificationEndpoint in the specified project in the given region using the parameters that are included in the request.", + "canonical": true, + "file": "region_notification_endpoints.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionNotificationEndpoints.Insert", + "async": true, + "parameters": [ + { + "name": "notification_endpoint_resource", + "type": ".google.cloud.compute.v1.NotificationEndpoint" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionNotificationEndpointsClient", + "fullName": "google.cloud.compute.v1.RegionNotificationEndpointsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionNotificationEndpoints.Insert", + "service": { + "shortName": "RegionNotificationEndpoints", + "fullName": "google.cloud.compute.v1.RegionNotificationEndpoints" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionNotificationEndpoints_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Lists the NotificationEndpoints for a project in the given region.", + "canonical": true, + "file": "region_notification_endpoints.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionNotificationEndpoints.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.NotificationEndpointList", + "client": { + "shortName": "RegionNotificationEndpointsClient", + "fullName": "google.cloud.compute.v1.RegionNotificationEndpointsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionNotificationEndpoints.List", + "service": { + "shortName": "RegionNotificationEndpoints", + "fullName": "google.cloud.compute.v1.RegionNotificationEndpoints" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionOperations_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified region-specific Operations resource.", + "canonical": true, + "file": "region_operations.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionOperations.Delete", + "async": true, + "parameters": [ + { + "name": "operation", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.DeleteRegionOperationResponse", + "client": { + "shortName": "RegionOperationsClient", + "fullName": "google.cloud.compute.v1.RegionOperationsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionOperations.Delete", + "service": { + "shortName": "RegionOperations", + "fullName": "google.cloud.compute.v1.RegionOperations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionOperations_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the specified region-specific Operations resource.", + "canonical": true, + "file": "region_operations.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionOperations.Get", + "async": true, + "parameters": [ + { + "name": "operation", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionOperationsClient", + "fullName": "google.cloud.compute.v1.RegionOperationsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionOperations.Get", + "service": { + "shortName": "RegionOperations", + "fullName": "google.cloud.compute.v1.RegionOperations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionOperations_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of Operation resources contained within the specified region.", + "canonical": true, + "file": "region_operations.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionOperations.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.OperationList", + "client": { + "shortName": "RegionOperationsClient", + "fullName": "google.cloud.compute.v1.RegionOperationsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionOperations.List", + "service": { + "shortName": "RegionOperations", + "fullName": "google.cloud.compute.v1.RegionOperations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionOperations_Wait_async", + "title": "AcceleratorTypes wait Sample", + "origin": "API_DEFINITION", + "description": " Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the `GET` method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. ", + "canonical": true, + "file": "region_operations.wait.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Wait", + "fullName": "google.cloud.compute.v1.RegionOperations.Wait", + "async": true, + "parameters": [ + { + "name": "operation", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionOperationsClient", + "fullName": "google.cloud.compute.v1.RegionOperationsClient" + }, + "method": { + "shortName": "Wait", + "fullName": "google.cloud.compute.v1.RegionOperations.Wait", + "service": { + "shortName": "RegionOperations", + "fullName": "google.cloud.compute.v1.RegionOperations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Regions_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified Region resource. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request.", + "canonical": true, + "file": "regions.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Regions.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Region", + "client": { + "shortName": "RegionsClient", + "fullName": "google.cloud.compute.v1.RegionsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Regions.Get", + "service": { + "shortName": "Regions", + "fullName": "google.cloud.compute.v1.Regions" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Regions_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of region resources available to the specified project. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `items.quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request.", + "canonical": true, + "file": "regions.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Regions.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.RegionList", + "client": { + "shortName": "RegionsClient", + "fullName": "google.cloud.compute.v1.RegionsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Regions.List", + "service": { + "shortName": "Regions", + "fullName": "google.cloud.compute.v1.Regions" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionSecurityPolicies_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified policy.", + "canonical": true, + "file": "region_security_policies.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "security_policy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionSecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionSecurityPoliciesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.Delete", + "service": { + "shortName": "RegionSecurityPolicies", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionSecurityPolicies_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " List all of the ordered rules present in a single specified policy.", + "canonical": true, + "file": "region_security_policies.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "security_policy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.SecurityPolicy", + "client": { + "shortName": "RegionSecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionSecurityPoliciesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.Get", + "service": { + "shortName": "RegionSecurityPolicies", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionSecurityPolicies_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a new policy in the specified project using the data included in the request.", + "canonical": true, + "file": "region_security_policies.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "security_policy_resource", + "type": ".google.cloud.compute.v1.SecurityPolicy" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionSecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionSecurityPoliciesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.Insert", + "service": { + "shortName": "RegionSecurityPolicies", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionSecurityPolicies_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " List all the policies that have been configured for the specified project and region.", + "canonical": true, + "file": "region_security_policies.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.SecurityPolicyList", + "client": { + "shortName": "RegionSecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionSecurityPoliciesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.List", + "service": { + "shortName": "RegionSecurityPolicies", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionSecurityPolicies_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified policy with the data included in the request. To clear fields in the rule, leave the fields empty and specify them in the updateMask. This cannot be used to be update the rules in the policy. Please use the per rule methods like addRule, patchRule, and removeRule instead.", + "canonical": true, + "file": "region_security_policies.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.Patch", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "security_policy", + "type": "TYPE_STRING" + }, + { + "name": "security_policy_resource", + "type": ".google.cloud.compute.v1.SecurityPolicy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionSecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionSecurityPoliciesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.Patch", + "service": { + "shortName": "RegionSecurityPolicies", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionSslCertificates_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified SslCertificate resource in the region.", + "canonical": true, + "file": "region_ssl_certificates.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionSslCertificates.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "ssl_certificate", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionSslCertificatesClient", + "fullName": "google.cloud.compute.v1.RegionSslCertificatesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionSslCertificates.Delete", + "service": { + "shortName": "RegionSslCertificates", + "fullName": "google.cloud.compute.v1.RegionSslCertificates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionSslCertificates_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified SslCertificate resource in the specified region. Get a list of available SSL certificates by making a list() request.", + "canonical": true, + "file": "region_ssl_certificates.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionSslCertificates.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "ssl_certificate", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.SslCertificate", + "client": { + "shortName": "RegionSslCertificatesClient", + "fullName": "google.cloud.compute.v1.RegionSslCertificatesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionSslCertificates.Get", + "service": { + "shortName": "RegionSslCertificates", + "fullName": "google.cloud.compute.v1.RegionSslCertificates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionSslCertificates_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a SslCertificate resource in the specified project and region using the data included in the request", + "canonical": true, + "file": "region_ssl_certificates.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionSslCertificates.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "ssl_certificate_resource", + "type": ".google.cloud.compute.v1.SslCertificate" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionSslCertificatesClient", + "fullName": "google.cloud.compute.v1.RegionSslCertificatesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionSslCertificates.Insert", + "service": { + "shortName": "RegionSslCertificates", + "fullName": "google.cloud.compute.v1.RegionSslCertificates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionSslCertificates_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of SslCertificate resources available to the specified project in the specified region.", + "canonical": true, + "file": "region_ssl_certificates.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionSslCertificates.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.SslCertificateList", + "client": { + "shortName": "RegionSslCertificatesClient", + "fullName": "google.cloud.compute.v1.RegionSslCertificatesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionSslCertificates.List", + "service": { + "shortName": "RegionSslCertificates", + "fullName": "google.cloud.compute.v1.RegionSslCertificates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionSslPolicies_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified SSL policy. The SSL policy resource can be deleted only if it is not in use by any TargetHttpsProxy or TargetSslProxy resources.", + "canonical": true, + "file": "region_ssl_policies.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionSslPolicies.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "ssl_policy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionSslPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionSslPoliciesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionSslPolicies.Delete", + "service": { + "shortName": "RegionSslPolicies", + "fullName": "google.cloud.compute.v1.RegionSslPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionSslPolicies_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Lists all of the ordered rules present in a single specified policy.", + "canonical": true, + "file": "region_ssl_policies.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionSslPolicies.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "ssl_policy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.SslPolicy", + "client": { + "shortName": "RegionSslPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionSslPoliciesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionSslPolicies.Get", + "service": { + "shortName": "RegionSslPolicies", + "fullName": "google.cloud.compute.v1.RegionSslPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionSslPolicies_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a new policy in the specified project and region using the data included in the request.", + "canonical": true, + "file": "region_ssl_policies.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionSslPolicies.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "ssl_policy_resource", + "type": ".google.cloud.compute.v1.SslPolicy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionSslPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionSslPoliciesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionSslPolicies.Insert", + "service": { + "shortName": "RegionSslPolicies", + "fullName": "google.cloud.compute.v1.RegionSslPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionSslPolicies_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Lists all the SSL policies that have been configured for the specified project and region.", + "canonical": true, + "file": "region_ssl_policies.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionSslPolicies.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.SslPoliciesList", + "client": { + "shortName": "RegionSslPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionSslPoliciesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionSslPolicies.List", + "service": { + "shortName": "RegionSslPolicies", + "fullName": "google.cloud.compute.v1.RegionSslPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionSslPolicies_ListAvailableFeatures_async", + "title": "AcceleratorTypes listAvailableFeatures Sample", + "origin": "API_DEFINITION", + "description": " Lists all features that can be specified in the SSL policy when using custom profile.", + "canonical": true, + "file": "region_ssl_policies.list_available_features.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 78, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListAvailableFeatures", + "fullName": "google.cloud.compute.v1.RegionSslPolicies.ListAvailableFeatures", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.SslPoliciesListAvailableFeaturesResponse", + "client": { + "shortName": "RegionSslPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionSslPoliciesClient" + }, + "method": { + "shortName": "ListAvailableFeatures", + "fullName": "google.cloud.compute.v1.RegionSslPolicies.ListAvailableFeatures", + "service": { + "shortName": "RegionSslPolicies", + "fullName": "google.cloud.compute.v1.RegionSslPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionSslPolicies_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified SSL policy with the data included in the request.", + "canonical": true, + "file": "region_ssl_policies.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionSslPolicies.Patch", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "ssl_policy", + "type": "TYPE_STRING" + }, + { + "name": "ssl_policy_resource", + "type": ".google.cloud.compute.v1.SslPolicy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionSslPoliciesClient", + "fullName": "google.cloud.compute.v1.RegionSslPoliciesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionSslPolicies.Patch", + "service": { + "shortName": "RegionSslPolicies", + "fullName": "google.cloud.compute.v1.RegionSslPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionTargetHttpProxies_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified TargetHttpProxy resource.", + "canonical": true, + "file": "region_target_http_proxies.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxies.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_http_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionTargetHttpProxiesClient", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxiesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxies.Delete", + "service": { + "shortName": "RegionTargetHttpProxies", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionTargetHttpProxies_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified TargetHttpProxy resource in the specified region.", + "canonical": true, + "file": "region_target_http_proxies.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxies.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "target_http_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TargetHttpProxy", + "client": { + "shortName": "RegionTargetHttpProxiesClient", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxiesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxies.Get", + "service": { + "shortName": "RegionTargetHttpProxies", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionTargetHttpProxies_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a TargetHttpProxy resource in the specified project and region using the data included in the request.", + "canonical": true, + "file": "region_target_http_proxies.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxies.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_http_proxy_resource", + "type": ".google.cloud.compute.v1.TargetHttpProxy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionTargetHttpProxiesClient", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxiesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxies.Insert", + "service": { + "shortName": "RegionTargetHttpProxies", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionTargetHttpProxies_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of TargetHttpProxy resources available to the specified project in the specified region.", + "canonical": true, + "file": "region_target_http_proxies.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxies.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.TargetHttpProxyList", + "client": { + "shortName": "RegionTargetHttpProxiesClient", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxiesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxies.List", + "service": { + "shortName": "RegionTargetHttpProxies", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionTargetHttpProxies_SetUrlMap_async", + "title": "AcceleratorTypes setUrlMap Sample", + "origin": "API_DEFINITION", + "description": " Changes the URL map for TargetHttpProxy.", + "canonical": true, + "file": "region_target_http_proxies.set_url_map.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetUrlMap", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxies.SetUrlMap", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_http_proxy", + "type": "TYPE_STRING" + }, + { + "name": "url_map_reference_resource", + "type": ".google.cloud.compute.v1.UrlMapReference" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionTargetHttpProxiesClient", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxiesClient" + }, + "method": { + "shortName": "SetUrlMap", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxies.SetUrlMap", + "service": { + "shortName": "RegionTargetHttpProxies", + "fullName": "google.cloud.compute.v1.RegionTargetHttpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionTargetHttpsProxies_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified TargetHttpsProxy resource.", + "canonical": true, + "file": "region_target_https_proxies.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_https_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionTargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxiesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies.Delete", + "service": { + "shortName": "RegionTargetHttpsProxies", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionTargetHttpsProxies_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified TargetHttpsProxy resource in the specified region.", + "canonical": true, + "file": "region_target_https_proxies.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "target_https_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TargetHttpsProxy", + "client": { + "shortName": "RegionTargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxiesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies.Get", + "service": { + "shortName": "RegionTargetHttpsProxies", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionTargetHttpsProxies_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a TargetHttpsProxy resource in the specified project and region using the data included in the request.", + "canonical": true, + "file": "region_target_https_proxies.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_https_proxy_resource", + "type": ".google.cloud.compute.v1.TargetHttpsProxy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionTargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxiesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies.Insert", + "service": { + "shortName": "RegionTargetHttpsProxies", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionTargetHttpsProxies_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of TargetHttpsProxy resources available to the specified project in the specified region.", + "canonical": true, + "file": "region_target_https_proxies.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.TargetHttpsProxyList", + "client": { + "shortName": "RegionTargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxiesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies.List", + "service": { + "shortName": "RegionTargetHttpsProxies", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionTargetHttpsProxies_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified regional TargetHttpsProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.", + "canonical": true, + "file": "region_target_https_proxies.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies.Patch", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_https_proxy", + "type": "TYPE_STRING" + }, + { + "name": "target_https_proxy_resource", + "type": ".google.cloud.compute.v1.TargetHttpsProxy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionTargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxiesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies.Patch", + "service": { + "shortName": "RegionTargetHttpsProxies", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionTargetHttpsProxies_SetSslCertificates_async", + "title": "AcceleratorTypes setSslCertificates Sample", + "origin": "API_DEFINITION", + "description": " Replaces SslCertificates for TargetHttpsProxy.", + "canonical": true, + "file": "region_target_https_proxies.set_ssl_certificates.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetSslCertificates", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies.SetSslCertificates", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_target_https_proxies_set_ssl_certificates_request_resource", + "type": ".google.cloud.compute.v1.RegionTargetHttpsProxiesSetSslCertificatesRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_https_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionTargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxiesClient" + }, + "method": { + "shortName": "SetSslCertificates", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies.SetSslCertificates", + "service": { + "shortName": "RegionTargetHttpsProxies", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionTargetHttpsProxies_SetUrlMap_async", + "title": "AcceleratorTypes setUrlMap Sample", + "origin": "API_DEFINITION", + "description": " Changes the URL map for TargetHttpsProxy.", + "canonical": true, + "file": "region_target_https_proxies.set_url_map.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetUrlMap", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies.SetUrlMap", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_https_proxy", + "type": "TYPE_STRING" + }, + { + "name": "url_map_reference_resource", + "type": ".google.cloud.compute.v1.UrlMapReference" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionTargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxiesClient" + }, + "method": { + "shortName": "SetUrlMap", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies.SetUrlMap", + "service": { + "shortName": "RegionTargetHttpsProxies", + "fullName": "google.cloud.compute.v1.RegionTargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionTargetTcpProxies_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified TargetTcpProxy resource.", + "canonical": true, + "file": "region_target_tcp_proxies.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionTargetTcpProxies.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_tcp_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionTargetTcpProxiesClient", + "fullName": "google.cloud.compute.v1.RegionTargetTcpProxiesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionTargetTcpProxies.Delete", + "service": { + "shortName": "RegionTargetTcpProxies", + "fullName": "google.cloud.compute.v1.RegionTargetTcpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionTargetTcpProxies_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified TargetTcpProxy resource.", + "canonical": true, + "file": "region_target_tcp_proxies.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionTargetTcpProxies.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "target_tcp_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TargetTcpProxy", + "client": { + "shortName": "RegionTargetTcpProxiesClient", + "fullName": "google.cloud.compute.v1.RegionTargetTcpProxiesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionTargetTcpProxies.Get", + "service": { + "shortName": "RegionTargetTcpProxies", + "fullName": "google.cloud.compute.v1.RegionTargetTcpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionTargetTcpProxies_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a TargetTcpProxy resource in the specified project and region using the data included in the request.", + "canonical": true, + "file": "region_target_tcp_proxies.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionTargetTcpProxies.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_tcp_proxy_resource", + "type": ".google.cloud.compute.v1.TargetTcpProxy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionTargetTcpProxiesClient", + "fullName": "google.cloud.compute.v1.RegionTargetTcpProxiesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionTargetTcpProxies.Insert", + "service": { + "shortName": "RegionTargetTcpProxies", + "fullName": "google.cloud.compute.v1.RegionTargetTcpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionTargetTcpProxies_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of TargetTcpProxy resources available to the specified project in a given region.", + "canonical": true, + "file": "region_target_tcp_proxies.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionTargetTcpProxies.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.TargetTcpProxyList", + "client": { + "shortName": "RegionTargetTcpProxiesClient", + "fullName": "google.cloud.compute.v1.RegionTargetTcpProxiesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionTargetTcpProxies.List", + "service": { + "shortName": "RegionTargetTcpProxies", + "fullName": "google.cloud.compute.v1.RegionTargetTcpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionUrlMaps_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified UrlMap resource.", + "canonical": true, + "file": "region_url_maps.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionUrlMaps.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "url_map", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionUrlMapsClient", + "fullName": "google.cloud.compute.v1.RegionUrlMapsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.RegionUrlMaps.Delete", + "service": { + "shortName": "RegionUrlMaps", + "fullName": "google.cloud.compute.v1.RegionUrlMaps" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionUrlMaps_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified UrlMap resource.", + "canonical": true, + "file": "region_url_maps.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionUrlMaps.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "url_map", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.UrlMap", + "client": { + "shortName": "RegionUrlMapsClient", + "fullName": "google.cloud.compute.v1.RegionUrlMapsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.RegionUrlMaps.Get", + "service": { + "shortName": "RegionUrlMaps", + "fullName": "google.cloud.compute.v1.RegionUrlMaps" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionUrlMaps_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a UrlMap resource in the specified project using the data included in the request.", + "canonical": true, + "file": "region_url_maps.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionUrlMaps.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "url_map_resource", + "type": ".google.cloud.compute.v1.UrlMap" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionUrlMapsClient", + "fullName": "google.cloud.compute.v1.RegionUrlMapsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.RegionUrlMaps.Insert", + "service": { + "shortName": "RegionUrlMaps", + "fullName": "google.cloud.compute.v1.RegionUrlMaps" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionUrlMaps_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of UrlMap resources available to the specified project in the specified region.", + "canonical": true, + "file": "region_url_maps.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionUrlMaps.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.UrlMapList", + "client": { + "shortName": "RegionUrlMapsClient", + "fullName": "google.cloud.compute.v1.RegionUrlMapsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.RegionUrlMaps.List", + "service": { + "shortName": "RegionUrlMaps", + "fullName": "google.cloud.compute.v1.RegionUrlMaps" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionUrlMaps_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified UrlMap resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.", + "canonical": true, + "file": "region_url_maps.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionUrlMaps.Patch", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "url_map", + "type": "TYPE_STRING" + }, + { + "name": "url_map_resource", + "type": ".google.cloud.compute.v1.UrlMap" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionUrlMapsClient", + "fullName": "google.cloud.compute.v1.RegionUrlMapsClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.RegionUrlMaps.Patch", + "service": { + "shortName": "RegionUrlMaps", + "fullName": "google.cloud.compute.v1.RegionUrlMaps" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionUrlMaps_Update_async", + "title": "AcceleratorTypes update Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified UrlMap resource with the data included in the request.", + "canonical": true, + "file": "region_url_maps.update.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.RegionUrlMaps.Update", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "url_map", + "type": "TYPE_STRING" + }, + { + "name": "url_map_resource", + "type": ".google.cloud.compute.v1.UrlMap" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RegionUrlMapsClient", + "fullName": "google.cloud.compute.v1.RegionUrlMapsClient" + }, + "method": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.RegionUrlMaps.Update", + "service": { + "shortName": "RegionUrlMaps", + "fullName": "google.cloud.compute.v1.RegionUrlMaps" + } + } + } + }, + { + "regionTag": "compute_v1_generated_RegionUrlMaps_Validate_async", + "title": "AcceleratorTypes validate Sample", + "origin": "API_DEFINITION", + "description": " Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling this method does NOT create the UrlMap.", + "canonical": true, + "file": "region_url_maps.validate.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Validate", + "fullName": "google.cloud.compute.v1.RegionUrlMaps.Validate", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_url_maps_validate_request_resource", + "type": ".google.cloud.compute.v1.RegionUrlMapsValidateRequest" + }, + { + "name": "url_map", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.UrlMapsValidateResponse", + "client": { + "shortName": "RegionUrlMapsClient", + "fullName": "google.cloud.compute.v1.RegionUrlMapsClient" + }, + "method": { + "shortName": "Validate", + "fullName": "google.cloud.compute.v1.RegionUrlMaps.Validate", + "service": { + "shortName": "RegionUrlMaps", + "fullName": "google.cloud.compute.v1.RegionUrlMaps" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Reservations_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of reservations.", + "canonical": true, + "file": "reservations.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.Reservations.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.ReservationAggregatedList", + "client": { + "shortName": "ReservationsClient", + "fullName": "google.cloud.compute.v1.ReservationsClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.Reservations.AggregatedList", + "service": { + "shortName": "Reservations", + "fullName": "google.cloud.compute.v1.Reservations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Reservations_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified reservation.", + "canonical": true, + "file": "reservations.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Reservations.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "reservation", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ReservationsClient", + "fullName": "google.cloud.compute.v1.ReservationsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Reservations.Delete", + "service": { + "shortName": "Reservations", + "fullName": "google.cloud.compute.v1.Reservations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Reservations_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Retrieves information about the specified reservation.", + "canonical": true, + "file": "reservations.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Reservations.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "reservation", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Reservation", + "client": { + "shortName": "ReservationsClient", + "fullName": "google.cloud.compute.v1.ReservationsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Reservations.Get", + "service": { + "shortName": "Reservations", + "fullName": "google.cloud.compute.v1.Reservations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Reservations_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "reservations.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.Reservations.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "ReservationsClient", + "fullName": "google.cloud.compute.v1.ReservationsClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.Reservations.GetIamPolicy", + "service": { + "shortName": "Reservations", + "fullName": "google.cloud.compute.v1.Reservations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Reservations_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a new reservation. For more information, read Reserving zonal resources.", + "canonical": true, + "file": "reservations.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Reservations.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "reservation_resource", + "type": ".google.cloud.compute.v1.Reservation" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ReservationsClient", + "fullName": "google.cloud.compute.v1.ReservationsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Reservations.Insert", + "service": { + "shortName": "Reservations", + "fullName": "google.cloud.compute.v1.Reservations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Reservations_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " A list of all the reservations that have been configured for the specified project in specified zone.", + "canonical": true, + "file": "reservations.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Reservations.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.ReservationList", + "client": { + "shortName": "ReservationsClient", + "fullName": "google.cloud.compute.v1.ReservationsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Reservations.List", + "service": { + "shortName": "Reservations", + "fullName": "google.cloud.compute.v1.Reservations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Reservations_Resize_async", + "title": "AcceleratorTypes resize Sample", + "origin": "API_DEFINITION", + "description": " Resizes the reservation (applicable to standalone reservations only). For more information, read Modifying reservations.", + "canonical": true, + "file": "reservations.resize.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Resize", + "fullName": "google.cloud.compute.v1.Reservations.Resize", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "reservation", + "type": "TYPE_STRING" + }, + { + "name": "reservations_resize_request_resource", + "type": ".google.cloud.compute.v1.ReservationsResizeRequest" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ReservationsClient", + "fullName": "google.cloud.compute.v1.ReservationsClient" + }, + "method": { + "shortName": "Resize", + "fullName": "google.cloud.compute.v1.Reservations.Resize", + "service": { + "shortName": "Reservations", + "fullName": "google.cloud.compute.v1.Reservations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Reservations_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "reservations.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.Reservations.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + }, + { + "name": "zone_set_policy_request_resource", + "type": ".google.cloud.compute.v1.ZoneSetPolicyRequest" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "ReservationsClient", + "fullName": "google.cloud.compute.v1.ReservationsClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.Reservations.SetIamPolicy", + "service": { + "shortName": "Reservations", + "fullName": "google.cloud.compute.v1.Reservations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Reservations_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "reservations.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.Reservations.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "ReservationsClient", + "fullName": "google.cloud.compute.v1.ReservationsClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.Reservations.TestIamPermissions", + "service": { + "shortName": "Reservations", + "fullName": "google.cloud.compute.v1.Reservations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Reservations_Update_async", + "title": "AcceleratorTypes update Sample", + "origin": "API_DEFINITION", + "description": " Update share settings of the reservation.", + "canonical": true, + "file": "reservations.update.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.Reservations.Update", + "async": true, + "parameters": [ + { + "name": "paths", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "reservation", + "type": "TYPE_STRING" + }, + { + "name": "reservation_resource", + "type": ".google.cloud.compute.v1.Reservation" + }, + { + "name": "update_mask", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ReservationsClient", + "fullName": "google.cloud.compute.v1.ReservationsClient" + }, + "method": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.Reservations.Update", + "service": { + "shortName": "Reservations", + "fullName": "google.cloud.compute.v1.Reservations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ResourcePolicies_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of resource policies.", + "canonical": true, + "file": "resource_policies.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.ResourcePolicies.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.ResourcePolicyAggregatedList", + "client": { + "shortName": "ResourcePoliciesClient", + "fullName": "google.cloud.compute.v1.ResourcePoliciesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.ResourcePolicies.AggregatedList", + "service": { + "shortName": "ResourcePolicies", + "fullName": "google.cloud.compute.v1.ResourcePolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ResourcePolicies_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified resource policy.", + "canonical": true, + "file": "resource_policies.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.ResourcePolicies.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "resource_policy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ResourcePoliciesClient", + "fullName": "google.cloud.compute.v1.ResourcePoliciesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.ResourcePolicies.Delete", + "service": { + "shortName": "ResourcePolicies", + "fullName": "google.cloud.compute.v1.ResourcePolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ResourcePolicies_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Retrieves all information of the specified resource policy.", + "canonical": true, + "file": "resource_policies.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.ResourcePolicies.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource_policy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.ResourcePolicy", + "client": { + "shortName": "ResourcePoliciesClient", + "fullName": "google.cloud.compute.v1.ResourcePoliciesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.ResourcePolicies.Get", + "service": { + "shortName": "ResourcePolicies", + "fullName": "google.cloud.compute.v1.ResourcePolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ResourcePolicies_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "resource_policies.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.ResourcePolicies.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "ResourcePoliciesClient", + "fullName": "google.cloud.compute.v1.ResourcePoliciesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.ResourcePolicies.GetIamPolicy", + "service": { + "shortName": "ResourcePolicies", + "fullName": "google.cloud.compute.v1.ResourcePolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ResourcePolicies_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a new resource policy.", + "canonical": true, + "file": "resource_policies.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.ResourcePolicies.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "resource_policy_resource", + "type": ".google.cloud.compute.v1.ResourcePolicy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ResourcePoliciesClient", + "fullName": "google.cloud.compute.v1.ResourcePoliciesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.ResourcePolicies.Insert", + "service": { + "shortName": "ResourcePolicies", + "fullName": "google.cloud.compute.v1.ResourcePolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ResourcePolicies_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " A list all the resource policies that have been configured for the specified project in specified region.", + "canonical": true, + "file": "resource_policies.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.ResourcePolicies.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.ResourcePolicyList", + "client": { + "shortName": "ResourcePoliciesClient", + "fullName": "google.cloud.compute.v1.ResourcePoliciesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.ResourcePolicies.List", + "service": { + "shortName": "ResourcePolicies", + "fullName": "google.cloud.compute.v1.ResourcePolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ResourcePolicies_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "resource_policies.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.ResourcePolicies.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_set_policy_request_resource", + "type": ".google.cloud.compute.v1.RegionSetPolicyRequest" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "ResourcePoliciesClient", + "fullName": "google.cloud.compute.v1.ResourcePoliciesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.ResourcePolicies.SetIamPolicy", + "service": { + "shortName": "ResourcePolicies", + "fullName": "google.cloud.compute.v1.ResourcePolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ResourcePolicies_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "resource_policies.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.ResourcePolicies.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "ResourcePoliciesClient", + "fullName": "google.cloud.compute.v1.ResourcePoliciesClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.ResourcePolicies.TestIamPermissions", + "service": { + "shortName": "ResourcePolicies", + "fullName": "google.cloud.compute.v1.ResourcePolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Routers_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of routers.", + "canonical": true, + "file": "routers.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.Routers.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.RouterAggregatedList", + "client": { + "shortName": "RoutersClient", + "fullName": "google.cloud.compute.v1.RoutersClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.Routers.AggregatedList", + "service": { + "shortName": "Routers", + "fullName": "google.cloud.compute.v1.Routers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Routers_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified Router resource.", + "canonical": true, + "file": "routers.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Routers.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "router", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RoutersClient", + "fullName": "google.cloud.compute.v1.RoutersClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Routers.Delete", + "service": { + "shortName": "Routers", + "fullName": "google.cloud.compute.v1.Routers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Routers_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified Router resource.", + "canonical": true, + "file": "routers.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Routers.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "router", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Router", + "client": { + "shortName": "RoutersClient", + "fullName": "google.cloud.compute.v1.RoutersClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Routers.Get", + "service": { + "shortName": "Routers", + "fullName": "google.cloud.compute.v1.Routers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Routers_GetNatMappingInfo_async", + "title": "AcceleratorTypes getNatMappingInfo Sample", + "origin": "API_DEFINITION", + "description": " Retrieves runtime Nat mapping information of VM endpoints.", + "canonical": true, + "file": "routers.get_nat_mapping_info.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetNatMappingInfo", + "fullName": "google.cloud.compute.v1.Routers.GetNatMappingInfo", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "router", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.VmEndpointNatMappingsList", + "client": { + "shortName": "RoutersClient", + "fullName": "google.cloud.compute.v1.RoutersClient" + }, + "method": { + "shortName": "GetNatMappingInfo", + "fullName": "google.cloud.compute.v1.Routers.GetNatMappingInfo", + "service": { + "shortName": "Routers", + "fullName": "google.cloud.compute.v1.Routers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Routers_GetRouterStatus_async", + "title": "AcceleratorTypes getRouterStatus Sample", + "origin": "API_DEFINITION", + "description": " Retrieves runtime information of the specified router.", + "canonical": true, + "file": "routers.get_router_status.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetRouterStatus", + "fullName": "google.cloud.compute.v1.Routers.GetRouterStatus", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "router", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.RouterStatusResponse", + "client": { + "shortName": "RoutersClient", + "fullName": "google.cloud.compute.v1.RoutersClient" + }, + "method": { + "shortName": "GetRouterStatus", + "fullName": "google.cloud.compute.v1.Routers.GetRouterStatus", + "service": { + "shortName": "Routers", + "fullName": "google.cloud.compute.v1.Routers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Routers_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a Router resource in the specified project and region using the data included in the request.", + "canonical": true, + "file": "routers.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Routers.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "router_resource", + "type": ".google.cloud.compute.v1.Router" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RoutersClient", + "fullName": "google.cloud.compute.v1.RoutersClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Routers.Insert", + "service": { + "shortName": "Routers", + "fullName": "google.cloud.compute.v1.Routers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Routers_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of Router resources available to the specified project.", + "canonical": true, + "file": "routers.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Routers.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.RouterList", + "client": { + "shortName": "RoutersClient", + "fullName": "google.cloud.compute.v1.RoutersClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Routers.List", + "service": { + "shortName": "Routers", + "fullName": "google.cloud.compute.v1.Routers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Routers_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified Router resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.", + "canonical": true, + "file": "routers.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.Routers.Patch", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "router", + "type": "TYPE_STRING" + }, + { + "name": "router_resource", + "type": ".google.cloud.compute.v1.Router" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RoutersClient", + "fullName": "google.cloud.compute.v1.RoutersClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.Routers.Patch", + "service": { + "shortName": "Routers", + "fullName": "google.cloud.compute.v1.Routers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Routers_Preview_async", + "title": "AcceleratorTypes preview Sample", + "origin": "API_DEFINITION", + "description": " Preview fields auto-generated during router create and update operations. Calling this method does NOT create or update the router.", + "canonical": true, + "file": "routers.preview.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Preview", + "fullName": "google.cloud.compute.v1.Routers.Preview", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "router", + "type": "TYPE_STRING" + }, + { + "name": "router_resource", + "type": ".google.cloud.compute.v1.Router" + } + ], + "resultType": ".google.cloud.compute.v1.RoutersPreviewResponse", + "client": { + "shortName": "RoutersClient", + "fullName": "google.cloud.compute.v1.RoutersClient" + }, + "method": { + "shortName": "Preview", + "fullName": "google.cloud.compute.v1.Routers.Preview", + "service": { + "shortName": "Routers", + "fullName": "google.cloud.compute.v1.Routers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Routers_Update_async", + "title": "AcceleratorTypes update Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified Router resource with the data included in the request. This method conforms to PUT semantics, which requests that the state of the target resource be created or replaced with the state defined by the representation enclosed in the request message payload.", + "canonical": true, + "file": "routers.update.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.Routers.Update", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "router", + "type": "TYPE_STRING" + }, + { + "name": "router_resource", + "type": ".google.cloud.compute.v1.Router" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RoutersClient", + "fullName": "google.cloud.compute.v1.RoutersClient" + }, + "method": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.Routers.Update", + "service": { + "shortName": "Routers", + "fullName": "google.cloud.compute.v1.Routers" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Routes_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified Route resource.", + "canonical": true, + "file": "routes.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Routes.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "route", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RoutesClient", + "fullName": "google.cloud.compute.v1.RoutesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Routes.Delete", + "service": { + "shortName": "Routes", + "fullName": "google.cloud.compute.v1.Routes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Routes_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified Route resource.", + "canonical": true, + "file": "routes.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Routes.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "route", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Route", + "client": { + "shortName": "RoutesClient", + "fullName": "google.cloud.compute.v1.RoutesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Routes.Get", + "service": { + "shortName": "Routes", + "fullName": "google.cloud.compute.v1.Routes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Routes_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a Route resource in the specified project using the data included in the request.", + "canonical": true, + "file": "routes.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Routes.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "route_resource", + "type": ".google.cloud.compute.v1.Route" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "RoutesClient", + "fullName": "google.cloud.compute.v1.RoutesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Routes.Insert", + "service": { + "shortName": "Routes", + "fullName": "google.cloud.compute.v1.Routes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Routes_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of Route resources available to the specified project.", + "canonical": true, + "file": "routes.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Routes.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.RouteList", + "client": { + "shortName": "RoutesClient", + "fullName": "google.cloud.compute.v1.RoutesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Routes.List", + "service": { + "shortName": "Routes", + "fullName": "google.cloud.compute.v1.Routes" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SecurityPolicies_AddRule_async", + "title": "AcceleratorTypes addRule Sample", + "origin": "API_DEFINITION", + "description": " Inserts a rule into a security policy.", + "canonical": true, + "file": "security_policies.add_rule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddRule", + "fullName": "google.cloud.compute.v1.SecurityPolicies.AddRule", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "security_policy", + "type": "TYPE_STRING" + }, + { + "name": "security_policy_rule_resource", + "type": ".google.cloud.compute.v1.SecurityPolicyRule" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.SecurityPoliciesClient" + }, + "method": { + "shortName": "AddRule", + "fullName": "google.cloud.compute.v1.SecurityPolicies.AddRule", + "service": { + "shortName": "SecurityPolicies", + "fullName": "google.cloud.compute.v1.SecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SecurityPolicies_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of all SecurityPolicy resources, regional and global, available to the specified project.", + "canonical": true, + "file": "security_policies.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.SecurityPolicies.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.SecurityPoliciesAggregatedList", + "client": { + "shortName": "SecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.SecurityPoliciesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.SecurityPolicies.AggregatedList", + "service": { + "shortName": "SecurityPolicies", + "fullName": "google.cloud.compute.v1.SecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SecurityPolicies_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified policy.", + "canonical": true, + "file": "security_policies.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.SecurityPolicies.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "security_policy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.SecurityPoliciesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.SecurityPolicies.Delete", + "service": { + "shortName": "SecurityPolicies", + "fullName": "google.cloud.compute.v1.SecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SecurityPolicies_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " List all of the ordered rules present in a single specified policy.", + "canonical": true, + "file": "security_policies.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.SecurityPolicies.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "security_policy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.SecurityPolicy", + "client": { + "shortName": "SecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.SecurityPoliciesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.SecurityPolicies.Get", + "service": { + "shortName": "SecurityPolicies", + "fullName": "google.cloud.compute.v1.SecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SecurityPolicies_GetRule_async", + "title": "AcceleratorTypes getRule Sample", + "origin": "API_DEFINITION", + "description": " Gets a rule at the specified priority.", + "canonical": true, + "file": "security_policies.get_rule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetRule", + "fullName": "google.cloud.compute.v1.SecurityPolicies.GetRule", + "async": true, + "parameters": [ + { + "name": "priority", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "security_policy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.SecurityPolicyRule", + "client": { + "shortName": "SecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.SecurityPoliciesClient" + }, + "method": { + "shortName": "GetRule", + "fullName": "google.cloud.compute.v1.SecurityPolicies.GetRule", + "service": { + "shortName": "SecurityPolicies", + "fullName": "google.cloud.compute.v1.SecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SecurityPolicies_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a new policy in the specified project using the data included in the request.", + "canonical": true, + "file": "security_policies.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.SecurityPolicies.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "security_policy_resource", + "type": ".google.cloud.compute.v1.SecurityPolicy" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.SecurityPoliciesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.SecurityPolicies.Insert", + "service": { + "shortName": "SecurityPolicies", + "fullName": "google.cloud.compute.v1.SecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SecurityPolicies_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " List all the policies that have been configured for the specified project.", + "canonical": true, + "file": "security_policies.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.SecurityPolicies.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.SecurityPolicyList", + "client": { + "shortName": "SecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.SecurityPoliciesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.SecurityPolicies.List", + "service": { + "shortName": "SecurityPolicies", + "fullName": "google.cloud.compute.v1.SecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SecurityPolicies_ListPreconfiguredExpressionSets_async", + "title": "AcceleratorTypes listPreconfiguredExpressionSets Sample", + "origin": "API_DEFINITION", + "description": " Gets the current list of preconfigured Web Application Firewall (WAF) expressions.", + "canonical": true, + "file": "security_policies.list_preconfigured_expression_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListPreconfiguredExpressionSets", + "fullName": "google.cloud.compute.v1.SecurityPolicies.ListPreconfiguredExpressionSets", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.SecurityPoliciesListPreconfiguredExpressionSetsResponse", + "client": { + "shortName": "SecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.SecurityPoliciesClient" + }, + "method": { + "shortName": "ListPreconfiguredExpressionSets", + "fullName": "google.cloud.compute.v1.SecurityPolicies.ListPreconfiguredExpressionSets", + "service": { + "shortName": "SecurityPolicies", + "fullName": "google.cloud.compute.v1.SecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SecurityPolicies_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified policy with the data included in the request. To clear fields in the rule, leave the fields empty and specify them in the updateMask. This cannot be used to be update the rules in the policy. Please use the per rule methods like addRule, patchRule, and removeRule instead.", + "canonical": true, + "file": "security_policies.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.SecurityPolicies.Patch", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "security_policy", + "type": "TYPE_STRING" + }, + { + "name": "security_policy_resource", + "type": ".google.cloud.compute.v1.SecurityPolicy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.SecurityPoliciesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.SecurityPolicies.Patch", + "service": { + "shortName": "SecurityPolicies", + "fullName": "google.cloud.compute.v1.SecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SecurityPolicies_PatchRule_async", + "title": "AcceleratorTypes patchRule Sample", + "origin": "API_DEFINITION", + "description": " Patches a rule at the specified priority.", + "canonical": true, + "file": "security_policies.patch_rule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PatchRule", + "fullName": "google.cloud.compute.v1.SecurityPolicies.PatchRule", + "async": true, + "parameters": [ + { + "name": "priority", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "security_policy", + "type": "TYPE_STRING" + }, + { + "name": "security_policy_rule_resource", + "type": ".google.cloud.compute.v1.SecurityPolicyRule" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.SecurityPoliciesClient" + }, + "method": { + "shortName": "PatchRule", + "fullName": "google.cloud.compute.v1.SecurityPolicies.PatchRule", + "service": { + "shortName": "SecurityPolicies", + "fullName": "google.cloud.compute.v1.SecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SecurityPolicies_RemoveRule_async", + "title": "AcceleratorTypes removeRule Sample", + "origin": "API_DEFINITION", + "description": " Deletes a rule at the specified priority.", + "canonical": true, + "file": "security_policies.remove_rule.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveRule", + "fullName": "google.cloud.compute.v1.SecurityPolicies.RemoveRule", + "async": true, + "parameters": [ + { + "name": "priority", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "security_policy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.SecurityPoliciesClient" + }, + "method": { + "shortName": "RemoveRule", + "fullName": "google.cloud.compute.v1.SecurityPolicies.RemoveRule", + "service": { + "shortName": "SecurityPolicies", + "fullName": "google.cloud.compute.v1.SecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SecurityPolicies_SetLabels_async", + "title": "AcceleratorTypes setLabels Sample", + "origin": "API_DEFINITION", + "description": " Sets the labels on a security policy. To learn more about labels, read the Labeling Resources documentation.", + "canonical": true, + "file": "security_policies.set_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.SecurityPolicies.SetLabels", + "async": true, + "parameters": [ + { + "name": "global_set_labels_request_resource", + "type": ".google.cloud.compute.v1.GlobalSetLabelsRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SecurityPoliciesClient", + "fullName": "google.cloud.compute.v1.SecurityPoliciesClient" + }, + "method": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.SecurityPolicies.SetLabels", + "service": { + "shortName": "SecurityPolicies", + "fullName": "google.cloud.compute.v1.SecurityPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ServiceAttachments_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of all ServiceAttachment resources, regional and global, available to the specified project.", + "canonical": true, + "file": "service_attachments.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.ServiceAttachments.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.ServiceAttachmentAggregatedList", + "client": { + "shortName": "ServiceAttachmentsClient", + "fullName": "google.cloud.compute.v1.ServiceAttachmentsClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.ServiceAttachments.AggregatedList", + "service": { + "shortName": "ServiceAttachments", + "fullName": "google.cloud.compute.v1.ServiceAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ServiceAttachments_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified ServiceAttachment in the given scope", + "canonical": true, + "file": "service_attachments.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.ServiceAttachments.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "service_attachment", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ServiceAttachmentsClient", + "fullName": "google.cloud.compute.v1.ServiceAttachmentsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.ServiceAttachments.Delete", + "service": { + "shortName": "ServiceAttachments", + "fullName": "google.cloud.compute.v1.ServiceAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ServiceAttachments_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified ServiceAttachment resource in the given scope.", + "canonical": true, + "file": "service_attachments.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.ServiceAttachments.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "service_attachment", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.ServiceAttachment", + "client": { + "shortName": "ServiceAttachmentsClient", + "fullName": "google.cloud.compute.v1.ServiceAttachmentsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.ServiceAttachments.Get", + "service": { + "shortName": "ServiceAttachments", + "fullName": "google.cloud.compute.v1.ServiceAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ServiceAttachments_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "service_attachments.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.ServiceAttachments.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "ServiceAttachmentsClient", + "fullName": "google.cloud.compute.v1.ServiceAttachmentsClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.ServiceAttachments.GetIamPolicy", + "service": { + "shortName": "ServiceAttachments", + "fullName": "google.cloud.compute.v1.ServiceAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ServiceAttachments_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a ServiceAttachment in the specified project in the given scope using the parameters that are included in the request.", + "canonical": true, + "file": "service_attachments.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.ServiceAttachments.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "service_attachment_resource", + "type": ".google.cloud.compute.v1.ServiceAttachment" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ServiceAttachmentsClient", + "fullName": "google.cloud.compute.v1.ServiceAttachmentsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.ServiceAttachments.Insert", + "service": { + "shortName": "ServiceAttachments", + "fullName": "google.cloud.compute.v1.ServiceAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ServiceAttachments_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Lists the ServiceAttachments for a project in the given scope.", + "canonical": true, + "file": "service_attachments.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.ServiceAttachments.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.ServiceAttachmentList", + "client": { + "shortName": "ServiceAttachmentsClient", + "fullName": "google.cloud.compute.v1.ServiceAttachmentsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.ServiceAttachments.List", + "service": { + "shortName": "ServiceAttachments", + "fullName": "google.cloud.compute.v1.ServiceAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ServiceAttachments_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified ServiceAttachment resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.", + "canonical": true, + "file": "service_attachments.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.ServiceAttachments.Patch", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "service_attachment", + "type": "TYPE_STRING" + }, + { + "name": "service_attachment_resource", + "type": ".google.cloud.compute.v1.ServiceAttachment" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ServiceAttachmentsClient", + "fullName": "google.cloud.compute.v1.ServiceAttachmentsClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.ServiceAttachments.Patch", + "service": { + "shortName": "ServiceAttachments", + "fullName": "google.cloud.compute.v1.ServiceAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ServiceAttachments_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "service_attachments.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.ServiceAttachments.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_set_policy_request_resource", + "type": ".google.cloud.compute.v1.RegionSetPolicyRequest" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "ServiceAttachmentsClient", + "fullName": "google.cloud.compute.v1.ServiceAttachmentsClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.ServiceAttachments.SetIamPolicy", + "service": { + "shortName": "ServiceAttachments", + "fullName": "google.cloud.compute.v1.ServiceAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ServiceAttachments_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "service_attachments.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.ServiceAttachments.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "ServiceAttachmentsClient", + "fullName": "google.cloud.compute.v1.ServiceAttachmentsClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.ServiceAttachments.TestIamPermissions", + "service": { + "shortName": "ServiceAttachments", + "fullName": "google.cloud.compute.v1.ServiceAttachments" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Snapshots_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified Snapshot resource. Keep in mind that deleting a single snapshot might not necessarily delete all the data on that snapshot. If any data on the snapshot that is marked for deletion is needed for subsequent snapshots, the data will be moved to the next corresponding snapshot. For more information, see Deleting snapshots.", + "canonical": true, + "file": "snapshots.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Snapshots.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "snapshot", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SnapshotsClient", + "fullName": "google.cloud.compute.v1.SnapshotsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Snapshots.Delete", + "service": { + "shortName": "Snapshots", + "fullName": "google.cloud.compute.v1.Snapshots" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Snapshots_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified Snapshot resource.", + "canonical": true, + "file": "snapshots.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Snapshots.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "snapshot", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Snapshot", + "client": { + "shortName": "SnapshotsClient", + "fullName": "google.cloud.compute.v1.SnapshotsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Snapshots.Get", + "service": { + "shortName": "Snapshots", + "fullName": "google.cloud.compute.v1.Snapshots" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Snapshots_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "snapshots.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.Snapshots.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "SnapshotsClient", + "fullName": "google.cloud.compute.v1.SnapshotsClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.Snapshots.GetIamPolicy", + "service": { + "shortName": "Snapshots", + "fullName": "google.cloud.compute.v1.Snapshots" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Snapshots_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a snapshot in the specified project using the data included in the request. For regular snapshot creation, consider using this method instead of disks.createSnapshot, as this method supports more features, such as creating snapshots in a project different from the source disk project.", + "canonical": true, + "file": "snapshots.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Snapshots.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "snapshot_resource", + "type": ".google.cloud.compute.v1.Snapshot" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SnapshotsClient", + "fullName": "google.cloud.compute.v1.SnapshotsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Snapshots.Insert", + "service": { + "shortName": "Snapshots", + "fullName": "google.cloud.compute.v1.Snapshots" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Snapshots_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of Snapshot resources contained within the specified project.", + "canonical": true, + "file": "snapshots.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Snapshots.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.SnapshotList", + "client": { + "shortName": "SnapshotsClient", + "fullName": "google.cloud.compute.v1.SnapshotsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Snapshots.List", + "service": { + "shortName": "Snapshots", + "fullName": "google.cloud.compute.v1.Snapshots" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Snapshots_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "snapshots.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.Snapshots.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "global_set_policy_request_resource", + "type": ".google.cloud.compute.v1.GlobalSetPolicyRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "SnapshotsClient", + "fullName": "google.cloud.compute.v1.SnapshotsClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.Snapshots.SetIamPolicy", + "service": { + "shortName": "Snapshots", + "fullName": "google.cloud.compute.v1.Snapshots" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Snapshots_SetLabels_async", + "title": "AcceleratorTypes setLabels Sample", + "origin": "API_DEFINITION", + "description": " Sets the labels on a snapshot. To learn more about labels, read the Labeling Resources documentation.", + "canonical": true, + "file": "snapshots.set_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.Snapshots.SetLabels", + "async": true, + "parameters": [ + { + "name": "global_set_labels_request_resource", + "type": ".google.cloud.compute.v1.GlobalSetLabelsRequest" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SnapshotsClient", + "fullName": "google.cloud.compute.v1.SnapshotsClient" + }, + "method": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.Snapshots.SetLabels", + "service": { + "shortName": "Snapshots", + "fullName": "google.cloud.compute.v1.Snapshots" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Snapshots_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "snapshots.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.Snapshots.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "SnapshotsClient", + "fullName": "google.cloud.compute.v1.SnapshotsClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.Snapshots.TestIamPermissions", + "service": { + "shortName": "Snapshots", + "fullName": "google.cloud.compute.v1.Snapshots" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SslCertificates_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of all SslCertificate resources, regional and global, available to the specified project.", + "canonical": true, + "file": "ssl_certificates.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.SslCertificates.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.SslCertificateAggregatedList", + "client": { + "shortName": "SslCertificatesClient", + "fullName": "google.cloud.compute.v1.SslCertificatesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.SslCertificates.AggregatedList", + "service": { + "shortName": "SslCertificates", + "fullName": "google.cloud.compute.v1.SslCertificates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SslCertificates_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified SslCertificate resource.", + "canonical": true, + "file": "ssl_certificates.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.SslCertificates.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "ssl_certificate", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SslCertificatesClient", + "fullName": "google.cloud.compute.v1.SslCertificatesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.SslCertificates.Delete", + "service": { + "shortName": "SslCertificates", + "fullName": "google.cloud.compute.v1.SslCertificates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SslCertificates_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified SslCertificate resource.", + "canonical": true, + "file": "ssl_certificates.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.SslCertificates.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "ssl_certificate", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.SslCertificate", + "client": { + "shortName": "SslCertificatesClient", + "fullName": "google.cloud.compute.v1.SslCertificatesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.SslCertificates.Get", + "service": { + "shortName": "SslCertificates", + "fullName": "google.cloud.compute.v1.SslCertificates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SslCertificates_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a SslCertificate resource in the specified project using the data included in the request.", + "canonical": true, + "file": "ssl_certificates.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.SslCertificates.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "ssl_certificate_resource", + "type": ".google.cloud.compute.v1.SslCertificate" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SslCertificatesClient", + "fullName": "google.cloud.compute.v1.SslCertificatesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.SslCertificates.Insert", + "service": { + "shortName": "SslCertificates", + "fullName": "google.cloud.compute.v1.SslCertificates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SslCertificates_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of SslCertificate resources available to the specified project.", + "canonical": true, + "file": "ssl_certificates.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.SslCertificates.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.SslCertificateList", + "client": { + "shortName": "SslCertificatesClient", + "fullName": "google.cloud.compute.v1.SslCertificatesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.SslCertificates.List", + "service": { + "shortName": "SslCertificates", + "fullName": "google.cloud.compute.v1.SslCertificates" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SslPolicies_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of all SslPolicy resources, regional and global, available to the specified project.", + "canonical": true, + "file": "ssl_policies.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.SslPolicies.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.SslPoliciesAggregatedList", + "client": { + "shortName": "SslPoliciesClient", + "fullName": "google.cloud.compute.v1.SslPoliciesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.SslPolicies.AggregatedList", + "service": { + "shortName": "SslPolicies", + "fullName": "google.cloud.compute.v1.SslPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SslPolicies_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified SSL policy. The SSL policy resource can be deleted only if it is not in use by any TargetHttpsProxy or TargetSslProxy resources.", + "canonical": true, + "file": "ssl_policies.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.SslPolicies.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "ssl_policy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SslPoliciesClient", + "fullName": "google.cloud.compute.v1.SslPoliciesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.SslPolicies.Delete", + "service": { + "shortName": "SslPolicies", + "fullName": "google.cloud.compute.v1.SslPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SslPolicies_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Lists all of the ordered rules present in a single specified policy.", + "canonical": true, + "file": "ssl_policies.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.SslPolicies.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "ssl_policy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.SslPolicy", + "client": { + "shortName": "SslPoliciesClient", + "fullName": "google.cloud.compute.v1.SslPoliciesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.SslPolicies.Get", + "service": { + "shortName": "SslPolicies", + "fullName": "google.cloud.compute.v1.SslPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SslPolicies_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified SSL policy resource.", + "canonical": true, + "file": "ssl_policies.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.SslPolicies.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "ssl_policy_resource", + "type": ".google.cloud.compute.v1.SslPolicy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SslPoliciesClient", + "fullName": "google.cloud.compute.v1.SslPoliciesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.SslPolicies.Insert", + "service": { + "shortName": "SslPolicies", + "fullName": "google.cloud.compute.v1.SslPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SslPolicies_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Lists all the SSL policies that have been configured for the specified project.", + "canonical": true, + "file": "ssl_policies.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.SslPolicies.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.SslPoliciesList", + "client": { + "shortName": "SslPoliciesClient", + "fullName": "google.cloud.compute.v1.SslPoliciesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.SslPolicies.List", + "service": { + "shortName": "SslPolicies", + "fullName": "google.cloud.compute.v1.SslPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SslPolicies_ListAvailableFeatures_async", + "title": "AcceleratorTypes listAvailableFeatures Sample", + "origin": "API_DEFINITION", + "description": " Lists all features that can be specified in the SSL policy when using custom profile.", + "canonical": true, + "file": "ssl_policies.list_available_features.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListAvailableFeatures", + "fullName": "google.cloud.compute.v1.SslPolicies.ListAvailableFeatures", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.SslPoliciesListAvailableFeaturesResponse", + "client": { + "shortName": "SslPoliciesClient", + "fullName": "google.cloud.compute.v1.SslPoliciesClient" + }, + "method": { + "shortName": "ListAvailableFeatures", + "fullName": "google.cloud.compute.v1.SslPolicies.ListAvailableFeatures", + "service": { + "shortName": "SslPolicies", + "fullName": "google.cloud.compute.v1.SslPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_SslPolicies_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified SSL policy with the data included in the request.", + "canonical": true, + "file": "ssl_policies.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.SslPolicies.Patch", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "ssl_policy", + "type": "TYPE_STRING" + }, + { + "name": "ssl_policy_resource", + "type": ".google.cloud.compute.v1.SslPolicy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SslPoliciesClient", + "fullName": "google.cloud.compute.v1.SslPoliciesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.SslPolicies.Patch", + "service": { + "shortName": "SslPolicies", + "fullName": "google.cloud.compute.v1.SslPolicies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Subnetworks_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of subnetworks.", + "canonical": true, + "file": "subnetworks.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.Subnetworks.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.SubnetworkAggregatedList", + "client": { + "shortName": "SubnetworksClient", + "fullName": "google.cloud.compute.v1.SubnetworksClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.Subnetworks.AggregatedList", + "service": { + "shortName": "Subnetworks", + "fullName": "google.cloud.compute.v1.Subnetworks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Subnetworks_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified subnetwork.", + "canonical": true, + "file": "subnetworks.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Subnetworks.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "subnetwork", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SubnetworksClient", + "fullName": "google.cloud.compute.v1.SubnetworksClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.Subnetworks.Delete", + "service": { + "shortName": "Subnetworks", + "fullName": "google.cloud.compute.v1.Subnetworks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Subnetworks_ExpandIpCidrRange_async", + "title": "AcceleratorTypes expandIpCidrRange Sample", + "origin": "API_DEFINITION", + "description": " Expands the IP CIDR range of the subnetwork to a specified value.", + "canonical": true, + "file": "subnetworks.expand_ip_cidr_range.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ExpandIpCidrRange", + "fullName": "google.cloud.compute.v1.Subnetworks.ExpandIpCidrRange", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "subnetwork", + "type": "TYPE_STRING" + }, + { + "name": "subnetworks_expand_ip_cidr_range_request_resource", + "type": ".google.cloud.compute.v1.SubnetworksExpandIpCidrRangeRequest" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SubnetworksClient", + "fullName": "google.cloud.compute.v1.SubnetworksClient" + }, + "method": { + "shortName": "ExpandIpCidrRange", + "fullName": "google.cloud.compute.v1.Subnetworks.ExpandIpCidrRange", + "service": { + "shortName": "Subnetworks", + "fullName": "google.cloud.compute.v1.Subnetworks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Subnetworks_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified subnetwork.", + "canonical": true, + "file": "subnetworks.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Subnetworks.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "subnetwork", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Subnetwork", + "client": { + "shortName": "SubnetworksClient", + "fullName": "google.cloud.compute.v1.SubnetworksClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Subnetworks.Get", + "service": { + "shortName": "Subnetworks", + "fullName": "google.cloud.compute.v1.Subnetworks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Subnetworks_GetIamPolicy_async", + "title": "AcceleratorTypes getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. May be empty if no such policy or resource exists.", + "canonical": true, + "file": "subnetworks.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.Subnetworks.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "options_requested_policy_version", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "SubnetworksClient", + "fullName": "google.cloud.compute.v1.SubnetworksClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.compute.v1.Subnetworks.GetIamPolicy", + "service": { + "shortName": "Subnetworks", + "fullName": "google.cloud.compute.v1.Subnetworks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Subnetworks_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a subnetwork in the specified project using the data included in the request.", + "canonical": true, + "file": "subnetworks.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Subnetworks.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "subnetwork_resource", + "type": ".google.cloud.compute.v1.Subnetwork" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SubnetworksClient", + "fullName": "google.cloud.compute.v1.SubnetworksClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.Subnetworks.Insert", + "service": { + "shortName": "Subnetworks", + "fullName": "google.cloud.compute.v1.Subnetworks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Subnetworks_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of subnetworks available to the specified project.", + "canonical": true, + "file": "subnetworks.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Subnetworks.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.SubnetworkList", + "client": { + "shortName": "SubnetworksClient", + "fullName": "google.cloud.compute.v1.SubnetworksClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Subnetworks.List", + "service": { + "shortName": "Subnetworks", + "fullName": "google.cloud.compute.v1.Subnetworks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Subnetworks_ListUsable_async", + "title": "AcceleratorTypes listUsable Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of all usable subnetworks in the project.", + "canonical": true, + "file": "subnetworks.list_usable.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListUsable", + "fullName": "google.cloud.compute.v1.Subnetworks.ListUsable", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.UsableSubnetworksAggregatedList", + "client": { + "shortName": "SubnetworksClient", + "fullName": "google.cloud.compute.v1.SubnetworksClient" + }, + "method": { + "shortName": "ListUsable", + "fullName": "google.cloud.compute.v1.Subnetworks.ListUsable", + "service": { + "shortName": "Subnetworks", + "fullName": "google.cloud.compute.v1.Subnetworks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Subnetworks_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified subnetwork with the data included in the request. Only certain fields can be updated with a patch request as indicated in the field descriptions. You must specify the current fingerprint of the subnetwork resource being patched.", + "canonical": true, + "file": "subnetworks.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 76, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.Subnetworks.Patch", + "async": true, + "parameters": [ + { + "name": "drain_timeout_seconds", + "type": "TYPE_INT32" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "subnetwork", + "type": "TYPE_STRING" + }, + { + "name": "subnetwork_resource", + "type": ".google.cloud.compute.v1.Subnetwork" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SubnetworksClient", + "fullName": "google.cloud.compute.v1.SubnetworksClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.Subnetworks.Patch", + "service": { + "shortName": "Subnetworks", + "fullName": "google.cloud.compute.v1.Subnetworks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Subnetworks_SetIamPolicy_async", + "title": "AcceleratorTypes setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "subnetworks.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.Subnetworks.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_set_policy_request_resource", + "type": ".google.cloud.compute.v1.RegionSetPolicyRequest" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Policy", + "client": { + "shortName": "SubnetworksClient", + "fullName": "google.cloud.compute.v1.SubnetworksClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.compute.v1.Subnetworks.SetIamPolicy", + "service": { + "shortName": "Subnetworks", + "fullName": "google.cloud.compute.v1.Subnetworks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Subnetworks_SetPrivateIpGoogleAccess_async", + "title": "AcceleratorTypes setPrivateIpGoogleAccess Sample", + "origin": "API_DEFINITION", + "description": " Set whether VMs in this subnet can access Google services without assigning external IP addresses through Private Google Access.", + "canonical": true, + "file": "subnetworks.set_private_ip_google_access.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetPrivateIpGoogleAccess", + "fullName": "google.cloud.compute.v1.Subnetworks.SetPrivateIpGoogleAccess", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "subnetwork", + "type": "TYPE_STRING" + }, + { + "name": "subnetworks_set_private_ip_google_access_request_resource", + "type": ".google.cloud.compute.v1.SubnetworksSetPrivateIpGoogleAccessRequest" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "SubnetworksClient", + "fullName": "google.cloud.compute.v1.SubnetworksClient" + }, + "method": { + "shortName": "SetPrivateIpGoogleAccess", + "fullName": "google.cloud.compute.v1.Subnetworks.SetPrivateIpGoogleAccess", + "service": { + "shortName": "Subnetworks", + "fullName": "google.cloud.compute.v1.Subnetworks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Subnetworks_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "subnetworks.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.Subnetworks.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "SubnetworksClient", + "fullName": "google.cloud.compute.v1.SubnetworksClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.Subnetworks.TestIamPermissions", + "service": { + "shortName": "Subnetworks", + "fullName": "google.cloud.compute.v1.Subnetworks" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetGrpcProxies_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified TargetGrpcProxy in the given scope", + "canonical": true, + "file": "target_grpc_proxies.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.TargetGrpcProxies.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_grpc_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetGrpcProxiesClient", + "fullName": "google.cloud.compute.v1.TargetGrpcProxiesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.TargetGrpcProxies.Delete", + "service": { + "shortName": "TargetGrpcProxies", + "fullName": "google.cloud.compute.v1.TargetGrpcProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetGrpcProxies_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified TargetGrpcProxy resource in the given scope.", + "canonical": true, + "file": "target_grpc_proxies.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.TargetGrpcProxies.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "target_grpc_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TargetGrpcProxy", + "client": { + "shortName": "TargetGrpcProxiesClient", + "fullName": "google.cloud.compute.v1.TargetGrpcProxiesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.TargetGrpcProxies.Get", + "service": { + "shortName": "TargetGrpcProxies", + "fullName": "google.cloud.compute.v1.TargetGrpcProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetGrpcProxies_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a TargetGrpcProxy in the specified project in the given scope using the parameters that are included in the request.", + "canonical": true, + "file": "target_grpc_proxies.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.TargetGrpcProxies.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_grpc_proxy_resource", + "type": ".google.cloud.compute.v1.TargetGrpcProxy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetGrpcProxiesClient", + "fullName": "google.cloud.compute.v1.TargetGrpcProxiesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.TargetGrpcProxies.Insert", + "service": { + "shortName": "TargetGrpcProxies", + "fullName": "google.cloud.compute.v1.TargetGrpcProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetGrpcProxies_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Lists the TargetGrpcProxies for a project in the given scope.", + "canonical": true, + "file": "target_grpc_proxies.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.TargetGrpcProxies.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.TargetGrpcProxyList", + "client": { + "shortName": "TargetGrpcProxiesClient", + "fullName": "google.cloud.compute.v1.TargetGrpcProxiesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.TargetGrpcProxies.List", + "service": { + "shortName": "TargetGrpcProxies", + "fullName": "google.cloud.compute.v1.TargetGrpcProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetGrpcProxies_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified TargetGrpcProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.", + "canonical": true, + "file": "target_grpc_proxies.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.TargetGrpcProxies.Patch", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_grpc_proxy", + "type": "TYPE_STRING" + }, + { + "name": "target_grpc_proxy_resource", + "type": ".google.cloud.compute.v1.TargetGrpcProxy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetGrpcProxiesClient", + "fullName": "google.cloud.compute.v1.TargetGrpcProxiesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.TargetGrpcProxies.Patch", + "service": { + "shortName": "TargetGrpcProxies", + "fullName": "google.cloud.compute.v1.TargetGrpcProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpProxies_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of all TargetHttpProxy resources, regional and global, available to the specified project.", + "canonical": true, + "file": "target_http_proxies.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.TargetHttpProxies.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.TargetHttpProxyAggregatedList", + "client": { + "shortName": "TargetHttpProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpProxiesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.TargetHttpProxies.AggregatedList", + "service": { + "shortName": "TargetHttpProxies", + "fullName": "google.cloud.compute.v1.TargetHttpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpProxies_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified TargetHttpProxy resource.", + "canonical": true, + "file": "target_http_proxies.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.TargetHttpProxies.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_http_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetHttpProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpProxiesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.TargetHttpProxies.Delete", + "service": { + "shortName": "TargetHttpProxies", + "fullName": "google.cloud.compute.v1.TargetHttpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpProxies_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified TargetHttpProxy resource.", + "canonical": true, + "file": "target_http_proxies.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.TargetHttpProxies.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "target_http_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TargetHttpProxy", + "client": { + "shortName": "TargetHttpProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpProxiesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.TargetHttpProxies.Get", + "service": { + "shortName": "TargetHttpProxies", + "fullName": "google.cloud.compute.v1.TargetHttpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpProxies_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a TargetHttpProxy resource in the specified project using the data included in the request.", + "canonical": true, + "file": "target_http_proxies.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.TargetHttpProxies.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_http_proxy_resource", + "type": ".google.cloud.compute.v1.TargetHttpProxy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetHttpProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpProxiesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.TargetHttpProxies.Insert", + "service": { + "shortName": "TargetHttpProxies", + "fullName": "google.cloud.compute.v1.TargetHttpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpProxies_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of TargetHttpProxy resources available to the specified project.", + "canonical": true, + "file": "target_http_proxies.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.TargetHttpProxies.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.TargetHttpProxyList", + "client": { + "shortName": "TargetHttpProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpProxiesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.TargetHttpProxies.List", + "service": { + "shortName": "TargetHttpProxies", + "fullName": "google.cloud.compute.v1.TargetHttpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpProxies_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified TargetHttpProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.", + "canonical": true, + "file": "target_http_proxies.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.TargetHttpProxies.Patch", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_http_proxy", + "type": "TYPE_STRING" + }, + { + "name": "target_http_proxy_resource", + "type": ".google.cloud.compute.v1.TargetHttpProxy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetHttpProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpProxiesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.TargetHttpProxies.Patch", + "service": { + "shortName": "TargetHttpProxies", + "fullName": "google.cloud.compute.v1.TargetHttpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpProxies_SetUrlMap_async", + "title": "AcceleratorTypes setUrlMap Sample", + "origin": "API_DEFINITION", + "description": " Changes the URL map for TargetHttpProxy.", + "canonical": true, + "file": "target_http_proxies.set_url_map.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetUrlMap", + "fullName": "google.cloud.compute.v1.TargetHttpProxies.SetUrlMap", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_http_proxy", + "type": "TYPE_STRING" + }, + { + "name": "url_map_reference_resource", + "type": ".google.cloud.compute.v1.UrlMapReference" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetHttpProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpProxiesClient" + }, + "method": { + "shortName": "SetUrlMap", + "fullName": "google.cloud.compute.v1.TargetHttpProxies.SetUrlMap", + "service": { + "shortName": "TargetHttpProxies", + "fullName": "google.cloud.compute.v1.TargetHttpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpsProxies_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of all TargetHttpsProxy resources, regional and global, available to the specified project.", + "canonical": true, + "file": "target_https_proxies.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.TargetHttpsProxyAggregatedList", + "client": { + "shortName": "TargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpsProxiesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.AggregatedList", + "service": { + "shortName": "TargetHttpsProxies", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpsProxies_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified TargetHttpsProxy resource.", + "canonical": true, + "file": "target_https_proxies.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_https_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpsProxiesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.Delete", + "service": { + "shortName": "TargetHttpsProxies", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpsProxies_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified TargetHttpsProxy resource.", + "canonical": true, + "file": "target_https_proxies.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "target_https_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TargetHttpsProxy", + "client": { + "shortName": "TargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpsProxiesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.Get", + "service": { + "shortName": "TargetHttpsProxies", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpsProxies_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a TargetHttpsProxy resource in the specified project using the data included in the request.", + "canonical": true, + "file": "target_https_proxies.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_https_proxy_resource", + "type": ".google.cloud.compute.v1.TargetHttpsProxy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpsProxiesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.Insert", + "service": { + "shortName": "TargetHttpsProxies", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpsProxies_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of TargetHttpsProxy resources available to the specified project.", + "canonical": true, + "file": "target_https_proxies.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.TargetHttpsProxyList", + "client": { + "shortName": "TargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpsProxiesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.List", + "service": { + "shortName": "TargetHttpsProxies", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpsProxies_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified TargetHttpsProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.", + "canonical": true, + "file": "target_https_proxies.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.Patch", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_https_proxy", + "type": "TYPE_STRING" + }, + { + "name": "target_https_proxy_resource", + "type": ".google.cloud.compute.v1.TargetHttpsProxy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpsProxiesClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.Patch", + "service": { + "shortName": "TargetHttpsProxies", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpsProxies_SetCertificateMap_async", + "title": "AcceleratorTypes setCertificateMap Sample", + "origin": "API_DEFINITION", + "description": " Changes the Certificate Map for TargetHttpsProxy.", + "canonical": true, + "file": "target_https_proxies.set_certificate_map.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetCertificateMap", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.SetCertificateMap", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_https_proxies_set_certificate_map_request_resource", + "type": ".google.cloud.compute.v1.TargetHttpsProxiesSetCertificateMapRequest" + }, + { + "name": "target_https_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpsProxiesClient" + }, + "method": { + "shortName": "SetCertificateMap", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.SetCertificateMap", + "service": { + "shortName": "TargetHttpsProxies", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpsProxies_SetQuicOverride_async", + "title": "AcceleratorTypes setQuicOverride Sample", + "origin": "API_DEFINITION", + "description": " Sets the QUIC override policy for TargetHttpsProxy.", + "canonical": true, + "file": "target_https_proxies.set_quic_override.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetQuicOverride", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.SetQuicOverride", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_https_proxies_set_quic_override_request_resource", + "type": ".google.cloud.compute.v1.TargetHttpsProxiesSetQuicOverrideRequest" + }, + { + "name": "target_https_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpsProxiesClient" + }, + "method": { + "shortName": "SetQuicOverride", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.SetQuicOverride", + "service": { + "shortName": "TargetHttpsProxies", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpsProxies_SetSslCertificates_async", + "title": "AcceleratorTypes setSslCertificates Sample", + "origin": "API_DEFINITION", + "description": " Replaces SslCertificates for TargetHttpsProxy.", + "canonical": true, + "file": "target_https_proxies.set_ssl_certificates.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetSslCertificates", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.SetSslCertificates", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_https_proxies_set_ssl_certificates_request_resource", + "type": ".google.cloud.compute.v1.TargetHttpsProxiesSetSslCertificatesRequest" + }, + { + "name": "target_https_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpsProxiesClient" + }, + "method": { + "shortName": "SetSslCertificates", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.SetSslCertificates", + "service": { + "shortName": "TargetHttpsProxies", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpsProxies_SetSslPolicy_async", + "title": "AcceleratorTypes setSslPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the SSL policy for TargetHttpsProxy. The SSL policy specifies the server-side support for SSL features. This affects connections between clients and the HTTPS proxy load balancer. They do not affect the connection between the load balancer and the backends.", + "canonical": true, + "file": "target_https_proxies.set_ssl_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetSslPolicy", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.SetSslPolicy", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "ssl_policy_reference_resource", + "type": ".google.cloud.compute.v1.SslPolicyReference" + }, + { + "name": "target_https_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpsProxiesClient" + }, + "method": { + "shortName": "SetSslPolicy", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.SetSslPolicy", + "service": { + "shortName": "TargetHttpsProxies", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetHttpsProxies_SetUrlMap_async", + "title": "AcceleratorTypes setUrlMap Sample", + "origin": "API_DEFINITION", + "description": " Changes the URL map for TargetHttpsProxy.", + "canonical": true, + "file": "target_https_proxies.set_url_map.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetUrlMap", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.SetUrlMap", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_https_proxy", + "type": "TYPE_STRING" + }, + { + "name": "url_map_reference_resource", + "type": ".google.cloud.compute.v1.UrlMapReference" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetHttpsProxiesClient", + "fullName": "google.cloud.compute.v1.TargetHttpsProxiesClient" + }, + "method": { + "shortName": "SetUrlMap", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies.SetUrlMap", + "service": { + "shortName": "TargetHttpsProxies", + "fullName": "google.cloud.compute.v1.TargetHttpsProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetInstances_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of target instances.", + "canonical": true, + "file": "target_instances.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.TargetInstances.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.TargetInstanceAggregatedList", + "client": { + "shortName": "TargetInstancesClient", + "fullName": "google.cloud.compute.v1.TargetInstancesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.TargetInstances.AggregatedList", + "service": { + "shortName": "TargetInstances", + "fullName": "google.cloud.compute.v1.TargetInstances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetInstances_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified TargetInstance resource.", + "canonical": true, + "file": "target_instances.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.TargetInstances.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_instance", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetInstancesClient", + "fullName": "google.cloud.compute.v1.TargetInstancesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.TargetInstances.Delete", + "service": { + "shortName": "TargetInstances", + "fullName": "google.cloud.compute.v1.TargetInstances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetInstances_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified TargetInstance resource.", + "canonical": true, + "file": "target_instances.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.TargetInstances.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "target_instance", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TargetInstance", + "client": { + "shortName": "TargetInstancesClient", + "fullName": "google.cloud.compute.v1.TargetInstancesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.TargetInstances.Get", + "service": { + "shortName": "TargetInstances", + "fullName": "google.cloud.compute.v1.TargetInstances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetInstances_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a TargetInstance resource in the specified project and zone using the data included in the request.", + "canonical": true, + "file": "target_instances.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.TargetInstances.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_instance_resource", + "type": ".google.cloud.compute.v1.TargetInstance" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetInstancesClient", + "fullName": "google.cloud.compute.v1.TargetInstancesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.TargetInstances.Insert", + "service": { + "shortName": "TargetInstances", + "fullName": "google.cloud.compute.v1.TargetInstances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetInstances_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of TargetInstance resources available to the specified project and zone.", + "canonical": true, + "file": "target_instances.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.TargetInstances.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TargetInstanceList", + "client": { + "shortName": "TargetInstancesClient", + "fullName": "google.cloud.compute.v1.TargetInstancesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.TargetInstances.List", + "service": { + "shortName": "TargetInstances", + "fullName": "google.cloud.compute.v1.TargetInstances" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetPools_AddHealthCheck_async", + "title": "AcceleratorTypes addHealthCheck Sample", + "origin": "API_DEFINITION", + "description": " Adds health check URLs to a target pool.", + "canonical": true, + "file": "target_pools.add_health_check.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddHealthCheck", + "fullName": "google.cloud.compute.v1.TargetPools.AddHealthCheck", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_pool", + "type": "TYPE_STRING" + }, + { + "name": "target_pools_add_health_check_request_resource", + "type": ".google.cloud.compute.v1.TargetPoolsAddHealthCheckRequest" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetPoolsClient", + "fullName": "google.cloud.compute.v1.TargetPoolsClient" + }, + "method": { + "shortName": "AddHealthCheck", + "fullName": "google.cloud.compute.v1.TargetPools.AddHealthCheck", + "service": { + "shortName": "TargetPools", + "fullName": "google.cloud.compute.v1.TargetPools" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetPools_AddInstance_async", + "title": "AcceleratorTypes addInstance Sample", + "origin": "API_DEFINITION", + "description": " Adds an instance to a target pool.", + "canonical": true, + "file": "target_pools.add_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddInstance", + "fullName": "google.cloud.compute.v1.TargetPools.AddInstance", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_pool", + "type": "TYPE_STRING" + }, + { + "name": "target_pools_add_instance_request_resource", + "type": ".google.cloud.compute.v1.TargetPoolsAddInstanceRequest" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetPoolsClient", + "fullName": "google.cloud.compute.v1.TargetPoolsClient" + }, + "method": { + "shortName": "AddInstance", + "fullName": "google.cloud.compute.v1.TargetPools.AddInstance", + "service": { + "shortName": "TargetPools", + "fullName": "google.cloud.compute.v1.TargetPools" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetPools_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of target pools.", + "canonical": true, + "file": "target_pools.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.TargetPools.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.TargetPoolAggregatedList", + "client": { + "shortName": "TargetPoolsClient", + "fullName": "google.cloud.compute.v1.TargetPoolsClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.TargetPools.AggregatedList", + "service": { + "shortName": "TargetPools", + "fullName": "google.cloud.compute.v1.TargetPools" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetPools_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified target pool.", + "canonical": true, + "file": "target_pools.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.TargetPools.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_pool", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetPoolsClient", + "fullName": "google.cloud.compute.v1.TargetPoolsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.TargetPools.Delete", + "service": { + "shortName": "TargetPools", + "fullName": "google.cloud.compute.v1.TargetPools" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetPools_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified target pool.", + "canonical": true, + "file": "target_pools.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.TargetPools.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "target_pool", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TargetPool", + "client": { + "shortName": "TargetPoolsClient", + "fullName": "google.cloud.compute.v1.TargetPoolsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.TargetPools.Get", + "service": { + "shortName": "TargetPools", + "fullName": "google.cloud.compute.v1.TargetPools" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetPools_GetHealth_async", + "title": "AcceleratorTypes getHealth Sample", + "origin": "API_DEFINITION", + "description": " Gets the most recent health check results for each IP for the instance that is referenced by the given target pool.", + "canonical": true, + "file": "target_pools.get_health.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetHealth", + "fullName": "google.cloud.compute.v1.TargetPools.GetHealth", + "async": true, + "parameters": [ + { + "name": "instance_reference_resource", + "type": ".google.cloud.compute.v1.InstanceReference" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "target_pool", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TargetPoolInstanceHealth", + "client": { + "shortName": "TargetPoolsClient", + "fullName": "google.cloud.compute.v1.TargetPoolsClient" + }, + "method": { + "shortName": "GetHealth", + "fullName": "google.cloud.compute.v1.TargetPools.GetHealth", + "service": { + "shortName": "TargetPools", + "fullName": "google.cloud.compute.v1.TargetPools" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetPools_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a target pool in the specified project and region using the data included in the request.", + "canonical": true, + "file": "target_pools.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.TargetPools.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_pool_resource", + "type": ".google.cloud.compute.v1.TargetPool" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetPoolsClient", + "fullName": "google.cloud.compute.v1.TargetPoolsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.TargetPools.Insert", + "service": { + "shortName": "TargetPools", + "fullName": "google.cloud.compute.v1.TargetPools" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetPools_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of target pools available to the specified project and region.", + "canonical": true, + "file": "target_pools.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.TargetPools.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.TargetPoolList", + "client": { + "shortName": "TargetPoolsClient", + "fullName": "google.cloud.compute.v1.TargetPoolsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.TargetPools.List", + "service": { + "shortName": "TargetPools", + "fullName": "google.cloud.compute.v1.TargetPools" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetPools_RemoveHealthCheck_async", + "title": "AcceleratorTypes removeHealthCheck Sample", + "origin": "API_DEFINITION", + "description": " Removes health check URL from a target pool.", + "canonical": true, + "file": "target_pools.remove_health_check.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveHealthCheck", + "fullName": "google.cloud.compute.v1.TargetPools.RemoveHealthCheck", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_pool", + "type": "TYPE_STRING" + }, + { + "name": "target_pools_remove_health_check_request_resource", + "type": ".google.cloud.compute.v1.TargetPoolsRemoveHealthCheckRequest" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetPoolsClient", + "fullName": "google.cloud.compute.v1.TargetPoolsClient" + }, + "method": { + "shortName": "RemoveHealthCheck", + "fullName": "google.cloud.compute.v1.TargetPools.RemoveHealthCheck", + "service": { + "shortName": "TargetPools", + "fullName": "google.cloud.compute.v1.TargetPools" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetPools_RemoveInstance_async", + "title": "AcceleratorTypes removeInstance Sample", + "origin": "API_DEFINITION", + "description": " Removes instance URL from a target pool.", + "canonical": true, + "file": "target_pools.remove_instance.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveInstance", + "fullName": "google.cloud.compute.v1.TargetPools.RemoveInstance", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_pool", + "type": "TYPE_STRING" + }, + { + "name": "target_pools_remove_instance_request_resource", + "type": ".google.cloud.compute.v1.TargetPoolsRemoveInstanceRequest" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetPoolsClient", + "fullName": "google.cloud.compute.v1.TargetPoolsClient" + }, + "method": { + "shortName": "RemoveInstance", + "fullName": "google.cloud.compute.v1.TargetPools.RemoveInstance", + "service": { + "shortName": "TargetPools", + "fullName": "google.cloud.compute.v1.TargetPools" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetPools_SetBackup_async", + "title": "AcceleratorTypes setBackup Sample", + "origin": "API_DEFINITION", + "description": " Changes a backup target pool's configurations.", + "canonical": true, + "file": "target_pools.set_backup.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 76, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetBackup", + "fullName": "google.cloud.compute.v1.TargetPools.SetBackup", + "async": true, + "parameters": [ + { + "name": "failover_ratio", + "type": "TYPE_FLOAT" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_pool", + "type": "TYPE_STRING" + }, + { + "name": "target_reference_resource", + "type": ".google.cloud.compute.v1.TargetReference" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetPoolsClient", + "fullName": "google.cloud.compute.v1.TargetPoolsClient" + }, + "method": { + "shortName": "SetBackup", + "fullName": "google.cloud.compute.v1.TargetPools.SetBackup", + "service": { + "shortName": "TargetPools", + "fullName": "google.cloud.compute.v1.TargetPools" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetSslProxies_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified TargetSslProxy resource.", + "canonical": true, + "file": "target_ssl_proxies.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.TargetSslProxies.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_ssl_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetSslProxiesClient", + "fullName": "google.cloud.compute.v1.TargetSslProxiesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.TargetSslProxies.Delete", + "service": { + "shortName": "TargetSslProxies", + "fullName": "google.cloud.compute.v1.TargetSslProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetSslProxies_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified TargetSslProxy resource.", + "canonical": true, + "file": "target_ssl_proxies.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.TargetSslProxies.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "target_ssl_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TargetSslProxy", + "client": { + "shortName": "TargetSslProxiesClient", + "fullName": "google.cloud.compute.v1.TargetSslProxiesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.TargetSslProxies.Get", + "service": { + "shortName": "TargetSslProxies", + "fullName": "google.cloud.compute.v1.TargetSslProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetSslProxies_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a TargetSslProxy resource in the specified project using the data included in the request.", + "canonical": true, + "file": "target_ssl_proxies.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.TargetSslProxies.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_ssl_proxy_resource", + "type": ".google.cloud.compute.v1.TargetSslProxy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetSslProxiesClient", + "fullName": "google.cloud.compute.v1.TargetSslProxiesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.TargetSslProxies.Insert", + "service": { + "shortName": "TargetSslProxies", + "fullName": "google.cloud.compute.v1.TargetSslProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetSslProxies_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of TargetSslProxy resources available to the specified project.", + "canonical": true, + "file": "target_ssl_proxies.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.TargetSslProxies.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.TargetSslProxyList", + "client": { + "shortName": "TargetSslProxiesClient", + "fullName": "google.cloud.compute.v1.TargetSslProxiesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.TargetSslProxies.List", + "service": { + "shortName": "TargetSslProxies", + "fullName": "google.cloud.compute.v1.TargetSslProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetSslProxies_SetBackendService_async", + "title": "AcceleratorTypes setBackendService Sample", + "origin": "API_DEFINITION", + "description": " Changes the BackendService for TargetSslProxy.", + "canonical": true, + "file": "target_ssl_proxies.set_backend_service.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetBackendService", + "fullName": "google.cloud.compute.v1.TargetSslProxies.SetBackendService", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_ssl_proxies_set_backend_service_request_resource", + "type": ".google.cloud.compute.v1.TargetSslProxiesSetBackendServiceRequest" + }, + { + "name": "target_ssl_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetSslProxiesClient", + "fullName": "google.cloud.compute.v1.TargetSslProxiesClient" + }, + "method": { + "shortName": "SetBackendService", + "fullName": "google.cloud.compute.v1.TargetSslProxies.SetBackendService", + "service": { + "shortName": "TargetSslProxies", + "fullName": "google.cloud.compute.v1.TargetSslProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetSslProxies_SetCertificateMap_async", + "title": "AcceleratorTypes setCertificateMap Sample", + "origin": "API_DEFINITION", + "description": " Changes the Certificate Map for TargetSslProxy.", + "canonical": true, + "file": "target_ssl_proxies.set_certificate_map.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetCertificateMap", + "fullName": "google.cloud.compute.v1.TargetSslProxies.SetCertificateMap", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_ssl_proxies_set_certificate_map_request_resource", + "type": ".google.cloud.compute.v1.TargetSslProxiesSetCertificateMapRequest" + }, + { + "name": "target_ssl_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetSslProxiesClient", + "fullName": "google.cloud.compute.v1.TargetSslProxiesClient" + }, + "method": { + "shortName": "SetCertificateMap", + "fullName": "google.cloud.compute.v1.TargetSslProxies.SetCertificateMap", + "service": { + "shortName": "TargetSslProxies", + "fullName": "google.cloud.compute.v1.TargetSslProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetSslProxies_SetProxyHeader_async", + "title": "AcceleratorTypes setProxyHeader Sample", + "origin": "API_DEFINITION", + "description": " Changes the ProxyHeaderType for TargetSslProxy.", + "canonical": true, + "file": "target_ssl_proxies.set_proxy_header.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetProxyHeader", + "fullName": "google.cloud.compute.v1.TargetSslProxies.SetProxyHeader", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_ssl_proxies_set_proxy_header_request_resource", + "type": ".google.cloud.compute.v1.TargetSslProxiesSetProxyHeaderRequest" + }, + { + "name": "target_ssl_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetSslProxiesClient", + "fullName": "google.cloud.compute.v1.TargetSslProxiesClient" + }, + "method": { + "shortName": "SetProxyHeader", + "fullName": "google.cloud.compute.v1.TargetSslProxies.SetProxyHeader", + "service": { + "shortName": "TargetSslProxies", + "fullName": "google.cloud.compute.v1.TargetSslProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetSslProxies_SetSslCertificates_async", + "title": "AcceleratorTypes setSslCertificates Sample", + "origin": "API_DEFINITION", + "description": " Changes SslCertificates for TargetSslProxy.", + "canonical": true, + "file": "target_ssl_proxies.set_ssl_certificates.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetSslCertificates", + "fullName": "google.cloud.compute.v1.TargetSslProxies.SetSslCertificates", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_ssl_proxies_set_ssl_certificates_request_resource", + "type": ".google.cloud.compute.v1.TargetSslProxiesSetSslCertificatesRequest" + }, + { + "name": "target_ssl_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetSslProxiesClient", + "fullName": "google.cloud.compute.v1.TargetSslProxiesClient" + }, + "method": { + "shortName": "SetSslCertificates", + "fullName": "google.cloud.compute.v1.TargetSslProxies.SetSslCertificates", + "service": { + "shortName": "TargetSslProxies", + "fullName": "google.cloud.compute.v1.TargetSslProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetSslProxies_SetSslPolicy_async", + "title": "AcceleratorTypes setSslPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the SSL policy for TargetSslProxy. The SSL policy specifies the server-side support for SSL features. This affects connections between clients and the SSL proxy load balancer. They do not affect the connection between the load balancer and the backends.", + "canonical": true, + "file": "target_ssl_proxies.set_ssl_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetSslPolicy", + "fullName": "google.cloud.compute.v1.TargetSslProxies.SetSslPolicy", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "ssl_policy_reference_resource", + "type": ".google.cloud.compute.v1.SslPolicyReference" + }, + { + "name": "target_ssl_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetSslProxiesClient", + "fullName": "google.cloud.compute.v1.TargetSslProxiesClient" + }, + "method": { + "shortName": "SetSslPolicy", + "fullName": "google.cloud.compute.v1.TargetSslProxies.SetSslPolicy", + "service": { + "shortName": "TargetSslProxies", + "fullName": "google.cloud.compute.v1.TargetSslProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetTcpProxies_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of all TargetTcpProxy resources, regional and global, available to the specified project.", + "canonical": true, + "file": "target_tcp_proxies.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.TargetTcpProxies.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.TargetTcpProxyAggregatedList", + "client": { + "shortName": "TargetTcpProxiesClient", + "fullName": "google.cloud.compute.v1.TargetTcpProxiesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.TargetTcpProxies.AggregatedList", + "service": { + "shortName": "TargetTcpProxies", + "fullName": "google.cloud.compute.v1.TargetTcpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetTcpProxies_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified TargetTcpProxy resource.", + "canonical": true, + "file": "target_tcp_proxies.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.TargetTcpProxies.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_tcp_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetTcpProxiesClient", + "fullName": "google.cloud.compute.v1.TargetTcpProxiesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.TargetTcpProxies.Delete", + "service": { + "shortName": "TargetTcpProxies", + "fullName": "google.cloud.compute.v1.TargetTcpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetTcpProxies_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified TargetTcpProxy resource.", + "canonical": true, + "file": "target_tcp_proxies.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.TargetTcpProxies.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "target_tcp_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TargetTcpProxy", + "client": { + "shortName": "TargetTcpProxiesClient", + "fullName": "google.cloud.compute.v1.TargetTcpProxiesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.TargetTcpProxies.Get", + "service": { + "shortName": "TargetTcpProxies", + "fullName": "google.cloud.compute.v1.TargetTcpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetTcpProxies_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a TargetTcpProxy resource in the specified project using the data included in the request.", + "canonical": true, + "file": "target_tcp_proxies.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.TargetTcpProxies.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_tcp_proxy_resource", + "type": ".google.cloud.compute.v1.TargetTcpProxy" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetTcpProxiesClient", + "fullName": "google.cloud.compute.v1.TargetTcpProxiesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.TargetTcpProxies.Insert", + "service": { + "shortName": "TargetTcpProxies", + "fullName": "google.cloud.compute.v1.TargetTcpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetTcpProxies_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of TargetTcpProxy resources available to the specified project.", + "canonical": true, + "file": "target_tcp_proxies.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.TargetTcpProxies.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.TargetTcpProxyList", + "client": { + "shortName": "TargetTcpProxiesClient", + "fullName": "google.cloud.compute.v1.TargetTcpProxiesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.TargetTcpProxies.List", + "service": { + "shortName": "TargetTcpProxies", + "fullName": "google.cloud.compute.v1.TargetTcpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetTcpProxies_SetBackendService_async", + "title": "AcceleratorTypes setBackendService Sample", + "origin": "API_DEFINITION", + "description": " Changes the BackendService for TargetTcpProxy.", + "canonical": true, + "file": "target_tcp_proxies.set_backend_service.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetBackendService", + "fullName": "google.cloud.compute.v1.TargetTcpProxies.SetBackendService", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_tcp_proxies_set_backend_service_request_resource", + "type": ".google.cloud.compute.v1.TargetTcpProxiesSetBackendServiceRequest" + }, + { + "name": "target_tcp_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetTcpProxiesClient", + "fullName": "google.cloud.compute.v1.TargetTcpProxiesClient" + }, + "method": { + "shortName": "SetBackendService", + "fullName": "google.cloud.compute.v1.TargetTcpProxies.SetBackendService", + "service": { + "shortName": "TargetTcpProxies", + "fullName": "google.cloud.compute.v1.TargetTcpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetTcpProxies_SetProxyHeader_async", + "title": "AcceleratorTypes setProxyHeader Sample", + "origin": "API_DEFINITION", + "description": " Changes the ProxyHeaderType for TargetTcpProxy.", + "canonical": true, + "file": "target_tcp_proxies.set_proxy_header.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetProxyHeader", + "fullName": "google.cloud.compute.v1.TargetTcpProxies.SetProxyHeader", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_tcp_proxies_set_proxy_header_request_resource", + "type": ".google.cloud.compute.v1.TargetTcpProxiesSetProxyHeaderRequest" + }, + { + "name": "target_tcp_proxy", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetTcpProxiesClient", + "fullName": "google.cloud.compute.v1.TargetTcpProxiesClient" + }, + "method": { + "shortName": "SetProxyHeader", + "fullName": "google.cloud.compute.v1.TargetTcpProxies.SetProxyHeader", + "service": { + "shortName": "TargetTcpProxies", + "fullName": "google.cloud.compute.v1.TargetTcpProxies" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetVpnGateways_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of target VPN gateways.", + "canonical": true, + "file": "target_vpn_gateways.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.TargetVpnGateways.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.TargetVpnGatewayAggregatedList", + "client": { + "shortName": "TargetVpnGatewaysClient", + "fullName": "google.cloud.compute.v1.TargetVpnGatewaysClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.TargetVpnGateways.AggregatedList", + "service": { + "shortName": "TargetVpnGateways", + "fullName": "google.cloud.compute.v1.TargetVpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetVpnGateways_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified target VPN gateway.", + "canonical": true, + "file": "target_vpn_gateways.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.TargetVpnGateways.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_vpn_gateway", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetVpnGatewaysClient", + "fullName": "google.cloud.compute.v1.TargetVpnGatewaysClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.TargetVpnGateways.Delete", + "service": { + "shortName": "TargetVpnGateways", + "fullName": "google.cloud.compute.v1.TargetVpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetVpnGateways_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified target VPN gateway.", + "canonical": true, + "file": "target_vpn_gateways.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.TargetVpnGateways.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "target_vpn_gateway", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.TargetVpnGateway", + "client": { + "shortName": "TargetVpnGatewaysClient", + "fullName": "google.cloud.compute.v1.TargetVpnGatewaysClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.TargetVpnGateways.Get", + "service": { + "shortName": "TargetVpnGateways", + "fullName": "google.cloud.compute.v1.TargetVpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetVpnGateways_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a target VPN gateway in the specified project and region using the data included in the request.", + "canonical": true, + "file": "target_vpn_gateways.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.TargetVpnGateways.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "target_vpn_gateway_resource", + "type": ".google.cloud.compute.v1.TargetVpnGateway" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetVpnGatewaysClient", + "fullName": "google.cloud.compute.v1.TargetVpnGatewaysClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.TargetVpnGateways.Insert", + "service": { + "shortName": "TargetVpnGateways", + "fullName": "google.cloud.compute.v1.TargetVpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetVpnGateways_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of target VPN gateways available to the specified project and region.", + "canonical": true, + "file": "target_vpn_gateways.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.TargetVpnGateways.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.TargetVpnGatewayList", + "client": { + "shortName": "TargetVpnGatewaysClient", + "fullName": "google.cloud.compute.v1.TargetVpnGatewaysClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.TargetVpnGateways.List", + "service": { + "shortName": "TargetVpnGateways", + "fullName": "google.cloud.compute.v1.TargetVpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_TargetVpnGateways_SetLabels_async", + "title": "AcceleratorTypes setLabels Sample", + "origin": "API_DEFINITION", + "description": " Sets the labels on a TargetVpnGateway. To learn more about labels, read the Labeling Resources documentation.", + "canonical": true, + "file": "target_vpn_gateways.set_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.TargetVpnGateways.SetLabels", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_set_labels_request_resource", + "type": ".google.cloud.compute.v1.RegionSetLabelsRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "TargetVpnGatewaysClient", + "fullName": "google.cloud.compute.v1.TargetVpnGatewaysClient" + }, + "method": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.TargetVpnGateways.SetLabels", + "service": { + "shortName": "TargetVpnGateways", + "fullName": "google.cloud.compute.v1.TargetVpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_UrlMaps_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of all UrlMap resources, regional and global, available to the specified project.", + "canonical": true, + "file": "url_maps.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.UrlMaps.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.UrlMapsAggregatedList", + "client": { + "shortName": "UrlMapsClient", + "fullName": "google.cloud.compute.v1.UrlMapsClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.UrlMaps.AggregatedList", + "service": { + "shortName": "UrlMaps", + "fullName": "google.cloud.compute.v1.UrlMaps" + } + } + } + }, + { + "regionTag": "compute_v1_generated_UrlMaps_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified UrlMap resource.", + "canonical": true, + "file": "url_maps.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.UrlMaps.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "url_map", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "UrlMapsClient", + "fullName": "google.cloud.compute.v1.UrlMapsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.UrlMaps.Delete", + "service": { + "shortName": "UrlMaps", + "fullName": "google.cloud.compute.v1.UrlMaps" + } + } + } + }, + { + "regionTag": "compute_v1_generated_UrlMaps_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified UrlMap resource.", + "canonical": true, + "file": "url_maps.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.UrlMaps.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "url_map", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.UrlMap", + "client": { + "shortName": "UrlMapsClient", + "fullName": "google.cloud.compute.v1.UrlMapsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.UrlMaps.Get", + "service": { + "shortName": "UrlMaps", + "fullName": "google.cloud.compute.v1.UrlMaps" + } + } + } + }, + { + "regionTag": "compute_v1_generated_UrlMaps_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a UrlMap resource in the specified project using the data included in the request.", + "canonical": true, + "file": "url_maps.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.UrlMaps.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "url_map_resource", + "type": ".google.cloud.compute.v1.UrlMap" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "UrlMapsClient", + "fullName": "google.cloud.compute.v1.UrlMapsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.UrlMaps.Insert", + "service": { + "shortName": "UrlMaps", + "fullName": "google.cloud.compute.v1.UrlMaps" + } + } + } + }, + { + "regionTag": "compute_v1_generated_UrlMaps_InvalidateCache_async", + "title": "AcceleratorTypes invalidateCache Sample", + "origin": "API_DEFINITION", + "description": " Initiates a cache invalidation operation, invalidating the specified path, scoped to the specified UrlMap. For more information, see [Invalidating cached content](/cdn/docs/invalidating-cached-content).", + "canonical": true, + "file": "url_maps.invalidate_cache.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "InvalidateCache", + "fullName": "google.cloud.compute.v1.UrlMaps.InvalidateCache", + "async": true, + "parameters": [ + { + "name": "cache_invalidation_rule_resource", + "type": ".google.cloud.compute.v1.CacheInvalidationRule" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "url_map", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "UrlMapsClient", + "fullName": "google.cloud.compute.v1.UrlMapsClient" + }, + "method": { + "shortName": "InvalidateCache", + "fullName": "google.cloud.compute.v1.UrlMaps.InvalidateCache", + "service": { + "shortName": "UrlMaps", + "fullName": "google.cloud.compute.v1.UrlMaps" + } + } + } + }, + { + "regionTag": "compute_v1_generated_UrlMaps_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of UrlMap resources available to the specified project.", + "canonical": true, + "file": "url_maps.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.UrlMaps.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.UrlMapList", + "client": { + "shortName": "UrlMapsClient", + "fullName": "google.cloud.compute.v1.UrlMapsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.UrlMaps.List", + "service": { + "shortName": "UrlMaps", + "fullName": "google.cloud.compute.v1.UrlMaps" + } + } + } + }, + { + "regionTag": "compute_v1_generated_UrlMaps_Patch_async", + "title": "AcceleratorTypes patch Sample", + "origin": "API_DEFINITION", + "description": " Patches the specified UrlMap resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.", + "canonical": true, + "file": "url_maps.patch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.UrlMaps.Patch", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "url_map", + "type": "TYPE_STRING" + }, + { + "name": "url_map_resource", + "type": ".google.cloud.compute.v1.UrlMap" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "UrlMapsClient", + "fullName": "google.cloud.compute.v1.UrlMapsClient" + }, + "method": { + "shortName": "Patch", + "fullName": "google.cloud.compute.v1.UrlMaps.Patch", + "service": { + "shortName": "UrlMaps", + "fullName": "google.cloud.compute.v1.UrlMaps" + } + } + } + }, + { + "regionTag": "compute_v1_generated_UrlMaps_Update_async", + "title": "AcceleratorTypes update Sample", + "origin": "API_DEFINITION", + "description": " Updates the specified UrlMap resource with the data included in the request.", + "canonical": true, + "file": "url_maps.update.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.UrlMaps.Update", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "url_map", + "type": "TYPE_STRING" + }, + { + "name": "url_map_resource", + "type": ".google.cloud.compute.v1.UrlMap" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "UrlMapsClient", + "fullName": "google.cloud.compute.v1.UrlMapsClient" + }, + "method": { + "shortName": "Update", + "fullName": "google.cloud.compute.v1.UrlMaps.Update", + "service": { + "shortName": "UrlMaps", + "fullName": "google.cloud.compute.v1.UrlMaps" + } + } + } + }, + { + "regionTag": "compute_v1_generated_UrlMaps_Validate_async", + "title": "AcceleratorTypes validate Sample", + "origin": "API_DEFINITION", + "description": " Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling this method does NOT create the UrlMap.", + "canonical": true, + "file": "url_maps.validate.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Validate", + "fullName": "google.cloud.compute.v1.UrlMaps.Validate", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "url_map", + "type": "TYPE_STRING" + }, + { + "name": "url_maps_validate_request_resource", + "type": ".google.cloud.compute.v1.UrlMapsValidateRequest" + } + ], + "resultType": ".google.cloud.compute.v1.UrlMapsValidateResponse", + "client": { + "shortName": "UrlMapsClient", + "fullName": "google.cloud.compute.v1.UrlMapsClient" + }, + "method": { + "shortName": "Validate", + "fullName": "google.cloud.compute.v1.UrlMaps.Validate", + "service": { + "shortName": "UrlMaps", + "fullName": "google.cloud.compute.v1.UrlMaps" + } + } + } + }, + { + "regionTag": "compute_v1_generated_VpnGateways_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of VPN gateways.", + "canonical": true, + "file": "vpn_gateways.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.VpnGateways.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.VpnGatewayAggregatedList", + "client": { + "shortName": "VpnGatewaysClient", + "fullName": "google.cloud.compute.v1.VpnGatewaysClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.VpnGateways.AggregatedList", + "service": { + "shortName": "VpnGateways", + "fullName": "google.cloud.compute.v1.VpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_VpnGateways_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified VPN gateway.", + "canonical": true, + "file": "vpn_gateways.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.VpnGateways.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "vpn_gateway", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "VpnGatewaysClient", + "fullName": "google.cloud.compute.v1.VpnGatewaysClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.VpnGateways.Delete", + "service": { + "shortName": "VpnGateways", + "fullName": "google.cloud.compute.v1.VpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_VpnGateways_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified VPN gateway.", + "canonical": true, + "file": "vpn_gateways.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.VpnGateways.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "vpn_gateway", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.VpnGateway", + "client": { + "shortName": "VpnGatewaysClient", + "fullName": "google.cloud.compute.v1.VpnGatewaysClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.VpnGateways.Get", + "service": { + "shortName": "VpnGateways", + "fullName": "google.cloud.compute.v1.VpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_VpnGateways_GetStatus_async", + "title": "AcceleratorTypes getStatus Sample", + "origin": "API_DEFINITION", + "description": " Returns the status for the specified VPN gateway.", + "canonical": true, + "file": "vpn_gateways.get_status.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetStatus", + "fullName": "google.cloud.compute.v1.VpnGateways.GetStatus", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "vpn_gateway", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.VpnGatewaysGetStatusResponse", + "client": { + "shortName": "VpnGatewaysClient", + "fullName": "google.cloud.compute.v1.VpnGatewaysClient" + }, + "method": { + "shortName": "GetStatus", + "fullName": "google.cloud.compute.v1.VpnGateways.GetStatus", + "service": { + "shortName": "VpnGateways", + "fullName": "google.cloud.compute.v1.VpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_VpnGateways_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a VPN gateway in the specified project and region using the data included in the request.", + "canonical": true, + "file": "vpn_gateways.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.VpnGateways.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "vpn_gateway_resource", + "type": ".google.cloud.compute.v1.VpnGateway" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "VpnGatewaysClient", + "fullName": "google.cloud.compute.v1.VpnGatewaysClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.VpnGateways.Insert", + "service": { + "shortName": "VpnGateways", + "fullName": "google.cloud.compute.v1.VpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_VpnGateways_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of VPN gateways available to the specified project and region.", + "canonical": true, + "file": "vpn_gateways.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.VpnGateways.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.VpnGatewayList", + "client": { + "shortName": "VpnGatewaysClient", + "fullName": "google.cloud.compute.v1.VpnGatewaysClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.VpnGateways.List", + "service": { + "shortName": "VpnGateways", + "fullName": "google.cloud.compute.v1.VpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_VpnGateways_SetLabels_async", + "title": "AcceleratorTypes setLabels Sample", + "origin": "API_DEFINITION", + "description": " Sets the labels on a VpnGateway. To learn more about labels, read the Labeling Resources documentation.", + "canonical": true, + "file": "vpn_gateways.set_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.VpnGateways.SetLabels", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_set_labels_request_resource", + "type": ".google.cloud.compute.v1.RegionSetLabelsRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "VpnGatewaysClient", + "fullName": "google.cloud.compute.v1.VpnGatewaysClient" + }, + "method": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.VpnGateways.SetLabels", + "service": { + "shortName": "VpnGateways", + "fullName": "google.cloud.compute.v1.VpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_VpnGateways_TestIamPermissions_async", + "title": "AcceleratorTypes testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource.", + "canonical": true, + "file": "vpn_gateways.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.VpnGateways.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "test_permissions_request_resource", + "type": ".google.cloud.compute.v1.TestPermissionsRequest" + } + ], + "resultType": ".google.cloud.compute.v1.TestPermissionsResponse", + "client": { + "shortName": "VpnGatewaysClient", + "fullName": "google.cloud.compute.v1.VpnGatewaysClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.compute.v1.VpnGateways.TestIamPermissions", + "service": { + "shortName": "VpnGateways", + "fullName": "google.cloud.compute.v1.VpnGateways" + } + } + } + }, + { + "regionTag": "compute_v1_generated_VpnTunnels_AggregatedList_async", + "title": "AcceleratorTypes aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of VPN tunnels.", + "canonical": true, + "file": "vpn_tunnels.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.VpnTunnels.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.VpnTunnelAggregatedList", + "client": { + "shortName": "VpnTunnelsClient", + "fullName": "google.cloud.compute.v1.VpnTunnelsClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1.VpnTunnels.AggregatedList", + "service": { + "shortName": "VpnTunnels", + "fullName": "google.cloud.compute.v1.VpnTunnels" + } + } + } + }, + { + "regionTag": "compute_v1_generated_VpnTunnels_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified VpnTunnel resource.", + "canonical": true, + "file": "vpn_tunnels.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.VpnTunnels.Delete", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "vpn_tunnel", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "VpnTunnelsClient", + "fullName": "google.cloud.compute.v1.VpnTunnelsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.VpnTunnels.Delete", + "service": { + "shortName": "VpnTunnels", + "fullName": "google.cloud.compute.v1.VpnTunnels" + } + } + } + }, + { + "regionTag": "compute_v1_generated_VpnTunnels_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified VpnTunnel resource.", + "canonical": true, + "file": "vpn_tunnels.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.VpnTunnels.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "vpn_tunnel", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.VpnTunnel", + "client": { + "shortName": "VpnTunnelsClient", + "fullName": "google.cloud.compute.v1.VpnTunnelsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.VpnTunnels.Get", + "service": { + "shortName": "VpnTunnels", + "fullName": "google.cloud.compute.v1.VpnTunnels" + } + } + } + }, + { + "regionTag": "compute_v1_generated_VpnTunnels_Insert_async", + "title": "AcceleratorTypes insert Sample", + "origin": "API_DEFINITION", + "description": " Creates a VpnTunnel resource in the specified project and region using the data included in the request.", + "canonical": true, + "file": "vpn_tunnels.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.VpnTunnels.Insert", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "vpn_tunnel_resource", + "type": ".google.cloud.compute.v1.VpnTunnel" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "VpnTunnelsClient", + "fullName": "google.cloud.compute.v1.VpnTunnelsClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1.VpnTunnels.Insert", + "service": { + "shortName": "VpnTunnels", + "fullName": "google.cloud.compute.v1.VpnTunnels" + } + } + } + }, + { + "regionTag": "compute_v1_generated_VpnTunnels_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of VpnTunnel resources contained in the specified project and region.", + "canonical": true, + "file": "vpn_tunnels.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.VpnTunnels.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.VpnTunnelList", + "client": { + "shortName": "VpnTunnelsClient", + "fullName": "google.cloud.compute.v1.VpnTunnelsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.VpnTunnels.List", + "service": { + "shortName": "VpnTunnels", + "fullName": "google.cloud.compute.v1.VpnTunnels" + } + } + } + }, + { + "regionTag": "compute_v1_generated_VpnTunnels_SetLabels_async", + "title": "AcceleratorTypes setLabels Sample", + "origin": "API_DEFINITION", + "description": " Sets the labels on a VpnTunnel. To learn more about labels, read the Labeling Resources documentation.", + "canonical": true, + "file": "vpn_tunnels.set_labels.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.VpnTunnels.SetLabels", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "region_set_labels_request_resource", + "type": ".google.cloud.compute.v1.RegionSetLabelsRequest" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "resource", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "VpnTunnelsClient", + "fullName": "google.cloud.compute.v1.VpnTunnelsClient" + }, + "method": { + "shortName": "SetLabels", + "fullName": "google.cloud.compute.v1.VpnTunnels.SetLabels", + "service": { + "shortName": "VpnTunnels", + "fullName": "google.cloud.compute.v1.VpnTunnels" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ZoneOperations_Delete_async", + "title": "AcceleratorTypes delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified zone-specific Operations resource.", + "canonical": true, + "file": "zone_operations.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.ZoneOperations.Delete", + "async": true, + "parameters": [ + { + "name": "operation", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.DeleteZoneOperationResponse", + "client": { + "shortName": "ZoneOperationsClient", + "fullName": "google.cloud.compute.v1.ZoneOperationsClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1.ZoneOperations.Delete", + "service": { + "shortName": "ZoneOperations", + "fullName": "google.cloud.compute.v1.ZoneOperations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ZoneOperations_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the specified zone-specific Operations resource.", + "canonical": true, + "file": "zone_operations.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.ZoneOperations.Get", + "async": true, + "parameters": [ + { + "name": "operation", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ZoneOperationsClient", + "fullName": "google.cloud.compute.v1.ZoneOperationsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.ZoneOperations.Get", + "service": { + "shortName": "ZoneOperations", + "fullName": "google.cloud.compute.v1.ZoneOperations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ZoneOperations_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of Operation resources contained within the specified zone.", + "canonical": true, + "file": "zone_operations.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.ZoneOperations.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.OperationList", + "client": { + "shortName": "ZoneOperationsClient", + "fullName": "google.cloud.compute.v1.ZoneOperationsClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.ZoneOperations.List", + "service": { + "shortName": "ZoneOperations", + "fullName": "google.cloud.compute.v1.ZoneOperations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_ZoneOperations_Wait_async", + "title": "AcceleratorTypes wait Sample", + "origin": "API_DEFINITION", + "description": " Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method waits for no more than the 2 minutes and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. ", + "canonical": true, + "file": "zone_operations.wait.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Wait", + "fullName": "google.cloud.compute.v1.ZoneOperations.Wait", + "async": true, + "parameters": [ + { + "name": "operation", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Operation", + "client": { + "shortName": "ZoneOperationsClient", + "fullName": "google.cloud.compute.v1.ZoneOperationsClient" + }, + "method": { + "shortName": "Wait", + "fullName": "google.cloud.compute.v1.ZoneOperations.Wait", + "service": { + "shortName": "ZoneOperations", + "fullName": "google.cloud.compute.v1.ZoneOperations" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Zones_Get_async", + "title": "AcceleratorTypes get Sample", + "origin": "API_DEFINITION", + "description": " Returns the specified Zone resource.", + "canonical": true, + "file": "zones.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Zones.Get", + "async": true, + "parameters": [ + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "zone", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1.Zone", + "client": { + "shortName": "ZonesClient", + "fullName": "google.cloud.compute.v1.ZonesClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1.Zones.Get", + "service": { + "shortName": "Zones", + "fullName": "google.cloud.compute.v1.Zones" + } + } + } + }, + { + "regionTag": "compute_v1_generated_Zones_List_async", + "title": "AcceleratorTypes list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the list of Zone resources available to the specified project.", + "canonical": true, + "file": "zones.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Zones.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "return_partial_success", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.compute.v1.ZoneList", + "client": { + "shortName": "ZonesClient", + "fullName": "google.cloud.compute.v1.ZonesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1.Zones.List", + "service": { + "shortName": "Zones", + "fullName": "google.cloud.compute.v1.Zones" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_certificates.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_certificates.aggregated_list.js new file mode 100644 index 00000000000..380eacb632e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_certificates.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_SslCertificates_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Name of the project scoping this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {SslCertificatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SslCertificatesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_SslCertificates_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_certificates.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_certificates.delete.js new file mode 100644 index 00000000000..df39e88447f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_certificates.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, sslCertificate) { + // [START compute_v1_generated_SslCertificates_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the SslCertificate resource to delete. + */ + // const sslCertificate = 'abc123' + + // Imports the Compute library + const {SslCertificatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SslCertificatesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + sslCertificate, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_SslCertificates_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_certificates.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_certificates.get.js new file mode 100644 index 00000000000..403cc19728d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_certificates.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(project, sslCertificate) { + // [START compute_v1_generated_SslCertificates_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the SslCertificate resource to return. + */ + // const sslCertificate = 'abc123' + + // Imports the Compute library + const {SslCertificatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SslCertificatesClient(); + + async function callGet() { + // Construct request + const request = { + project, + sslCertificate, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_SslCertificates_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_certificates.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_certificates.insert.js new file mode 100644 index 00000000000..a9e146a6544 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_certificates.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, sslCertificateResource) { + // [START compute_v1_generated_SslCertificates_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const sslCertificateResource = {} + + // Imports the Compute library + const {SslCertificatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SslCertificatesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + sslCertificateResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_SslCertificates_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_certificates.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_certificates.list.js new file mode 100644 index 00000000000..320fe3378db --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_certificates.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_SslCertificates_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {SslCertificatesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SslCertificatesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_SslCertificates_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.aggregated_list.js new file mode 100644 index 00000000000..db428ba67e0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_SslPolicies_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Name of the project scoping this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {SslPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SslPoliciesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_SslPolicies_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.delete.js new file mode 100644 index 00000000000..63595df92bd --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, sslPolicy) { + // [START compute_v1_generated_SslPolicies_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the SSL policy to delete. The name must be 1-63 characters long, and comply with RFC1035. + */ + // const sslPolicy = 'abc123' + + // Imports the Compute library + const {SslPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SslPoliciesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + sslPolicy, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_SslPolicies_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.get.js new file mode 100644 index 00000000000..f8ff74fc94a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(project, sslPolicy) { + // [START compute_v1_generated_SslPolicies_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the SSL policy to update. The name must be 1-63 characters long, and comply with RFC1035. + */ + // const sslPolicy = 'abc123' + + // Imports the Compute library + const {SslPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SslPoliciesClient(); + + async function callGet() { + // Construct request + const request = { + project, + sslPolicy, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_SslPolicies_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.insert.js new file mode 100644 index 00000000000..3b7cfdb8c8c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, sslPolicyResource) { + // [START compute_v1_generated_SslPolicies_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const sslPolicyResource = {} + + // Imports the Compute library + const {SslPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SslPoliciesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + sslPolicyResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_SslPolicies_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.list.js new file mode 100644 index 00000000000..5255c3c789f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_SslPolicies_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {SslPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SslPoliciesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_SslPolicies_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.list_available_features.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.list_available_features.js new file mode 100644 index 00000000000..502700b8906 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.list_available_features.js @@ -0,0 +1,81 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_SslPolicies_ListAvailableFeatures_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {SslPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SslPoliciesClient(); + + async function callListAvailableFeatures() { + // Construct request + const request = { + project, + }; + + // Run request + const response = await computeClient.listAvailableFeatures(request); + console.log(response); + } + + callListAvailableFeatures(); + // [END compute_v1_generated_SslPolicies_ListAvailableFeatures_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.patch.js new file mode 100644 index 00000000000..ab3ee71dd8c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/ssl_policies.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, sslPolicy, sslPolicyResource) { + // [START compute_v1_generated_SslPolicies_Patch_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the SSL policy to update. The name must be 1-63 characters long, and comply with RFC1035. + */ + // const sslPolicy = 'abc123' + /** + * The body resource for this request + */ + // const sslPolicyResource = {} + + // Imports the Compute library + const {SslPoliciesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SslPoliciesClient(); + + async function callPatch() { + // Construct request + const request = { + project, + sslPolicy, + sslPolicyResource, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_SslPolicies_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.aggregated_list.js new file mode 100644 index 00000000000..47e3a432295 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Subnetworks_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {SubnetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SubnetworksClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_Subnetworks_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.delete.js new file mode 100644 index 00000000000..a99211702b1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, subnetwork) { + // [START compute_v1_generated_Subnetworks_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the Subnetwork resource to delete. + */ + // const subnetwork = 'abc123' + + // Imports the Compute library + const {SubnetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SubnetworksClient(); + + async function callDelete() { + // Construct request + const request = { + project, + region, + subnetwork, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_Subnetworks_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.expand_ip_cidr_range.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.expand_ip_cidr_range.js new file mode 100644 index 00000000000..67ffb171d6b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.expand_ip_cidr_range.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, subnetwork, subnetworksExpandIpCidrRangeRequestResource) { + // [START compute_v1_generated_Subnetworks_ExpandIpCidrRange_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the Subnetwork resource to update. + */ + // const subnetwork = 'abc123' + /** + * The body resource for this request + */ + // const subnetworksExpandIpCidrRangeRequestResource = {} + + // Imports the Compute library + const {SubnetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SubnetworksClient(); + + async function callExpandIpCidrRange() { + // Construct request + const request = { + project, + region, + subnetwork, + subnetworksExpandIpCidrRangeRequestResource, + }; + + // Run request + const response = await computeClient.expandIpCidrRange(request); + console.log(response); + } + + callExpandIpCidrRange(); + // [END compute_v1_generated_Subnetworks_ExpandIpCidrRange_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.get.js new file mode 100644 index 00000000000..b1edf4dfdc9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, subnetwork) { + // [START compute_v1_generated_Subnetworks_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Name of the Subnetwork resource to return. + */ + // const subnetwork = 'abc123' + + // Imports the Compute library + const {SubnetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SubnetworksClient(); + + async function callGet() { + // Construct request + const request = { + project, + region, + subnetwork, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Subnetworks_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.get_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.get_iam_policy.js new file mode 100644 index 00000000000..e9ba0e7e320 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.get_iam_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, resource) { + // [START compute_v1_generated_Subnetworks_GetIamPolicy_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. + */ + /** + * Requested IAM Policy version. + */ + // const optionsRequestedPolicyVersion = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {SubnetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SubnetworksClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + project, + region, + resource, + }; + + // Run request + const response = await computeClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END compute_v1_generated_Subnetworks_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.insert.js new file mode 100644 index 00000000000..101235f9352 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, subnetworkResource) { + // [START compute_v1_generated_Subnetworks_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const subnetworkResource = {} + + // Imports the Compute library + const {SubnetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SubnetworksClient(); + + async function callInsert() { + // Construct request + const request = { + project, + region, + subnetworkResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_Subnetworks_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.list.js new file mode 100644 index 00000000000..f174de08943 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_Subnetworks_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {SubnetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SubnetworksClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_Subnetworks_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.list_usable.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.list_usable.js new file mode 100644 index 00000000000..71f3bceaf26 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.list_usable.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Subnetworks_ListUsable_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {SubnetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SubnetworksClient(); + + async function callListUsable() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listUsableAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListUsable(); + // [END compute_v1_generated_Subnetworks_ListUsable_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.patch.js new file mode 100644 index 00000000000..a568cbdf178 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.patch.js @@ -0,0 +1,84 @@ +// Copyright 2023 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(project, region, subnetwork, subnetworkResource) { + // [START compute_v1_generated_Subnetworks_Patch_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. + */ + /** + * The drain timeout specifies the upper bound in seconds on the amount of time allowed to drain connections from the current ACTIVE subnetwork to the current BACKUP subnetwork. The drain timeout is only applicable when the following conditions are true: - the subnetwork being patched has purpose = INTERNAL_HTTPS_LOAD_BALANCER - the subnetwork being patched has role = BACKUP - the patch request is setting the role to ACTIVE. Note that after this patch operation the roles of the ACTIVE and BACKUP subnetworks will be swapped. + */ + // const drainTimeoutSeconds = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the Subnetwork resource to patch. + */ + // const subnetwork = 'abc123' + /** + * The body resource for this request + */ + // const subnetworkResource = {} + + // Imports the Compute library + const {SubnetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SubnetworksClient(); + + async function callPatch() { + // Construct request + const request = { + project, + region, + subnetwork, + subnetworkResource, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_Subnetworks_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.set_iam_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.set_iam_policy.js new file mode 100644 index 00000000000..d399416c002 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.set_iam_policy.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, regionSetPolicyRequestResource, resource) { + // [START compute_v1_generated_Subnetworks_SetIamPolicy_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionSetPolicyRequestResource = {} + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {SubnetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SubnetworksClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + project, + region, + regionSetPolicyRequestResource, + resource, + }; + + // Run request + const response = await computeClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END compute_v1_generated_Subnetworks_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.set_private_ip_google_access.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.set_private_ip_google_access.js new file mode 100644 index 00000000000..fabc2ab21ae --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.set_private_ip_google_access.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, subnetwork, subnetworksSetPrivateIpGoogleAccessRequestResource) { + // [START compute_v1_generated_Subnetworks_SetPrivateIpGoogleAccess_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the Subnetwork resource. + */ + // const subnetwork = 'abc123' + /** + * The body resource for this request + */ + // const subnetworksSetPrivateIpGoogleAccessRequestResource = {} + + // Imports the Compute library + const {SubnetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SubnetworksClient(); + + async function callSetPrivateIpGoogleAccess() { + // Construct request + const request = { + project, + region, + subnetwork, + subnetworksSetPrivateIpGoogleAccessRequestResource, + }; + + // Run request + const response = await computeClient.setPrivateIpGoogleAccess(request); + console.log(response); + } + + callSetPrivateIpGoogleAccess(); + // [END compute_v1_generated_Subnetworks_SetPrivateIpGoogleAccess_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.test_iam_permissions.js new file mode 100644 index 00000000000..1d322da8829 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/subnetworks.test_iam_permissions.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_Subnetworks_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {SubnetworksClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new SubnetworksClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + region, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_Subnetworks_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_grpc_proxies.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_grpc_proxies.delete.js new file mode 100644 index 00000000000..340c3615bda --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_grpc_proxies.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, targetGrpcProxy) { + // [START compute_v1_generated_TargetGrpcProxies_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetGrpcProxy resource to delete. + */ + // const targetGrpcProxy = 'abc123' + + // Imports the Compute library + const {TargetGrpcProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetGrpcProxiesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + targetGrpcProxy, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_TargetGrpcProxies_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_grpc_proxies.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_grpc_proxies.get.js new file mode 100644 index 00000000000..4c11ec35396 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_grpc_proxies.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(project, targetGrpcProxy) { + // [START compute_v1_generated_TargetGrpcProxies_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the TargetGrpcProxy resource to return. + */ + // const targetGrpcProxy = 'abc123' + + // Imports the Compute library + const {TargetGrpcProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetGrpcProxiesClient(); + + async function callGet() { + // Construct request + const request = { + project, + targetGrpcProxy, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_TargetGrpcProxies_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_grpc_proxies.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_grpc_proxies.insert.js new file mode 100644 index 00000000000..0185121c0c5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_grpc_proxies.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, targetGrpcProxyResource) { + // [START compute_v1_generated_TargetGrpcProxies_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetGrpcProxyResource = {} + + // Imports the Compute library + const {TargetGrpcProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetGrpcProxiesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + targetGrpcProxyResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_TargetGrpcProxies_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_grpc_proxies.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_grpc_proxies.list.js new file mode 100644 index 00000000000..445369359e3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_grpc_proxies.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_TargetGrpcProxies_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {TargetGrpcProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetGrpcProxiesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_TargetGrpcProxies_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_grpc_proxies.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_grpc_proxies.patch.js new file mode 100644 index 00000000000..86fc69c9fee --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_grpc_proxies.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, targetGrpcProxy, targetGrpcProxyResource) { + // [START compute_v1_generated_TargetGrpcProxies_Patch_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetGrpcProxy resource to patch. + */ + // const targetGrpcProxy = 'abc123' + /** + * The body resource for this request + */ + // const targetGrpcProxyResource = {} + + // Imports the Compute library + const {TargetGrpcProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetGrpcProxiesClient(); + + async function callPatch() { + // Construct request + const request = { + project, + targetGrpcProxy, + targetGrpcProxyResource, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_TargetGrpcProxies_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.aggregated_list.js new file mode 100644 index 00000000000..6ade75c8aa6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_TargetHttpProxies_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Name of the project scoping this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {TargetHttpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpProxiesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_TargetHttpProxies_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.delete.js new file mode 100644 index 00000000000..ff8d50dc59e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, targetHttpProxy) { + // [START compute_v1_generated_TargetHttpProxies_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetHttpProxy resource to delete. + */ + // const targetHttpProxy = 'abc123' + + // Imports the Compute library + const {TargetHttpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpProxiesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + targetHttpProxy, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_TargetHttpProxies_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.get.js new file mode 100644 index 00000000000..6c1ab68ffbe --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(project, targetHttpProxy) { + // [START compute_v1_generated_TargetHttpProxies_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the TargetHttpProxy resource to return. + */ + // const targetHttpProxy = 'abc123' + + // Imports the Compute library + const {TargetHttpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpProxiesClient(); + + async function callGet() { + // Construct request + const request = { + project, + targetHttpProxy, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_TargetHttpProxies_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.insert.js new file mode 100644 index 00000000000..8061bf3edc1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, targetHttpProxyResource) { + // [START compute_v1_generated_TargetHttpProxies_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetHttpProxyResource = {} + + // Imports the Compute library + const {TargetHttpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpProxiesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + targetHttpProxyResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_TargetHttpProxies_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.list.js new file mode 100644 index 00000000000..02ccc692911 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_TargetHttpProxies_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {TargetHttpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpProxiesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_TargetHttpProxies_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.patch.js new file mode 100644 index 00000000000..9d97203fe12 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, targetHttpProxy, targetHttpProxyResource) { + // [START compute_v1_generated_TargetHttpProxies_Patch_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetHttpProxy resource to patch. + */ + // const targetHttpProxy = 'abc123' + /** + * The body resource for this request + */ + // const targetHttpProxyResource = {} + + // Imports the Compute library + const {TargetHttpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpProxiesClient(); + + async function callPatch() { + // Construct request + const request = { + project, + targetHttpProxy, + targetHttpProxyResource, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_TargetHttpProxies_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.set_url_map.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.set_url_map.js new file mode 100644 index 00000000000..7940e709555 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_http_proxies.set_url_map.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, targetHttpProxy, urlMapReferenceResource) { + // [START compute_v1_generated_TargetHttpProxies_SetUrlMap_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetHttpProxy to set a URL map for. + */ + // const targetHttpProxy = 'abc123' + /** + * The body resource for this request + */ + // const urlMapReferenceResource = {} + + // Imports the Compute library + const {TargetHttpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpProxiesClient(); + + async function callSetUrlMap() { + // Construct request + const request = { + project, + targetHttpProxy, + urlMapReferenceResource, + }; + + // Run request + const response = await computeClient.setUrlMap(request); + console.log(response); + } + + callSetUrlMap(); + // [END compute_v1_generated_TargetHttpProxies_SetUrlMap_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.aggregated_list.js new file mode 100644 index 00000000000..0287dc42561 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_TargetHttpsProxies_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Name of the project scoping this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {TargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpsProxiesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_TargetHttpsProxies_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.delete.js new file mode 100644 index 00000000000..bc4e347d8f3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, targetHttpsProxy) { + // [START compute_v1_generated_TargetHttpsProxies_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetHttpsProxy resource to delete. + */ + // const targetHttpsProxy = 'abc123' + + // Imports the Compute library + const {TargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpsProxiesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + targetHttpsProxy, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_TargetHttpsProxies_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.get.js new file mode 100644 index 00000000000..4c43ee0dfbd --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(project, targetHttpsProxy) { + // [START compute_v1_generated_TargetHttpsProxies_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the TargetHttpsProxy resource to return. + */ + // const targetHttpsProxy = 'abc123' + + // Imports the Compute library + const {TargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpsProxiesClient(); + + async function callGet() { + // Construct request + const request = { + project, + targetHttpsProxy, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_TargetHttpsProxies_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.insert.js new file mode 100644 index 00000000000..72483d1a3a5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, targetHttpsProxyResource) { + // [START compute_v1_generated_TargetHttpsProxies_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetHttpsProxyResource = {} + + // Imports the Compute library + const {TargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpsProxiesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + targetHttpsProxyResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_TargetHttpsProxies_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.list.js new file mode 100644 index 00000000000..b63faeee3f3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_TargetHttpsProxies_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {TargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpsProxiesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_TargetHttpsProxies_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.patch.js new file mode 100644 index 00000000000..a8998409efe --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, targetHttpsProxy, targetHttpsProxyResource) { + // [START compute_v1_generated_TargetHttpsProxies_Patch_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetHttpsProxy resource to patch. + */ + // const targetHttpsProxy = 'abc123' + /** + * The body resource for this request + */ + // const targetHttpsProxyResource = {} + + // Imports the Compute library + const {TargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpsProxiesClient(); + + async function callPatch() { + // Construct request + const request = { + project, + targetHttpsProxy, + targetHttpsProxyResource, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_TargetHttpsProxies_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.set_certificate_map.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.set_certificate_map.js new file mode 100644 index 00000000000..7b170443ea9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.set_certificate_map.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, targetHttpsProxiesSetCertificateMapRequestResource, targetHttpsProxy) { + // [START compute_v1_generated_TargetHttpsProxies_SetCertificateMap_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetHttpsProxiesSetCertificateMapRequestResource = {} + /** + * Name of the TargetHttpsProxy resource whose CertificateMap is to be set. The name must be 1-63 characters long, and comply with RFC1035. + */ + // const targetHttpsProxy = 'abc123' + + // Imports the Compute library + const {TargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpsProxiesClient(); + + async function callSetCertificateMap() { + // Construct request + const request = { + project, + targetHttpsProxiesSetCertificateMapRequestResource, + targetHttpsProxy, + }; + + // Run request + const response = await computeClient.setCertificateMap(request); + console.log(response); + } + + callSetCertificateMap(); + // [END compute_v1_generated_TargetHttpsProxies_SetCertificateMap_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.set_quic_override.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.set_quic_override.js new file mode 100644 index 00000000000..4274b789dd1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.set_quic_override.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, targetHttpsProxiesSetQuicOverrideRequestResource, targetHttpsProxy) { + // [START compute_v1_generated_TargetHttpsProxies_SetQuicOverride_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetHttpsProxiesSetQuicOverrideRequestResource = {} + /** + * Name of the TargetHttpsProxy resource to set the QUIC override policy for. The name should conform to RFC1035. + */ + // const targetHttpsProxy = 'abc123' + + // Imports the Compute library + const {TargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpsProxiesClient(); + + async function callSetQuicOverride() { + // Construct request + const request = { + project, + targetHttpsProxiesSetQuicOverrideRequestResource, + targetHttpsProxy, + }; + + // Run request + const response = await computeClient.setQuicOverride(request); + console.log(response); + } + + callSetQuicOverride(); + // [END compute_v1_generated_TargetHttpsProxies_SetQuicOverride_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.set_ssl_certificates.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.set_ssl_certificates.js new file mode 100644 index 00000000000..24349d316d6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.set_ssl_certificates.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, targetHttpsProxiesSetSslCertificatesRequestResource, targetHttpsProxy) { + // [START compute_v1_generated_TargetHttpsProxies_SetSslCertificates_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetHttpsProxiesSetSslCertificatesRequestResource = {} + /** + * Name of the TargetHttpsProxy resource to set an SslCertificates resource for. + */ + // const targetHttpsProxy = 'abc123' + + // Imports the Compute library + const {TargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpsProxiesClient(); + + async function callSetSslCertificates() { + // Construct request + const request = { + project, + targetHttpsProxiesSetSslCertificatesRequestResource, + targetHttpsProxy, + }; + + // Run request + const response = await computeClient.setSslCertificates(request); + console.log(response); + } + + callSetSslCertificates(); + // [END compute_v1_generated_TargetHttpsProxies_SetSslCertificates_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.set_ssl_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.set_ssl_policy.js new file mode 100644 index 00000000000..84f597ff671 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.set_ssl_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, sslPolicyReferenceResource, targetHttpsProxy) { + // [START compute_v1_generated_TargetHttpsProxies_SetSslPolicy_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const sslPolicyReferenceResource = {} + /** + * Name of the TargetHttpsProxy resource whose SSL policy is to be set. The name must be 1-63 characters long, and comply with RFC1035. + */ + // const targetHttpsProxy = 'abc123' + + // Imports the Compute library + const {TargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpsProxiesClient(); + + async function callSetSslPolicy() { + // Construct request + const request = { + project, + sslPolicyReferenceResource, + targetHttpsProxy, + }; + + // Run request + const response = await computeClient.setSslPolicy(request); + console.log(response); + } + + callSetSslPolicy(); + // [END compute_v1_generated_TargetHttpsProxies_SetSslPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.set_url_map.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.set_url_map.js new file mode 100644 index 00000000000..4e828885b9a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_https_proxies.set_url_map.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, targetHttpsProxy, urlMapReferenceResource) { + // [START compute_v1_generated_TargetHttpsProxies_SetUrlMap_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetHttpsProxy resource whose URL map is to be set. + */ + // const targetHttpsProxy = 'abc123' + /** + * The body resource for this request + */ + // const urlMapReferenceResource = {} + + // Imports the Compute library + const {TargetHttpsProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetHttpsProxiesClient(); + + async function callSetUrlMap() { + // Construct request + const request = { + project, + targetHttpsProxy, + urlMapReferenceResource, + }; + + // Run request + const response = await computeClient.setUrlMap(request); + console.log(response); + } + + callSetUrlMap(); + // [END compute_v1_generated_TargetHttpsProxies_SetUrlMap_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_instances.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_instances.aggregated_list.js new file mode 100644 index 00000000000..cc4b44e5375 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_instances.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_TargetInstances_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {TargetInstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetInstancesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_TargetInstances_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_instances.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_instances.delete.js new file mode 100644 index 00000000000..9f180efe0d8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_instances.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, targetInstance, zone) { + // [START compute_v1_generated_TargetInstances_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetInstance resource to delete. + */ + // const targetInstance = 'abc123' + /** + * Name of the zone scoping this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {TargetInstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetInstancesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + targetInstance, + zone, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_TargetInstances_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_instances.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_instances.get.js new file mode 100644 index 00000000000..0321b9ce05e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_instances.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, targetInstance, zone) { + // [START compute_v1_generated_TargetInstances_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the TargetInstance resource to return. + */ + // const targetInstance = 'abc123' + /** + * Name of the zone scoping this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {TargetInstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetInstancesClient(); + + async function callGet() { + // Construct request + const request = { + project, + targetInstance, + zone, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_TargetInstances_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_instances.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_instances.insert.js new file mode 100644 index 00000000000..4bd185116dd --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_instances.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, targetInstanceResource, zone) { + // [START compute_v1_generated_TargetInstances_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetInstanceResource = {} + /** + * Name of the zone scoping this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {TargetInstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetInstancesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + targetInstanceResource, + zone, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_TargetInstances_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_instances.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_instances.list.js new file mode 100644 index 00000000000..eada29123ba --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_instances.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, zone) { + // [START compute_v1_generated_TargetInstances_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * Name of the zone scoping this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {TargetInstancesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetInstancesClient(); + + async function callList() { + // Construct request + const request = { + project, + zone, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_TargetInstances_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.add_health_check.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.add_health_check.js new file mode 100644 index 00000000000..803d62b3141 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.add_health_check.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, targetPool, targetPoolsAddHealthCheckRequestResource) { + // [START compute_v1_generated_TargetPools_AddHealthCheck_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the target pool to add a health check to. + */ + // const targetPool = 'abc123' + /** + * The body resource for this request + */ + // const targetPoolsAddHealthCheckRequestResource = {} + + // Imports the Compute library + const {TargetPoolsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetPoolsClient(); + + async function callAddHealthCheck() { + // Construct request + const request = { + project, + region, + targetPool, + targetPoolsAddHealthCheckRequestResource, + }; + + // Run request + const response = await computeClient.addHealthCheck(request); + console.log(response); + } + + callAddHealthCheck(); + // [END compute_v1_generated_TargetPools_AddHealthCheck_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.add_instance.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.add_instance.js new file mode 100644 index 00000000000..5a7f04dc657 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.add_instance.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, targetPool, targetPoolsAddInstanceRequestResource) { + // [START compute_v1_generated_TargetPools_AddInstance_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetPool resource to add instances to. + */ + // const targetPool = 'abc123' + /** + * The body resource for this request + */ + // const targetPoolsAddInstanceRequestResource = {} + + // Imports the Compute library + const {TargetPoolsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetPoolsClient(); + + async function callAddInstance() { + // Construct request + const request = { + project, + region, + targetPool, + targetPoolsAddInstanceRequestResource, + }; + + // Run request + const response = await computeClient.addInstance(request); + console.log(response); + } + + callAddInstance(); + // [END compute_v1_generated_TargetPools_AddInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.aggregated_list.js new file mode 100644 index 00000000000..2344553ffeb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_TargetPools_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {TargetPoolsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetPoolsClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_TargetPools_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.delete.js new file mode 100644 index 00000000000..4021809791f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, targetPool) { + // [START compute_v1_generated_TargetPools_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetPool resource to delete. + */ + // const targetPool = 'abc123' + + // Imports the Compute library + const {TargetPoolsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetPoolsClient(); + + async function callDelete() { + // Construct request + const request = { + project, + region, + targetPool, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_TargetPools_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.get.js new file mode 100644 index 00000000000..326e7809662 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, targetPool) { + // [START compute_v1_generated_TargetPools_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Name of the TargetPool resource to return. + */ + // const targetPool = 'abc123' + + // Imports the Compute library + const {TargetPoolsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetPoolsClient(); + + async function callGet() { + // Construct request + const request = { + project, + region, + targetPool, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_TargetPools_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.get_health.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.get_health.js new file mode 100644 index 00000000000..c9b6ecdbeee --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.get_health.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(instanceReferenceResource, project, region, targetPool) { + // [START compute_v1_generated_TargetPools_GetHealth_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. + */ + /** + * The body resource for this request + */ + // const instanceReferenceResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Name of the TargetPool resource to which the queried instance belongs. + */ + // const targetPool = 'abc123' + + // Imports the Compute library + const {TargetPoolsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetPoolsClient(); + + async function callGetHealth() { + // Construct request + const request = { + instanceReferenceResource, + project, + region, + targetPool, + }; + + // Run request + const response = await computeClient.getHealth(request); + console.log(response); + } + + callGetHealth(); + // [END compute_v1_generated_TargetPools_GetHealth_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.insert.js new file mode 100644 index 00000000000..e0ffbe36b45 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, targetPoolResource) { + // [START compute_v1_generated_TargetPools_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetPoolResource = {} + + // Imports the Compute library + const {TargetPoolsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetPoolsClient(); + + async function callInsert() { + // Construct request + const request = { + project, + region, + targetPoolResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_TargetPools_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.list.js new file mode 100644 index 00000000000..8ae7d83d8f5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_TargetPools_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {TargetPoolsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetPoolsClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_TargetPools_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.remove_health_check.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.remove_health_check.js new file mode 100644 index 00000000000..33cddb00433 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.remove_health_check.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, targetPool, targetPoolsRemoveHealthCheckRequestResource) { + // [START compute_v1_generated_TargetPools_RemoveHealthCheck_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the target pool to remove health checks from. + */ + // const targetPool = 'abc123' + /** + * The body resource for this request + */ + // const targetPoolsRemoveHealthCheckRequestResource = {} + + // Imports the Compute library + const {TargetPoolsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetPoolsClient(); + + async function callRemoveHealthCheck() { + // Construct request + const request = { + project, + region, + targetPool, + targetPoolsRemoveHealthCheckRequestResource, + }; + + // Run request + const response = await computeClient.removeHealthCheck(request); + console.log(response); + } + + callRemoveHealthCheck(); + // [END compute_v1_generated_TargetPools_RemoveHealthCheck_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.remove_instance.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.remove_instance.js new file mode 100644 index 00000000000..4246111e20d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.remove_instance.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, targetPool, targetPoolsRemoveInstanceRequestResource) { + // [START compute_v1_generated_TargetPools_RemoveInstance_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetPool resource to remove instances from. + */ + // const targetPool = 'abc123' + /** + * The body resource for this request + */ + // const targetPoolsRemoveInstanceRequestResource = {} + + // Imports the Compute library + const {TargetPoolsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetPoolsClient(); + + async function callRemoveInstance() { + // Construct request + const request = { + project, + region, + targetPool, + targetPoolsRemoveInstanceRequestResource, + }; + + // Run request + const response = await computeClient.removeInstance(request); + console.log(response); + } + + callRemoveInstance(); + // [END compute_v1_generated_TargetPools_RemoveInstance_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.set_backup.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.set_backup.js new file mode 100644 index 00000000000..1b492f3149b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_pools.set_backup.js @@ -0,0 +1,84 @@ +// Copyright 2023 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(project, region, targetPool, targetReferenceResource) { + // [START compute_v1_generated_TargetPools_SetBackup_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. + */ + /** + * New failoverRatio value for the target pool. + */ + // const failoverRatio = 1234 + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region scoping this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetPool resource to set a backup pool for. + */ + // const targetPool = 'abc123' + /** + * The body resource for this request + */ + // const targetReferenceResource = {} + + // Imports the Compute library + const {TargetPoolsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetPoolsClient(); + + async function callSetBackup() { + // Construct request + const request = { + project, + region, + targetPool, + targetReferenceResource, + }; + + // Run request + const response = await computeClient.setBackup(request); + console.log(response); + } + + callSetBackup(); + // [END compute_v1_generated_TargetPools_SetBackup_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.delete.js new file mode 100644 index 00000000000..f728151fc7f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, targetSslProxy) { + // [START compute_v1_generated_TargetSslProxies_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetSslProxy resource to delete. + */ + // const targetSslProxy = 'abc123' + + // Imports the Compute library + const {TargetSslProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetSslProxiesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + targetSslProxy, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_TargetSslProxies_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.get.js new file mode 100644 index 00000000000..08422027a5d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(project, targetSslProxy) { + // [START compute_v1_generated_TargetSslProxies_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the TargetSslProxy resource to return. + */ + // const targetSslProxy = 'abc123' + + // Imports the Compute library + const {TargetSslProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetSslProxiesClient(); + + async function callGet() { + // Construct request + const request = { + project, + targetSslProxy, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_TargetSslProxies_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.insert.js new file mode 100644 index 00000000000..69eb1d53bf3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, targetSslProxyResource) { + // [START compute_v1_generated_TargetSslProxies_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetSslProxyResource = {} + + // Imports the Compute library + const {TargetSslProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetSslProxiesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + targetSslProxyResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_TargetSslProxies_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.list.js new file mode 100644 index 00000000000..bae223a4819 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_TargetSslProxies_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {TargetSslProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetSslProxiesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_TargetSslProxies_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.set_backend_service.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.set_backend_service.js new file mode 100644 index 00000000000..25660957ce1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.set_backend_service.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, targetSslProxiesSetBackendServiceRequestResource, targetSslProxy) { + // [START compute_v1_generated_TargetSslProxies_SetBackendService_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetSslProxiesSetBackendServiceRequestResource = {} + /** + * Name of the TargetSslProxy resource whose BackendService resource is to be set. + */ + // const targetSslProxy = 'abc123' + + // Imports the Compute library + const {TargetSslProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetSslProxiesClient(); + + async function callSetBackendService() { + // Construct request + const request = { + project, + targetSslProxiesSetBackendServiceRequestResource, + targetSslProxy, + }; + + // Run request + const response = await computeClient.setBackendService(request); + console.log(response); + } + + callSetBackendService(); + // [END compute_v1_generated_TargetSslProxies_SetBackendService_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.set_certificate_map.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.set_certificate_map.js new file mode 100644 index 00000000000..6ed3ef83db0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.set_certificate_map.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, targetSslProxiesSetCertificateMapRequestResource, targetSslProxy) { + // [START compute_v1_generated_TargetSslProxies_SetCertificateMap_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetSslProxiesSetCertificateMapRequestResource = {} + /** + * Name of the TargetSslProxy resource whose CertificateMap is to be set. The name must be 1-63 characters long, and comply with RFC1035. + */ + // const targetSslProxy = 'abc123' + + // Imports the Compute library + const {TargetSslProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetSslProxiesClient(); + + async function callSetCertificateMap() { + // Construct request + const request = { + project, + targetSslProxiesSetCertificateMapRequestResource, + targetSslProxy, + }; + + // Run request + const response = await computeClient.setCertificateMap(request); + console.log(response); + } + + callSetCertificateMap(); + // [END compute_v1_generated_TargetSslProxies_SetCertificateMap_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.set_proxy_header.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.set_proxy_header.js new file mode 100644 index 00000000000..592c1ef0af5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.set_proxy_header.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, targetSslProxiesSetProxyHeaderRequestResource, targetSslProxy) { + // [START compute_v1_generated_TargetSslProxies_SetProxyHeader_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetSslProxiesSetProxyHeaderRequestResource = {} + /** + * Name of the TargetSslProxy resource whose ProxyHeader is to be set. + */ + // const targetSslProxy = 'abc123' + + // Imports the Compute library + const {TargetSslProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetSslProxiesClient(); + + async function callSetProxyHeader() { + // Construct request + const request = { + project, + targetSslProxiesSetProxyHeaderRequestResource, + targetSslProxy, + }; + + // Run request + const response = await computeClient.setProxyHeader(request); + console.log(response); + } + + callSetProxyHeader(); + // [END compute_v1_generated_TargetSslProxies_SetProxyHeader_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.set_ssl_certificates.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.set_ssl_certificates.js new file mode 100644 index 00000000000..6fb6c609ae2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.set_ssl_certificates.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, targetSslProxiesSetSslCertificatesRequestResource, targetSslProxy) { + // [START compute_v1_generated_TargetSslProxies_SetSslCertificates_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetSslProxiesSetSslCertificatesRequestResource = {} + /** + * Name of the TargetSslProxy resource whose SslCertificate resource is to be set. + */ + // const targetSslProxy = 'abc123' + + // Imports the Compute library + const {TargetSslProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetSslProxiesClient(); + + async function callSetSslCertificates() { + // Construct request + const request = { + project, + targetSslProxiesSetSslCertificatesRequestResource, + targetSslProxy, + }; + + // Run request + const response = await computeClient.setSslCertificates(request); + console.log(response); + } + + callSetSslCertificates(); + // [END compute_v1_generated_TargetSslProxies_SetSslCertificates_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.set_ssl_policy.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.set_ssl_policy.js new file mode 100644 index 00000000000..c924c6ee778 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_ssl_proxies.set_ssl_policy.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, sslPolicyReferenceResource, targetSslProxy) { + // [START compute_v1_generated_TargetSslProxies_SetSslPolicy_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const sslPolicyReferenceResource = {} + /** + * Name of the TargetSslProxy resource whose SSL policy is to be set. The name must be 1-63 characters long, and comply with RFC1035. + */ + // const targetSslProxy = 'abc123' + + // Imports the Compute library + const {TargetSslProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetSslProxiesClient(); + + async function callSetSslPolicy() { + // Construct request + const request = { + project, + sslPolicyReferenceResource, + targetSslProxy, + }; + + // Run request + const response = await computeClient.setSslPolicy(request); + console.log(response); + } + + callSetSslPolicy(); + // [END compute_v1_generated_TargetSslProxies_SetSslPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.aggregated_list.js new file mode 100644 index 00000000000..4e69c2289fc --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_TargetTcpProxies_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Name of the project scoping this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {TargetTcpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetTcpProxiesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_TargetTcpProxies_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.delete.js new file mode 100644 index 00000000000..fdaae80e9b8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, targetTcpProxy) { + // [START compute_v1_generated_TargetTcpProxies_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the TargetTcpProxy resource to delete. + */ + // const targetTcpProxy = 'abc123' + + // Imports the Compute library + const {TargetTcpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetTcpProxiesClient(); + + async function callDelete() { + // Construct request + const request = { + project, + targetTcpProxy, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_TargetTcpProxies_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.get.js new file mode 100644 index 00000000000..a72f43bf709 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(project, targetTcpProxy) { + // [START compute_v1_generated_TargetTcpProxies_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the TargetTcpProxy resource to return. + */ + // const targetTcpProxy = 'abc123' + + // Imports the Compute library + const {TargetTcpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetTcpProxiesClient(); + + async function callGet() { + // Construct request + const request = { + project, + targetTcpProxy, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_TargetTcpProxies_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.insert.js new file mode 100644 index 00000000000..078aecf4eef --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, targetTcpProxyResource) { + // [START compute_v1_generated_TargetTcpProxies_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetTcpProxyResource = {} + + // Imports the Compute library + const {TargetTcpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetTcpProxiesClient(); + + async function callInsert() { + // Construct request + const request = { + project, + targetTcpProxyResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_TargetTcpProxies_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.list.js new file mode 100644 index 00000000000..9da1746bba2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_TargetTcpProxies_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {TargetTcpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetTcpProxiesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_TargetTcpProxies_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.set_backend_service.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.set_backend_service.js new file mode 100644 index 00000000000..fa1a52b083b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.set_backend_service.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, targetTcpProxiesSetBackendServiceRequestResource, targetTcpProxy) { + // [START compute_v1_generated_TargetTcpProxies_SetBackendService_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetTcpProxiesSetBackendServiceRequestResource = {} + /** + * Name of the TargetTcpProxy resource whose BackendService resource is to be set. + */ + // const targetTcpProxy = 'abc123' + + // Imports the Compute library + const {TargetTcpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetTcpProxiesClient(); + + async function callSetBackendService() { + // Construct request + const request = { + project, + targetTcpProxiesSetBackendServiceRequestResource, + targetTcpProxy, + }; + + // Run request + const response = await computeClient.setBackendService(request); + console.log(response); + } + + callSetBackendService(); + // [END compute_v1_generated_TargetTcpProxies_SetBackendService_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.set_proxy_header.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.set_proxy_header.js new file mode 100644 index 00000000000..cb152537f41 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_tcp_proxies.set_proxy_header.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, targetTcpProxiesSetProxyHeaderRequestResource, targetTcpProxy) { + // [START compute_v1_generated_TargetTcpProxies_SetProxyHeader_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetTcpProxiesSetProxyHeaderRequestResource = {} + /** + * Name of the TargetTcpProxy resource whose ProxyHeader is to be set. + */ + // const targetTcpProxy = 'abc123' + + // Imports the Compute library + const {TargetTcpProxiesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetTcpProxiesClient(); + + async function callSetProxyHeader() { + // Construct request + const request = { + project, + targetTcpProxiesSetProxyHeaderRequestResource, + targetTcpProxy, + }; + + // Run request + const response = await computeClient.setProxyHeader(request); + console.log(response); + } + + callSetProxyHeader(); + // [END compute_v1_generated_TargetTcpProxies_SetProxyHeader_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.aggregated_list.js new file mode 100644 index 00000000000..8e832ba24a0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_TargetVpnGateways_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {TargetVpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetVpnGatewaysClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_TargetVpnGateways_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.delete.js new file mode 100644 index 00000000000..0a5c95e0b40 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, targetVpnGateway) { + // [START compute_v1_generated_TargetVpnGateways_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the target VPN gateway to delete. + */ + // const targetVpnGateway = 'abc123' + + // Imports the Compute library + const {TargetVpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetVpnGatewaysClient(); + + async function callDelete() { + // Construct request + const request = { + project, + region, + targetVpnGateway, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_TargetVpnGateways_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.get.js new file mode 100644 index 00000000000..a44a44f2ea7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, targetVpnGateway) { + // [START compute_v1_generated_TargetVpnGateways_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name of the target VPN gateway to return. + */ + // const targetVpnGateway = 'abc123' + + // Imports the Compute library + const {TargetVpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetVpnGatewaysClient(); + + async function callGet() { + // Construct request + const request = { + project, + region, + targetVpnGateway, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_TargetVpnGateways_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.insert.js new file mode 100644 index 00000000000..abf35f4d546 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, targetVpnGatewayResource) { + // [START compute_v1_generated_TargetVpnGateways_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const targetVpnGatewayResource = {} + + // Imports the Compute library + const {TargetVpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetVpnGatewaysClient(); + + async function callInsert() { + // Construct request + const request = { + project, + region, + targetVpnGatewayResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_TargetVpnGateways_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.list.js new file mode 100644 index 00000000000..62d1717a081 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_TargetVpnGateways_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {TargetVpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetVpnGatewaysClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_TargetVpnGateways_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.set_labels.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.set_labels.js new file mode 100644 index 00000000000..74e80b3b853 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/target_vpn_gateways.set_labels.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, regionSetLabelsRequestResource, resource) { + // [START compute_v1_generated_TargetVpnGateways_SetLabels_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionSetLabelsRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {TargetVpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new TargetVpnGatewaysClient(); + + async function callSetLabels() { + // Construct request + const request = { + project, + region, + regionSetLabelsRequestResource, + resource, + }; + + // Run request + const response = await computeClient.setLabels(request); + console.log(response); + } + + callSetLabels(); + // [END compute_v1_generated_TargetVpnGateways_SetLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.aggregated_list.js new file mode 100644 index 00000000000..1f20f97b35d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_UrlMaps_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Name of the project scoping this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {UrlMapsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new UrlMapsClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_UrlMaps_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.delete.js new file mode 100644 index 00000000000..56a8d979b7e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.delete.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, urlMap) { + // [START compute_v1_generated_UrlMaps_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the UrlMap resource to delete. + */ + // const urlMap = 'abc123' + + // Imports the Compute library + const {UrlMapsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new UrlMapsClient(); + + async function callDelete() { + // Construct request + const request = { + project, + urlMap, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_UrlMaps_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.get.js new file mode 100644 index 00000000000..8be3e78ff19 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(project, urlMap) { + // [START compute_v1_generated_UrlMaps_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the UrlMap resource to return. + */ + // const urlMap = 'abc123' + + // Imports the Compute library + const {UrlMapsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new UrlMapsClient(); + + async function callGet() { + // Construct request + const request = { + project, + urlMap, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_UrlMaps_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.insert.js new file mode 100644 index 00000000000..dc7096c0aff --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.insert.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(project, urlMapResource) { + // [START compute_v1_generated_UrlMaps_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const urlMapResource = {} + + // Imports the Compute library + const {UrlMapsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new UrlMapsClient(); + + async function callInsert() { + // Construct request + const request = { + project, + urlMapResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_UrlMaps_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.invalidate_cache.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.invalidate_cache.js new file mode 100644 index 00000000000..614ca61437a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.invalidate_cache.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(cacheInvalidationRuleResource, project, urlMap) { + // [START compute_v1_generated_UrlMaps_InvalidateCache_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. + */ + /** + * The body resource for this request + */ + // const cacheInvalidationRuleResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the UrlMap scoping this request. + */ + // const urlMap = 'abc123' + + // Imports the Compute library + const {UrlMapsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new UrlMapsClient(); + + async function callInvalidateCache() { + // Construct request + const request = { + cacheInvalidationRuleResource, + project, + urlMap, + }; + + // Run request + const response = await computeClient.invalidateCache(request); + console.log(response); + } + + callInvalidateCache(); + // [END compute_v1_generated_UrlMaps_InvalidateCache_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.list.js new file mode 100644 index 00000000000..5b58c060732 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_UrlMaps_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {UrlMapsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new UrlMapsClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_UrlMaps_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.patch.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.patch.js new file mode 100644 index 00000000000..bf62005a941 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.patch.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, urlMap, urlMapResource) { + // [START compute_v1_generated_UrlMaps_Patch_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the UrlMap resource to patch. + */ + // const urlMap = 'abc123' + /** + * The body resource for this request + */ + // const urlMapResource = {} + + // Imports the Compute library + const {UrlMapsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new UrlMapsClient(); + + async function callPatch() { + // Construct request + const request = { + project, + urlMap, + urlMapResource, + }; + + // Run request + const response = await computeClient.patch(request); + console.log(response); + } + + callPatch(); + // [END compute_v1_generated_UrlMaps_Patch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.update.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.update.js new file mode 100644 index 00000000000..fcf04188eac --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.update.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, urlMap, urlMapResource) { + // [START compute_v1_generated_UrlMaps_Update_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the UrlMap resource to update. + */ + // const urlMap = 'abc123' + /** + * The body resource for this request + */ + // const urlMapResource = {} + + // Imports the Compute library + const {UrlMapsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new UrlMapsClient(); + + async function callUpdate() { + // Construct request + const request = { + project, + urlMap, + urlMapResource, + }; + + // Run request + const response = await computeClient.update(request); + console.log(response); + } + + callUpdate(); + // [END compute_v1_generated_UrlMaps_Update_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.validate.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.validate.js new file mode 100644 index 00000000000..0d02106a5e3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/url_maps.validate.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, urlMap, urlMapsValidateRequestResource) { + // [START compute_v1_generated_UrlMaps_Validate_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the UrlMap resource to be validated as. + */ + // const urlMap = 'abc123' + /** + * The body resource for this request + */ + // const urlMapsValidateRequestResource = {} + + // Imports the Compute library + const {UrlMapsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new UrlMapsClient(); + + async function callValidate() { + // Construct request + const request = { + project, + urlMap, + urlMapsValidateRequestResource, + }; + + // Run request + const response = await computeClient.validate(request); + console.log(response); + } + + callValidate(); + // [END compute_v1_generated_UrlMaps_Validate_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.aggregated_list.js new file mode 100644 index 00000000000..8458c721cf4 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_VpnGateways_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {VpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new VpnGatewaysClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_VpnGateways_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.delete.js new file mode 100644 index 00000000000..5bdc7725faf --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, vpnGateway) { + // [START compute_v1_generated_VpnGateways_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the VPN gateway to delete. + */ + // const vpnGateway = 'abc123' + + // Imports the Compute library + const {VpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new VpnGatewaysClient(); + + async function callDelete() { + // Construct request + const request = { + project, + region, + vpnGateway, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_VpnGateways_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.get.js new file mode 100644 index 00000000000..40de8ba6543 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, vpnGateway) { + // [START compute_v1_generated_VpnGateways_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name of the VPN gateway to return. + */ + // const vpnGateway = 'abc123' + + // Imports the Compute library + const {VpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new VpnGatewaysClient(); + + async function callGet() { + // Construct request + const request = { + project, + region, + vpnGateway, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_VpnGateways_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.get_status.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.get_status.js new file mode 100644 index 00000000000..2b875264b5f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.get_status.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, vpnGateway) { + // [START compute_v1_generated_VpnGateways_GetStatus_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name of the VPN gateway to return. + */ + // const vpnGateway = 'abc123' + + // Imports the Compute library + const {VpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new VpnGatewaysClient(); + + async function callGetStatus() { + // Construct request + const request = { + project, + region, + vpnGateway, + }; + + // Run request + const response = await computeClient.getStatus(request); + console.log(response); + } + + callGetStatus(); + // [END compute_v1_generated_VpnGateways_GetStatus_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.insert.js new file mode 100644 index 00000000000..4f48c25dbbf --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, vpnGatewayResource) { + // [START compute_v1_generated_VpnGateways_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const vpnGatewayResource = {} + + // Imports the Compute library + const {VpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new VpnGatewaysClient(); + + async function callInsert() { + // Construct request + const request = { + project, + region, + vpnGatewayResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_VpnGateways_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.list.js new file mode 100644 index 00000000000..53b72c1ba37 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_VpnGateways_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {VpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new VpnGatewaysClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_VpnGateways_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.set_labels.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.set_labels.js new file mode 100644 index 00000000000..657cfa4e7ec --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.set_labels.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, regionSetLabelsRequestResource, resource) { + // [START compute_v1_generated_VpnGateways_SetLabels_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionSetLabelsRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {VpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new VpnGatewaysClient(); + + async function callSetLabels() { + // Construct request + const request = { + project, + region, + regionSetLabelsRequestResource, + resource, + }; + + // Run request + const response = await computeClient.setLabels(request); + console.log(response); + } + + callSetLabels(); + // [END compute_v1_generated_VpnGateways_SetLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.test_iam_permissions.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.test_iam_permissions.js new file mode 100644 index 00000000000..485ef2fcd72 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_gateways.test_iam_permissions.js @@ -0,0 +1,76 @@ +// Copyright 2023 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(project, region, resource, testPermissionsRequestResource) { + // [START compute_v1_generated_VpnGateways_TestIamPermissions_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + /** + * The body resource for this request + */ + // const testPermissionsRequestResource = {} + + // Imports the Compute library + const {VpnGatewaysClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new VpnGatewaysClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + project, + region, + resource, + testPermissionsRequestResource, + }; + + // Run request + const response = await computeClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END compute_v1_generated_VpnGateways_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.aggregated_list.js new file mode 100644 index 00000000000..63e15d7b49d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.aggregated_list.js @@ -0,0 +1,87 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_VpnTunnels_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {VpnTunnelsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new VpnTunnelsClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1_generated_VpnTunnels_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.delete.js new file mode 100644 index 00000000000..85e15fed7bc --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.delete.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, vpnTunnel) { + // [START compute_v1_generated_VpnTunnels_Delete_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name of the VpnTunnel resource to delete. + */ + // const vpnTunnel = 'abc123' + + // Imports the Compute library + const {VpnTunnelsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new VpnTunnelsClient(); + + async function callDelete() { + // Construct request + const request = { + project, + region, + vpnTunnel, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_VpnTunnels_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.get.js new file mode 100644 index 00000000000..3ffab5a0910 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(project, region, vpnTunnel) { + // [START compute_v1_generated_VpnTunnels_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Name of the VpnTunnel resource to return. + */ + // const vpnTunnel = 'abc123' + + // Imports the Compute library + const {VpnTunnelsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new VpnTunnelsClient(); + + async function callGet() { + // Construct request + const request = { + project, + region, + vpnTunnel, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_VpnTunnels_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.insert.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.insert.js new file mode 100644 index 00000000000..9366ce8d68e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.insert.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(project, region, vpnTunnelResource) { + // [START compute_v1_generated_VpnTunnels_Insert_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * The body resource for this request + */ + // const vpnTunnelResource = {} + + // Imports the Compute library + const {VpnTunnelsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new VpnTunnelsClient(); + + async function callInsert() { + // Construct request + const request = { + project, + region, + vpnTunnelResource, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1_generated_VpnTunnels_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.list.js new file mode 100644 index 00000000000..9d2ec691c39 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, region) { + // [START compute_v1_generated_VpnTunnels_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {VpnTunnelsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new VpnTunnelsClient(); + + async function callList() { + // Construct request + const request = { + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_VpnTunnels_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.set_labels.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.set_labels.js new file mode 100644 index 00000000000..b7ca188e56c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/vpn_tunnels.set_labels.js @@ -0,0 +1,80 @@ +// Copyright 2023 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(project, region, regionSetLabelsRequestResource, resource) { + // [START compute_v1_generated_VpnTunnels_SetLabels_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * The region for this request. + */ + // const region = 'us-central1' + /** + * The body resource for this request + */ + // const regionSetLabelsRequestResource = {} + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + /** + * Name or id of the resource for this request. + */ + // const resource = 'abc123' + + // Imports the Compute library + const {VpnTunnelsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new VpnTunnelsClient(); + + async function callSetLabels() { + // Construct request + const request = { + project, + region, + regionSetLabelsRequestResource, + resource, + }; + + // Run request + const response = await computeClient.setLabels(request); + console.log(response); + } + + callSetLabels(); + // [END compute_v1_generated_VpnTunnels_SetLabels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zone_operations.delete.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zone_operations.delete.js new file mode 100644 index 00000000000..d1e8e8b8571 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zone_operations.delete.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(operation, project, zone) { + // [START compute_v1_generated_ZoneOperations_Delete_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. + */ + /** + * Name of the Operations resource to delete. + */ + // const operation = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {ZoneOperationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ZoneOperationsClient(); + + async function callDelete() { + // Construct request + const request = { + operation, + project, + zone, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1_generated_ZoneOperations_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zone_operations.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zone_operations.get.js new file mode 100644 index 00000000000..bc989767159 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zone_operations.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(operation, project, zone) { + // [START compute_v1_generated_ZoneOperations_Get_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. + */ + /** + * Name of the Operations resource to return. + */ + // const operation = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {ZoneOperationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ZoneOperationsClient(); + + async function callGet() { + // Construct request + const request = { + operation, + project, + zone, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_ZoneOperations_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zone_operations.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zone_operations.list.js new file mode 100644 index 00000000000..2cf51bd1bcd --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zone_operations.list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project, zone) { + // [START compute_v1_generated_ZoneOperations_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + /** + * Name of the zone for request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {ZoneOperationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ZoneOperationsClient(); + + async function callList() { + // Construct request + const request = { + project, + zone, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_ZoneOperations_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zone_operations.wait.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zone_operations.wait.js new file mode 100644 index 00000000000..8229aa8a75e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zone_operations.wait.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(operation, project, zone) { + // [START compute_v1_generated_ZoneOperations_Wait_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. + */ + /** + * Name of the Operations resource to return. + */ + // const operation = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the zone for this request. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {ZoneOperationsClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ZoneOperationsClient(); + + async function callWait() { + // Construct request + const request = { + operation, + project, + zone, + }; + + // Run request + const response = await computeClient.wait(request); + console.log(response); + } + + callWait(); + // [END compute_v1_generated_ZoneOperations_Wait_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zones.get.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zones.get.js new file mode 100644 index 00000000000..bee681239a0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zones.get.js @@ -0,0 +1,66 @@ +// Copyright 2023 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(project, zone) { + // [START compute_v1_generated_Zones_Get_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. + */ + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the zone resource to return. + */ + // const zone = 'abc123' + + // Imports the Compute library + const {ZonesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ZonesClient(); + + async function callGet() { + // Construct request + const request = { + project, + zone, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1_generated_Zones_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zones.list.js b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zones.list.js new file mode 100644 index 00000000000..03ccaee9cd8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/samples/generated/v1/zones.list.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(project) { + // [START compute_v1_generated_Zones_List_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. + */ + /** + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + */ + // const returnPartialSuccess = true + + // Imports the Compute library + const {ZonesClient} = require('@google-cloud/compute').v1; + + // Instantiates a client + const computeClient = new ZonesClient(); + + async function callList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1_generated_Zones_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1/src/index.ts b/owl-bot-staging/google-cloud-compute/v1/src/index.ts new file mode 100644 index 00000000000..ecedf9141d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/index.ts @@ -0,0 +1,201 @@ +// Copyright 2023 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 v1 from './v1'; +const AcceleratorTypesClient = v1.AcceleratorTypesClient; +type AcceleratorTypesClient = v1.AcceleratorTypesClient; +const AddressesClient = v1.AddressesClient; +type AddressesClient = v1.AddressesClient; +const AutoscalersClient = v1.AutoscalersClient; +type AutoscalersClient = v1.AutoscalersClient; +const BackendBucketsClient = v1.BackendBucketsClient; +type BackendBucketsClient = v1.BackendBucketsClient; +const BackendServicesClient = v1.BackendServicesClient; +type BackendServicesClient = v1.BackendServicesClient; +const DisksClient = v1.DisksClient; +type DisksClient = v1.DisksClient; +const DiskTypesClient = v1.DiskTypesClient; +type DiskTypesClient = v1.DiskTypesClient; +const ExternalVpnGatewaysClient = v1.ExternalVpnGatewaysClient; +type ExternalVpnGatewaysClient = v1.ExternalVpnGatewaysClient; +const FirewallPoliciesClient = v1.FirewallPoliciesClient; +type FirewallPoliciesClient = v1.FirewallPoliciesClient; +const FirewallsClient = v1.FirewallsClient; +type FirewallsClient = v1.FirewallsClient; +const ForwardingRulesClient = v1.ForwardingRulesClient; +type ForwardingRulesClient = v1.ForwardingRulesClient; +const GlobalAddressesClient = v1.GlobalAddressesClient; +type GlobalAddressesClient = v1.GlobalAddressesClient; +const GlobalForwardingRulesClient = v1.GlobalForwardingRulesClient; +type GlobalForwardingRulesClient = v1.GlobalForwardingRulesClient; +const GlobalNetworkEndpointGroupsClient = v1.GlobalNetworkEndpointGroupsClient; +type GlobalNetworkEndpointGroupsClient = v1.GlobalNetworkEndpointGroupsClient; +const GlobalOperationsClient = v1.GlobalOperationsClient; +type GlobalOperationsClient = v1.GlobalOperationsClient; +const GlobalOrganizationOperationsClient = v1.GlobalOrganizationOperationsClient; +type GlobalOrganizationOperationsClient = v1.GlobalOrganizationOperationsClient; +const GlobalPublicDelegatedPrefixesClient = v1.GlobalPublicDelegatedPrefixesClient; +type GlobalPublicDelegatedPrefixesClient = v1.GlobalPublicDelegatedPrefixesClient; +const HealthChecksClient = v1.HealthChecksClient; +type HealthChecksClient = v1.HealthChecksClient; +const ImageFamilyViewsClient = v1.ImageFamilyViewsClient; +type ImageFamilyViewsClient = v1.ImageFamilyViewsClient; +const ImagesClient = v1.ImagesClient; +type ImagesClient = v1.ImagesClient; +const InstanceGroupManagersClient = v1.InstanceGroupManagersClient; +type InstanceGroupManagersClient = v1.InstanceGroupManagersClient; +const InstanceGroupsClient = v1.InstanceGroupsClient; +type InstanceGroupsClient = v1.InstanceGroupsClient; +const InstancesClient = v1.InstancesClient; +type InstancesClient = v1.InstancesClient; +const InstanceTemplatesClient = v1.InstanceTemplatesClient; +type InstanceTemplatesClient = v1.InstanceTemplatesClient; +const InterconnectAttachmentsClient = v1.InterconnectAttachmentsClient; +type InterconnectAttachmentsClient = v1.InterconnectAttachmentsClient; +const InterconnectLocationsClient = v1.InterconnectLocationsClient; +type InterconnectLocationsClient = v1.InterconnectLocationsClient; +const InterconnectsClient = v1.InterconnectsClient; +type InterconnectsClient = v1.InterconnectsClient; +const LicenseCodesClient = v1.LicenseCodesClient; +type LicenseCodesClient = v1.LicenseCodesClient; +const LicensesClient = v1.LicensesClient; +type LicensesClient = v1.LicensesClient; +const MachineImagesClient = v1.MachineImagesClient; +type MachineImagesClient = v1.MachineImagesClient; +const MachineTypesClient = v1.MachineTypesClient; +type MachineTypesClient = v1.MachineTypesClient; +const NetworkAttachmentsClient = v1.NetworkAttachmentsClient; +type NetworkAttachmentsClient = v1.NetworkAttachmentsClient; +const NetworkEdgeSecurityServicesClient = v1.NetworkEdgeSecurityServicesClient; +type NetworkEdgeSecurityServicesClient = v1.NetworkEdgeSecurityServicesClient; +const NetworkEndpointGroupsClient = v1.NetworkEndpointGroupsClient; +type NetworkEndpointGroupsClient = v1.NetworkEndpointGroupsClient; +const NetworkFirewallPoliciesClient = v1.NetworkFirewallPoliciesClient; +type NetworkFirewallPoliciesClient = v1.NetworkFirewallPoliciesClient; +const NetworksClient = v1.NetworksClient; +type NetworksClient = v1.NetworksClient; +const NodeGroupsClient = v1.NodeGroupsClient; +type NodeGroupsClient = v1.NodeGroupsClient; +const NodeTemplatesClient = v1.NodeTemplatesClient; +type NodeTemplatesClient = v1.NodeTemplatesClient; +const NodeTypesClient = v1.NodeTypesClient; +type NodeTypesClient = v1.NodeTypesClient; +const PacketMirroringsClient = v1.PacketMirroringsClient; +type PacketMirroringsClient = v1.PacketMirroringsClient; +const ProjectsClient = v1.ProjectsClient; +type ProjectsClient = v1.ProjectsClient; +const PublicAdvertisedPrefixesClient = v1.PublicAdvertisedPrefixesClient; +type PublicAdvertisedPrefixesClient = v1.PublicAdvertisedPrefixesClient; +const PublicDelegatedPrefixesClient = v1.PublicDelegatedPrefixesClient; +type PublicDelegatedPrefixesClient = v1.PublicDelegatedPrefixesClient; +const RegionAutoscalersClient = v1.RegionAutoscalersClient; +type RegionAutoscalersClient = v1.RegionAutoscalersClient; +const RegionBackendServicesClient = v1.RegionBackendServicesClient; +type RegionBackendServicesClient = v1.RegionBackendServicesClient; +const RegionCommitmentsClient = v1.RegionCommitmentsClient; +type RegionCommitmentsClient = v1.RegionCommitmentsClient; +const RegionDisksClient = v1.RegionDisksClient; +type RegionDisksClient = v1.RegionDisksClient; +const RegionDiskTypesClient = v1.RegionDiskTypesClient; +type RegionDiskTypesClient = v1.RegionDiskTypesClient; +const RegionHealthChecksClient = v1.RegionHealthChecksClient; +type RegionHealthChecksClient = v1.RegionHealthChecksClient; +const RegionHealthCheckServicesClient = v1.RegionHealthCheckServicesClient; +type RegionHealthCheckServicesClient = v1.RegionHealthCheckServicesClient; +const RegionInstanceGroupManagersClient = v1.RegionInstanceGroupManagersClient; +type RegionInstanceGroupManagersClient = v1.RegionInstanceGroupManagersClient; +const RegionInstanceGroupsClient = v1.RegionInstanceGroupsClient; +type RegionInstanceGroupsClient = v1.RegionInstanceGroupsClient; +const RegionInstancesClient = v1.RegionInstancesClient; +type RegionInstancesClient = v1.RegionInstancesClient; +const RegionInstanceTemplatesClient = v1.RegionInstanceTemplatesClient; +type RegionInstanceTemplatesClient = v1.RegionInstanceTemplatesClient; +const RegionNetworkEndpointGroupsClient = v1.RegionNetworkEndpointGroupsClient; +type RegionNetworkEndpointGroupsClient = v1.RegionNetworkEndpointGroupsClient; +const RegionNetworkFirewallPoliciesClient = v1.RegionNetworkFirewallPoliciesClient; +type RegionNetworkFirewallPoliciesClient = v1.RegionNetworkFirewallPoliciesClient; +const RegionNotificationEndpointsClient = v1.RegionNotificationEndpointsClient; +type RegionNotificationEndpointsClient = v1.RegionNotificationEndpointsClient; +const RegionOperationsClient = v1.RegionOperationsClient; +type RegionOperationsClient = v1.RegionOperationsClient; +const RegionsClient = v1.RegionsClient; +type RegionsClient = v1.RegionsClient; +const RegionSecurityPoliciesClient = v1.RegionSecurityPoliciesClient; +type RegionSecurityPoliciesClient = v1.RegionSecurityPoliciesClient; +const RegionSslCertificatesClient = v1.RegionSslCertificatesClient; +type RegionSslCertificatesClient = v1.RegionSslCertificatesClient; +const RegionSslPoliciesClient = v1.RegionSslPoliciesClient; +type RegionSslPoliciesClient = v1.RegionSslPoliciesClient; +const RegionTargetHttpProxiesClient = v1.RegionTargetHttpProxiesClient; +type RegionTargetHttpProxiesClient = v1.RegionTargetHttpProxiesClient; +const RegionTargetHttpsProxiesClient = v1.RegionTargetHttpsProxiesClient; +type RegionTargetHttpsProxiesClient = v1.RegionTargetHttpsProxiesClient; +const RegionTargetTcpProxiesClient = v1.RegionTargetTcpProxiesClient; +type RegionTargetTcpProxiesClient = v1.RegionTargetTcpProxiesClient; +const RegionUrlMapsClient = v1.RegionUrlMapsClient; +type RegionUrlMapsClient = v1.RegionUrlMapsClient; +const ReservationsClient = v1.ReservationsClient; +type ReservationsClient = v1.ReservationsClient; +const ResourcePoliciesClient = v1.ResourcePoliciesClient; +type ResourcePoliciesClient = v1.ResourcePoliciesClient; +const RoutersClient = v1.RoutersClient; +type RoutersClient = v1.RoutersClient; +const RoutesClient = v1.RoutesClient; +type RoutesClient = v1.RoutesClient; +const SecurityPoliciesClient = v1.SecurityPoliciesClient; +type SecurityPoliciesClient = v1.SecurityPoliciesClient; +const ServiceAttachmentsClient = v1.ServiceAttachmentsClient; +type ServiceAttachmentsClient = v1.ServiceAttachmentsClient; +const SnapshotsClient = v1.SnapshotsClient; +type SnapshotsClient = v1.SnapshotsClient; +const SslCertificatesClient = v1.SslCertificatesClient; +type SslCertificatesClient = v1.SslCertificatesClient; +const SslPoliciesClient = v1.SslPoliciesClient; +type SslPoliciesClient = v1.SslPoliciesClient; +const SubnetworksClient = v1.SubnetworksClient; +type SubnetworksClient = v1.SubnetworksClient; +const TargetGrpcProxiesClient = v1.TargetGrpcProxiesClient; +type TargetGrpcProxiesClient = v1.TargetGrpcProxiesClient; +const TargetHttpProxiesClient = v1.TargetHttpProxiesClient; +type TargetHttpProxiesClient = v1.TargetHttpProxiesClient; +const TargetHttpsProxiesClient = v1.TargetHttpsProxiesClient; +type TargetHttpsProxiesClient = v1.TargetHttpsProxiesClient; +const TargetInstancesClient = v1.TargetInstancesClient; +type TargetInstancesClient = v1.TargetInstancesClient; +const TargetPoolsClient = v1.TargetPoolsClient; +type TargetPoolsClient = v1.TargetPoolsClient; +const TargetSslProxiesClient = v1.TargetSslProxiesClient; +type TargetSslProxiesClient = v1.TargetSslProxiesClient; +const TargetTcpProxiesClient = v1.TargetTcpProxiesClient; +type TargetTcpProxiesClient = v1.TargetTcpProxiesClient; +const TargetVpnGatewaysClient = v1.TargetVpnGatewaysClient; +type TargetVpnGatewaysClient = v1.TargetVpnGatewaysClient; +const UrlMapsClient = v1.UrlMapsClient; +type UrlMapsClient = v1.UrlMapsClient; +const VpnGatewaysClient = v1.VpnGatewaysClient; +type VpnGatewaysClient = v1.VpnGatewaysClient; +const VpnTunnelsClient = v1.VpnTunnelsClient; +type VpnTunnelsClient = v1.VpnTunnelsClient; +const ZoneOperationsClient = v1.ZoneOperationsClient; +type ZoneOperationsClient = v1.ZoneOperationsClient; +const ZonesClient = v1.ZonesClient; +type ZonesClient = v1.ZonesClient; +export {v1, AcceleratorTypesClient, AddressesClient, AutoscalersClient, BackendBucketsClient, BackendServicesClient, DisksClient, DiskTypesClient, ExternalVpnGatewaysClient, FirewallPoliciesClient, FirewallsClient, ForwardingRulesClient, GlobalAddressesClient, GlobalForwardingRulesClient, GlobalNetworkEndpointGroupsClient, GlobalOperationsClient, GlobalOrganizationOperationsClient, GlobalPublicDelegatedPrefixesClient, HealthChecksClient, ImageFamilyViewsClient, ImagesClient, InstanceGroupManagersClient, InstanceGroupsClient, InstancesClient, InstanceTemplatesClient, InterconnectAttachmentsClient, InterconnectLocationsClient, InterconnectsClient, LicenseCodesClient, LicensesClient, MachineImagesClient, MachineTypesClient, NetworkAttachmentsClient, NetworkEdgeSecurityServicesClient, NetworkEndpointGroupsClient, NetworkFirewallPoliciesClient, NetworksClient, NodeGroupsClient, NodeTemplatesClient, NodeTypesClient, PacketMirroringsClient, ProjectsClient, PublicAdvertisedPrefixesClient, PublicDelegatedPrefixesClient, RegionAutoscalersClient, RegionBackendServicesClient, RegionCommitmentsClient, RegionDisksClient, RegionDiskTypesClient, RegionHealthChecksClient, RegionHealthCheckServicesClient, RegionInstanceGroupManagersClient, RegionInstanceGroupsClient, RegionInstancesClient, RegionInstanceTemplatesClient, RegionNetworkEndpointGroupsClient, RegionNetworkFirewallPoliciesClient, RegionNotificationEndpointsClient, RegionOperationsClient, RegionsClient, RegionSecurityPoliciesClient, RegionSslCertificatesClient, RegionSslPoliciesClient, RegionTargetHttpProxiesClient, RegionTargetHttpsProxiesClient, RegionTargetTcpProxiesClient, RegionUrlMapsClient, ReservationsClient, ResourcePoliciesClient, RoutersClient, RoutesClient, SecurityPoliciesClient, ServiceAttachmentsClient, SnapshotsClient, SslCertificatesClient, SslPoliciesClient, SubnetworksClient, TargetGrpcProxiesClient, TargetHttpProxiesClient, TargetHttpsProxiesClient, TargetInstancesClient, TargetPoolsClient, TargetSslProxiesClient, TargetTcpProxiesClient, TargetVpnGatewaysClient, UrlMapsClient, VpnGatewaysClient, VpnTunnelsClient, ZoneOperationsClient, ZonesClient}; +export default {v1, AcceleratorTypesClient, AddressesClient, AutoscalersClient, BackendBucketsClient, BackendServicesClient, DisksClient, DiskTypesClient, ExternalVpnGatewaysClient, FirewallPoliciesClient, FirewallsClient, ForwardingRulesClient, GlobalAddressesClient, GlobalForwardingRulesClient, GlobalNetworkEndpointGroupsClient, GlobalOperationsClient, GlobalOrganizationOperationsClient, GlobalPublicDelegatedPrefixesClient, HealthChecksClient, ImageFamilyViewsClient, ImagesClient, InstanceGroupManagersClient, InstanceGroupsClient, InstancesClient, InstanceTemplatesClient, InterconnectAttachmentsClient, InterconnectLocationsClient, InterconnectsClient, LicenseCodesClient, LicensesClient, MachineImagesClient, MachineTypesClient, NetworkAttachmentsClient, NetworkEdgeSecurityServicesClient, NetworkEndpointGroupsClient, NetworkFirewallPoliciesClient, NetworksClient, NodeGroupsClient, NodeTemplatesClient, NodeTypesClient, PacketMirroringsClient, ProjectsClient, PublicAdvertisedPrefixesClient, PublicDelegatedPrefixesClient, RegionAutoscalersClient, RegionBackendServicesClient, RegionCommitmentsClient, RegionDisksClient, RegionDiskTypesClient, RegionHealthChecksClient, RegionHealthCheckServicesClient, RegionInstanceGroupManagersClient, RegionInstanceGroupsClient, RegionInstancesClient, RegionInstanceTemplatesClient, RegionNetworkEndpointGroupsClient, RegionNetworkFirewallPoliciesClient, RegionNotificationEndpointsClient, RegionOperationsClient, RegionsClient, RegionSecurityPoliciesClient, RegionSslCertificatesClient, RegionSslPoliciesClient, RegionTargetHttpProxiesClient, RegionTargetHttpsProxiesClient, RegionTargetTcpProxiesClient, RegionUrlMapsClient, ReservationsClient, ResourcePoliciesClient, RoutersClient, RoutesClient, SecurityPoliciesClient, ServiceAttachmentsClient, SnapshotsClient, SslCertificatesClient, SslPoliciesClient, SubnetworksClient, TargetGrpcProxiesClient, TargetHttpProxiesClient, TargetHttpsProxiesClient, TargetInstancesClient, TargetPoolsClient, TargetSslProxiesClient, TargetTcpProxiesClient, TargetVpnGatewaysClient, UrlMapsClient, VpnGatewaysClient, VpnTunnelsClient, ZoneOperationsClient, ZonesClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/accelerator_types_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/accelerator_types_client.ts new file mode 100644 index 00000000000..fd0f028cb87 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/accelerator_types_client.ts @@ -0,0 +1,656 @@ +// Copyright 2023 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/accelerator_types_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './accelerator_types_client_config.json'; +const version = require('../../../package.json').version; + +/** + * + * Services + * + * The AcceleratorTypes API. + * @class + * @memberof v1 + */ +export class AcceleratorTypesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + acceleratorTypesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of AcceleratorTypesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new AcceleratorTypesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof AcceleratorTypesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.AcceleratorTypes', 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.acceleratorTypesStub) { + return this.acceleratorTypesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.AcceleratorTypes. + this.acceleratorTypesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.AcceleratorTypes') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.AcceleratorTypes, + 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 acceleratorTypesStubMethods = + ['aggregatedList', 'get', 'list']; + for (const methodName of acceleratorTypesStubMethods) { + const callPromise = this.acceleratorTypesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.acceleratorTypesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute.readonly', + 'https://www.googleapis.com/auth/compute', + '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 -- + // ------------------- +/** + * Returns the specified accelerator type. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.acceleratorType + * Name of the accelerator type to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.AcceleratorType | AcceleratorType}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/accelerator_types.get.js + * region_tag:compute_v1_generated_AcceleratorTypes_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetAcceleratorTypeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IAcceleratorType, + protos.google.cloud.compute.v1.IGetAcceleratorTypeRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetAcceleratorTypeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IAcceleratorType, + protos.google.cloud.compute.v1.IGetAcceleratorTypeRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetAcceleratorTypeRequest, + callback: Callback< + protos.google.cloud.compute.v1.IAcceleratorType, + protos.google.cloud.compute.v1.IGetAcceleratorTypeRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetAcceleratorTypeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IAcceleratorType, + protos.google.cloud.compute.v1.IGetAcceleratorTypeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IAcceleratorType, + protos.google.cloud.compute.v1.IGetAcceleratorTypeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IAcceleratorType, + protos.google.cloud.compute.v1.IGetAcceleratorTypeRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'accelerator_type': request.acceleratorType ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } + + +/** + * Retrieves an aggregated list of accelerator types. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.AcceleratorTypesScopedList | AcceleratorTypesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/accelerator_types.aggregated_list.js + * region_tag:compute_v1_generated_AcceleratorTypes_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListAcceleratorTypesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IAcceleratorTypesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IAcceleratorTypesScopedList]>; + } + /** + * Retrieves a list of accelerator types that are available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.AcceleratorType | AcceleratorType}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListAcceleratorTypesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IAcceleratorType[], + protos.google.cloud.compute.v1.IListAcceleratorTypesRequest|null, + protos.google.cloud.compute.v1.IAcceleratorTypeList + ]>; + list( + request: protos.google.cloud.compute.v1.IListAcceleratorTypesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListAcceleratorTypesRequest, + protos.google.cloud.compute.v1.IAcceleratorTypeList|null|undefined, + protos.google.cloud.compute.v1.IAcceleratorType>): void; + list( + request: protos.google.cloud.compute.v1.IListAcceleratorTypesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListAcceleratorTypesRequest, + protos.google.cloud.compute.v1.IAcceleratorTypeList|null|undefined, + protos.google.cloud.compute.v1.IAcceleratorType>): void; + list( + request?: protos.google.cloud.compute.v1.IListAcceleratorTypesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListAcceleratorTypesRequest, + protos.google.cloud.compute.v1.IAcceleratorTypeList|null|undefined, + protos.google.cloud.compute.v1.IAcceleratorType>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListAcceleratorTypesRequest, + protos.google.cloud.compute.v1.IAcceleratorTypeList|null|undefined, + protos.google.cloud.compute.v1.IAcceleratorType>): + Promise<[ + protos.google.cloud.compute.v1.IAcceleratorType[], + protos.google.cloud.compute.v1.IListAcceleratorTypesRequest|null, + protos.google.cloud.compute.v1.IAcceleratorTypeList + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.AcceleratorType | AcceleratorType} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListAcceleratorTypesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.AcceleratorType | AcceleratorType}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/accelerator_types.list.js + * region_tag:compute_v1_generated_AcceleratorTypes_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListAcceleratorTypesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.acceleratorTypesStub && !this._terminated) { + return this.acceleratorTypesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/accelerator_types_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/accelerator_types_client_config.json new file mode 100644 index 00000000000..c78002c0a85 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/accelerator_types_client_config.json @@ -0,0 +1,38 @@ +{ + "interfaces": { + "google.cloud.compute.v1.AcceleratorTypes": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/accelerator_types_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/accelerator_types_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/accelerator_types_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/addresses_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/addresses_client.ts new file mode 100644 index 00000000000..66c290814fc --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/addresses_client.ts @@ -0,0 +1,926 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/addresses_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './addresses_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Addresses API. + * @class + * @memberof v1 + */ +export class AddressesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + addressesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of AddressesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new AddressesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof AddressesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.Addresses', 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.addressesStub) { + return this.addressesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.Addresses. + this.addressesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Addresses') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.Addresses, + 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 addressesStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'list', 'setLabels']; + for (const methodName of addressesStubMethods) { + const callPromise = this.addressesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.addressesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified address resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.address + * Name of the address resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/addresses.delete.js + * region_tag:compute_v1_generated_Addresses_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteAddressRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteAddressRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteAddressRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteAddressRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteAddressRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteAddressRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteAddressRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteAddressRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'address': request.address ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified address resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.address + * Name of the address resource to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @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.compute.v1.Address | Address}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/addresses.get.js + * region_tag:compute_v1_generated_Addresses_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetAddressRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IAddress, + protos.google.cloud.compute.v1.IGetAddressRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetAddressRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IAddress, + protos.google.cloud.compute.v1.IGetAddressRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetAddressRequest, + callback: Callback< + protos.google.cloud.compute.v1.IAddress, + protos.google.cloud.compute.v1.IGetAddressRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetAddressRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IAddress, + protos.google.cloud.compute.v1.IGetAddressRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IAddress, + protos.google.cloud.compute.v1.IGetAddressRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IAddress, + protos.google.cloud.compute.v1.IGetAddressRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'address': request.address ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates an address resource in the specified project by using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.Address} request.addressResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/addresses.insert.js + * region_tag:compute_v1_generated_Addresses_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertAddressRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertAddressRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertAddressRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertAddressRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertAddressRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertAddressRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertAddressRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertAddressRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the labels on an Address. To learn more about labels, read the Labeling Resources documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The region for this request. + * @param {google.cloud.compute.v1.RegionSetLabelsRequest} request.regionSetLabelsRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.resource + * Name or id of the resource for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/addresses.set_labels.js + * region_tag:compute_v1_generated_Addresses_SetLabels_async + */ + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsAddressRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsAddressRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsAddressRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsAddressRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsAddressRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsAddressRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsAddressRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsAddressRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setLabels(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves an aggregated list of addresses. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.AddressesScopedList | AddressesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/addresses.aggregated_list.js + * region_tag:compute_v1_generated_Addresses_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListAddressesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IAddressesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IAddressesScopedList]>; + } + /** + * Retrieves a list of addresses contained within the specified region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Address | Address}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListAddressesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IAddress[], + protos.google.cloud.compute.v1.IListAddressesRequest|null, + protos.google.cloud.compute.v1.IAddressList + ]>; + list( + request: protos.google.cloud.compute.v1.IListAddressesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListAddressesRequest, + protos.google.cloud.compute.v1.IAddressList|null|undefined, + protos.google.cloud.compute.v1.IAddress>): void; + list( + request: protos.google.cloud.compute.v1.IListAddressesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListAddressesRequest, + protos.google.cloud.compute.v1.IAddressList|null|undefined, + protos.google.cloud.compute.v1.IAddress>): void; + list( + request?: protos.google.cloud.compute.v1.IListAddressesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListAddressesRequest, + protos.google.cloud.compute.v1.IAddressList|null|undefined, + protos.google.cloud.compute.v1.IAddress>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListAddressesRequest, + protos.google.cloud.compute.v1.IAddressList|null|undefined, + protos.google.cloud.compute.v1.IAddress>): + Promise<[ + protos.google.cloud.compute.v1.IAddress[], + protos.google.cloud.compute.v1.IListAddressesRequest|null, + protos.google.cloud.compute.v1.IAddressList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Address | Address} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListAddressesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Address | Address}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/addresses.list.js + * region_tag:compute_v1_generated_Addresses_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListAddressesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.addressesStub && !this._terminated) { + return this.addressesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/addresses_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/addresses_client_config.json new file mode 100644 index 00000000000..08286c6d230 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/addresses_client_config.json @@ -0,0 +1,50 @@ +{ + "interfaces": { + "google.cloud.compute.v1.Addresses": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetLabels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/addresses_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/addresses_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/addresses_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/autoscalers_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/autoscalers_client.ts new file mode 100644 index 00000000000..0b2d1b1184c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/autoscalers_client.ts @@ -0,0 +1,1017 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/autoscalers_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './autoscalers_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Autoscalers API. + * @class + * @memberof v1 + */ +export class AutoscalersClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + autoscalersStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of AutoscalersClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new AutoscalersClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof AutoscalersClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.Autoscalers', 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.autoscalersStub) { + return this.autoscalersStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.Autoscalers. + this.autoscalersStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Autoscalers') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.Autoscalers, + 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 autoscalersStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'list', 'patch', 'update']; + for (const methodName of autoscalersStubMethods) { + const callPromise = this.autoscalersStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.autoscalersStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified autoscaler. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.autoscaler + * Name of the autoscaler to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * Name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/autoscalers.delete.js + * region_tag:compute_v1_generated_Autoscalers_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteAutoscalerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteAutoscalerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteAutoscalerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteAutoscalerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteAutoscalerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteAutoscalerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'autoscaler': request.autoscaler ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified autoscaler resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.autoscaler + * Name of the autoscaler to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * Name of the zone for this request. + * @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.compute.v1.Autoscaler | Autoscaler}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/autoscalers.get.js + * region_tag:compute_v1_generated_Autoscalers_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetAutoscalerRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IAutoscaler, + protos.google.cloud.compute.v1.IGetAutoscalerRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetAutoscalerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IAutoscaler, + protos.google.cloud.compute.v1.IGetAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetAutoscalerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IAutoscaler, + protos.google.cloud.compute.v1.IGetAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetAutoscalerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IAutoscaler, + protos.google.cloud.compute.v1.IGetAutoscalerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IAutoscaler, + protos.google.cloud.compute.v1.IGetAutoscalerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IAutoscaler, + protos.google.cloud.compute.v1.IGetAutoscalerRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'autoscaler': request.autoscaler ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates an autoscaler in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.Autoscaler} request.autoscalerResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * Name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/autoscalers.insert.js + * region_tag:compute_v1_generated_Autoscalers_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertAutoscalerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertAutoscalerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertAutoscalerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertAutoscalerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertAutoscalerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertAutoscalerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates an autoscaler in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.autoscaler + * Name of the autoscaler to patch. + * @param {google.cloud.compute.v1.Autoscaler} request.autoscalerResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * Name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/autoscalers.patch.js + * region_tag:compute_v1_generated_Autoscalers_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchAutoscalerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchAutoscalerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchAutoscalerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchAutoscalerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchAutoscalerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchAutoscalerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates an autoscaler in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.autoscaler + * Name of the autoscaler to update. + * @param {google.cloud.compute.v1.Autoscaler} request.autoscalerResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * Name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/autoscalers.update.js + * region_tag:compute_v1_generated_Autoscalers_Update_async + */ + update( + request?: protos.google.cloud.compute.v1.IUpdateAutoscalerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + update( + request: protos.google.cloud.compute.v1.IUpdateAutoscalerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + update( + request: protos.google.cloud.compute.v1.IUpdateAutoscalerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + update( + request?: protos.google.cloud.compute.v1.IUpdateAutoscalerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateAutoscalerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateAutoscalerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.update(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves an aggregated list of autoscalers. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.AutoscalersScopedList | AutoscalersScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/autoscalers.aggregated_list.js + * region_tag:compute_v1_generated_Autoscalers_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListAutoscalersRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IAutoscalersScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IAutoscalersScopedList]>; + } + /** + * Retrieves a list of autoscalers contained within the specified zone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * Name of the zone for this request. + * @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 google.cloud.compute.v1.Autoscaler | Autoscaler}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListAutoscalersRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IAutoscaler[], + protos.google.cloud.compute.v1.IListAutoscalersRequest|null, + protos.google.cloud.compute.v1.IAutoscalerList + ]>; + list( + request: protos.google.cloud.compute.v1.IListAutoscalersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListAutoscalersRequest, + protos.google.cloud.compute.v1.IAutoscalerList|null|undefined, + protos.google.cloud.compute.v1.IAutoscaler>): void; + list( + request: protos.google.cloud.compute.v1.IListAutoscalersRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListAutoscalersRequest, + protos.google.cloud.compute.v1.IAutoscalerList|null|undefined, + protos.google.cloud.compute.v1.IAutoscaler>): void; + list( + request?: protos.google.cloud.compute.v1.IListAutoscalersRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListAutoscalersRequest, + protos.google.cloud.compute.v1.IAutoscalerList|null|undefined, + protos.google.cloud.compute.v1.IAutoscaler>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListAutoscalersRequest, + protos.google.cloud.compute.v1.IAutoscalerList|null|undefined, + protos.google.cloud.compute.v1.IAutoscaler>): + Promise<[ + protos.google.cloud.compute.v1.IAutoscaler[], + protos.google.cloud.compute.v1.IListAutoscalersRequest|null, + protos.google.cloud.compute.v1.IAutoscalerList + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * Name of the zone for this request. + * @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 google.cloud.compute.v1.Autoscaler | Autoscaler} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListAutoscalersRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * Name of the zone for this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Autoscaler | Autoscaler}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/autoscalers.list.js + * region_tag:compute_v1_generated_Autoscalers_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListAutoscalersRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.autoscalersStub && !this._terminated) { + return this.autoscalersStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/autoscalers_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/autoscalers_client_config.json new file mode 100644 index 00000000000..38ec0371255 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/autoscalers_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.compute.v1.Autoscalers": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Update": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/autoscalers_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/autoscalers_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/autoscalers_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_buckets_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_buckets_client.ts new file mode 100644 index 00000000000..f6c5828128a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_buckets_client.ts @@ -0,0 +1,1207 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/backend_buckets_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './backend_buckets_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The BackendBuckets API. + * @class + * @memberof v1 + */ +export class BackendBucketsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + backendBucketsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of BackendBucketsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new BackendBucketsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof BackendBucketsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.BackendBuckets', 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.backendBucketsStub) { + return this.backendBucketsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.BackendBuckets. + this.backendBucketsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.BackendBuckets') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.BackendBuckets, + 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 backendBucketsStubMethods = + ['addSignedUrlKey', 'delete', 'deleteSignedUrlKey', 'get', 'insert', 'list', 'patch', 'setEdgeSecurityPolicy', 'update']; + for (const methodName of backendBucketsStubMethods) { + const callPromise = this.backendBucketsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.backendBucketsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Adds a key for validating requests with signed URLs for this backend bucket. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendBucket + * Name of the BackendBucket resource to which the Signed URL Key should be added. The name should conform to RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.SignedUrlKey} request.signedUrlKeyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/backend_buckets.add_signed_url_key.js + * region_tag:compute_v1_generated_BackendBuckets_AddSignedUrlKey_async + */ + addSignedUrlKey( + request?: protos.google.cloud.compute.v1.IAddSignedUrlKeyBackendBucketRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addSignedUrlKey( + request: protos.google.cloud.compute.v1.IAddSignedUrlKeyBackendBucketRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddSignedUrlKeyBackendBucketRequest|null|undefined, + {}|null|undefined>): void; + addSignedUrlKey( + request: protos.google.cloud.compute.v1.IAddSignedUrlKeyBackendBucketRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddSignedUrlKeyBackendBucketRequest|null|undefined, + {}|null|undefined>): void; + addSignedUrlKey( + request?: protos.google.cloud.compute.v1.IAddSignedUrlKeyBackendBucketRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddSignedUrlKeyBackendBucketRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddSignedUrlKeyBackendBucketRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'backend_bucket': request.backendBucket ?? '', + }); + this.initialize(); + return this.innerApiCalls.addSignedUrlKey(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified BackendBucket resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendBucket + * Name of the BackendBucket resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/backend_buckets.delete.js + * region_tag:compute_v1_generated_BackendBuckets_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteBackendBucketRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteBackendBucketRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteBackendBucketRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteBackendBucketRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteBackendBucketRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteBackendBucketRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteBackendBucketRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteBackendBucketRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'backend_bucket': request.backendBucket ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes a key for validating requests with signed URLs for this backend bucket. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendBucket + * Name of the BackendBucket resource to which the Signed URL Key should be added. The name should conform to RFC1035. + * @param {string} request.keyName + * The name of the Signed URL Key to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/backend_buckets.delete_signed_url_key.js + * region_tag:compute_v1_generated_BackendBuckets_DeleteSignedUrlKey_async + */ + deleteSignedUrlKey( + request?: protos.google.cloud.compute.v1.IDeleteSignedUrlKeyBackendBucketRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + deleteSignedUrlKey( + request: protos.google.cloud.compute.v1.IDeleteSignedUrlKeyBackendBucketRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSignedUrlKeyBackendBucketRequest|null|undefined, + {}|null|undefined>): void; + deleteSignedUrlKey( + request: protos.google.cloud.compute.v1.IDeleteSignedUrlKeyBackendBucketRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSignedUrlKeyBackendBucketRequest|null|undefined, + {}|null|undefined>): void; + deleteSignedUrlKey( + request?: protos.google.cloud.compute.v1.IDeleteSignedUrlKeyBackendBucketRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSignedUrlKeyBackendBucketRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSignedUrlKeyBackendBucketRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'backend_bucket': request.backendBucket ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteSignedUrlKey(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified BackendBucket resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendBucket + * Name of the BackendBucket resource to return. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.BackendBucket | BackendBucket}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/backend_buckets.get.js + * region_tag:compute_v1_generated_BackendBuckets_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetBackendBucketRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IBackendBucket, + protos.google.cloud.compute.v1.IGetBackendBucketRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetBackendBucketRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IBackendBucket, + protos.google.cloud.compute.v1.IGetBackendBucketRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetBackendBucketRequest, + callback: Callback< + protos.google.cloud.compute.v1.IBackendBucket, + protos.google.cloud.compute.v1.IGetBackendBucketRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetBackendBucketRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IBackendBucket, + protos.google.cloud.compute.v1.IGetBackendBucketRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IBackendBucket, + protos.google.cloud.compute.v1.IGetBackendBucketRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IBackendBucket, + protos.google.cloud.compute.v1.IGetBackendBucketRequest|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({ + 'project': request.project ?? '', + 'backend_bucket': request.backendBucket ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a BackendBucket resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.BackendBucket} request.backendBucketResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/backend_buckets.insert.js + * region_tag:compute_v1_generated_BackendBuckets_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertBackendBucketRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertBackendBucketRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertBackendBucketRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertBackendBucketRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertBackendBucketRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertBackendBucketRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertBackendBucketRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertBackendBucketRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified BackendBucket resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendBucket + * Name of the BackendBucket resource to patch. + * @param {google.cloud.compute.v1.BackendBucket} request.backendBucketResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/backend_buckets.patch.js + * region_tag:compute_v1_generated_BackendBuckets_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchBackendBucketRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchBackendBucketRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchBackendBucketRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchBackendBucketRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchBackendBucketRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchBackendBucketRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchBackendBucketRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchBackendBucketRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'backend_bucket': request.backendBucket ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the edge security policy for the specified backend bucket. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendBucket + * Name of the BackendService resource to which the security policy should be set. The name should conform to RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.SecurityPolicyReference} request.securityPolicyReferenceResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/backend_buckets.set_edge_security_policy.js + * region_tag:compute_v1_generated_BackendBuckets_SetEdgeSecurityPolicy_async + */ + setEdgeSecurityPolicy( + request?: protos.google.cloud.compute.v1.ISetEdgeSecurityPolicyBackendBucketRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setEdgeSecurityPolicy( + request: protos.google.cloud.compute.v1.ISetEdgeSecurityPolicyBackendBucketRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetEdgeSecurityPolicyBackendBucketRequest|null|undefined, + {}|null|undefined>): void; + setEdgeSecurityPolicy( + request: protos.google.cloud.compute.v1.ISetEdgeSecurityPolicyBackendBucketRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetEdgeSecurityPolicyBackendBucketRequest|null|undefined, + {}|null|undefined>): void; + setEdgeSecurityPolicy( + request?: protos.google.cloud.compute.v1.ISetEdgeSecurityPolicyBackendBucketRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetEdgeSecurityPolicyBackendBucketRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetEdgeSecurityPolicyBackendBucketRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'backend_bucket': request.backendBucket ?? '', + }); + this.initialize(); + return this.innerApiCalls.setEdgeSecurityPolicy(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified BackendBucket resource with the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendBucket + * Name of the BackendBucket resource to update. + * @param {google.cloud.compute.v1.BackendBucket} request.backendBucketResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/backend_buckets.update.js + * region_tag:compute_v1_generated_BackendBuckets_Update_async + */ + update( + request?: protos.google.cloud.compute.v1.IUpdateBackendBucketRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + update( + request: protos.google.cloud.compute.v1.IUpdateBackendBucketRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateBackendBucketRequest|null|undefined, + {}|null|undefined>): void; + update( + request: protos.google.cloud.compute.v1.IUpdateBackendBucketRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateBackendBucketRequest|null|undefined, + {}|null|undefined>): void; + update( + request?: protos.google.cloud.compute.v1.IUpdateBackendBucketRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateBackendBucketRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateBackendBucketRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'backend_bucket': request.backendBucket ?? '', + }); + this.initialize(); + return this.innerApiCalls.update(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves the list of BackendBucket resources available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.BackendBucket | BackendBucket}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListBackendBucketsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IBackendBucket[], + protos.google.cloud.compute.v1.IListBackendBucketsRequest|null, + protos.google.cloud.compute.v1.IBackendBucketList + ]>; + list( + request: protos.google.cloud.compute.v1.IListBackendBucketsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListBackendBucketsRequest, + protos.google.cloud.compute.v1.IBackendBucketList|null|undefined, + protos.google.cloud.compute.v1.IBackendBucket>): void; + list( + request: protos.google.cloud.compute.v1.IListBackendBucketsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListBackendBucketsRequest, + protos.google.cloud.compute.v1.IBackendBucketList|null|undefined, + protos.google.cloud.compute.v1.IBackendBucket>): void; + list( + request?: protos.google.cloud.compute.v1.IListBackendBucketsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListBackendBucketsRequest, + protos.google.cloud.compute.v1.IBackendBucketList|null|undefined, + protos.google.cloud.compute.v1.IBackendBucket>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListBackendBucketsRequest, + protos.google.cloud.compute.v1.IBackendBucketList|null|undefined, + protos.google.cloud.compute.v1.IBackendBucket>): + Promise<[ + protos.google.cloud.compute.v1.IBackendBucket[], + protos.google.cloud.compute.v1.IListBackendBucketsRequest|null, + protos.google.cloud.compute.v1.IBackendBucketList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.BackendBucket | BackendBucket} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListBackendBucketsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.BackendBucket | BackendBucket}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/backend_buckets.list.js + * region_tag:compute_v1_generated_BackendBuckets_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListBackendBucketsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.backendBucketsStub && !this._terminated) { + return this.backendBucketsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_buckets_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_buckets_client_config.json new file mode 100644 index 00000000000..2c4ab2e1738 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_buckets_client_config.json @@ -0,0 +1,62 @@ +{ + "interfaces": { + "google.cloud.compute.v1.BackendBuckets": { + "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": { + "AddSignedUrlKey": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteSignedUrlKey": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetEdgeSecurityPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Update": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_buckets_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_buckets_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_buckets_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_services_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_services_client.ts new file mode 100644 index 00000000000..2273ee1f3f3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_services_client.ts @@ -0,0 +1,1582 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/backend_services_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './backend_services_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The BackendServices API. + * @class + * @memberof v1 + */ +export class BackendServicesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + backendServicesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of BackendServicesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new BackendServicesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof BackendServicesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.BackendServices', 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.backendServicesStub) { + return this.backendServicesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.BackendServices. + this.backendServicesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.BackendServices') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.BackendServices, + 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 backendServicesStubMethods = + ['addSignedUrlKey', 'aggregatedList', 'delete', 'deleteSignedUrlKey', 'get', 'getHealth', 'getIamPolicy', 'insert', 'list', 'patch', 'setEdgeSecurityPolicy', 'setIamPolicy', 'setSecurityPolicy', 'update']; + for (const methodName of backendServicesStubMethods) { + const callPromise = this.backendServicesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.backendServicesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Adds a key for validating requests with signed URLs for this backend service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendService + * Name of the BackendService resource to which the Signed URL Key should be added. The name should conform to RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.SignedUrlKey} request.signedUrlKeyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/backend_services.add_signed_url_key.js + * region_tag:compute_v1_generated_BackendServices_AddSignedUrlKey_async + */ + addSignedUrlKey( + request?: protos.google.cloud.compute.v1.IAddSignedUrlKeyBackendServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addSignedUrlKey( + request: protos.google.cloud.compute.v1.IAddSignedUrlKeyBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddSignedUrlKeyBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + addSignedUrlKey( + request: protos.google.cloud.compute.v1.IAddSignedUrlKeyBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddSignedUrlKeyBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + addSignedUrlKey( + request?: protos.google.cloud.compute.v1.IAddSignedUrlKeyBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddSignedUrlKeyBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddSignedUrlKeyBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'backend_service': request.backendService ?? '', + }); + this.initialize(); + return this.innerApiCalls.addSignedUrlKey(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified BackendService resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendService + * Name of the BackendService resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/backend_services.delete.js + * region_tag:compute_v1_generated_BackendServices_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteBackendServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'backend_service': request.backendService ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes a key for validating requests with signed URLs for this backend service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendService + * Name of the BackendService resource to which the Signed URL Key should be added. The name should conform to RFC1035. + * @param {string} request.keyName + * The name of the Signed URL Key to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/backend_services.delete_signed_url_key.js + * region_tag:compute_v1_generated_BackendServices_DeleteSignedUrlKey_async + */ + deleteSignedUrlKey( + request?: protos.google.cloud.compute.v1.IDeleteSignedUrlKeyBackendServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + deleteSignedUrlKey( + request: protos.google.cloud.compute.v1.IDeleteSignedUrlKeyBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSignedUrlKeyBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + deleteSignedUrlKey( + request: protos.google.cloud.compute.v1.IDeleteSignedUrlKeyBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSignedUrlKeyBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + deleteSignedUrlKey( + request?: protos.google.cloud.compute.v1.IDeleteSignedUrlKeyBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSignedUrlKeyBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSignedUrlKeyBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'backend_service': request.backendService ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteSignedUrlKey(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified BackendService resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendService + * Name of the BackendService resource to return. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.BackendService | BackendService}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/backend_services.get.js + * region_tag:compute_v1_generated_BackendServices_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetBackendServiceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IBackendService, + protos.google.cloud.compute.v1.IGetBackendServiceRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IBackendService, + protos.google.cloud.compute.v1.IGetBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IBackendService, + protos.google.cloud.compute.v1.IGetBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IBackendService, + protos.google.cloud.compute.v1.IGetBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IBackendService, + protos.google.cloud.compute.v1.IGetBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IBackendService, + protos.google.cloud.compute.v1.IGetBackendServiceRequest|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({ + 'project': request.project ?? '', + 'backend_service': request.backendService ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the most recent health check results for this BackendService. Example request body: { "group": "/zones/us-east1-b/instanceGroups/lb-backend-example" } + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendService + * Name of the BackendService resource to which the queried instance belongs. + * @param {string} request.project + * @param {google.cloud.compute.v1.ResourceGroupReference} request.resourceGroupReferenceResource + * The body resource for this request + * @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.compute.v1.BackendServiceGroupHealth | BackendServiceGroupHealth}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/backend_services.get_health.js + * region_tag:compute_v1_generated_BackendServices_GetHealth_async + */ + getHealth( + request?: protos.google.cloud.compute.v1.IGetHealthBackendServiceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IBackendServiceGroupHealth, + protos.google.cloud.compute.v1.IGetHealthBackendServiceRequest|undefined, {}|undefined + ]>; + getHealth( + request: protos.google.cloud.compute.v1.IGetHealthBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IBackendServiceGroupHealth, + protos.google.cloud.compute.v1.IGetHealthBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + getHealth( + request: protos.google.cloud.compute.v1.IGetHealthBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IBackendServiceGroupHealth, + protos.google.cloud.compute.v1.IGetHealthBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + getHealth( + request?: protos.google.cloud.compute.v1.IGetHealthBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IBackendServiceGroupHealth, + protos.google.cloud.compute.v1.IGetHealthBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IBackendServiceGroupHealth, + protos.google.cloud.compute.v1.IGetHealthBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IBackendServiceGroupHealth, + protos.google.cloud.compute.v1.IGetHealthBackendServiceRequest|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({ + 'project': request.project ?? '', + 'backend_service': request.backendService ?? '', + }); + this.initialize(); + return this.innerApiCalls.getHealth(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/backend_services.get_iam_policy.js + * region_tag:compute_v1_generated_BackendServices_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyBackendServiceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyBackendServiceRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyBackendServiceRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Creates a BackendService resource in the specified project using the data included in the request. For more information, see Backend services overview . + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.BackendService} request.backendServiceResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/backend_services.insert.js + * region_tag:compute_v1_generated_BackendServices_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertBackendServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified BackendService resource with the data included in the request. For more information, see Backend services overview. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendService + * Name of the BackendService resource to patch. + * @param {google.cloud.compute.v1.BackendService} request.backendServiceResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/backend_services.patch.js + * region_tag:compute_v1_generated_BackendServices_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchBackendServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'backend_service': request.backendService ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the edge security policy for the specified backend service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendService + * Name of the BackendService resource to which the edge security policy should be set. The name should conform to RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.SecurityPolicyReference} request.securityPolicyReferenceResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/backend_services.set_edge_security_policy.js + * region_tag:compute_v1_generated_BackendServices_SetEdgeSecurityPolicy_async + */ + setEdgeSecurityPolicy( + request?: protos.google.cloud.compute.v1.ISetEdgeSecurityPolicyBackendServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setEdgeSecurityPolicy( + request: protos.google.cloud.compute.v1.ISetEdgeSecurityPolicyBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetEdgeSecurityPolicyBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + setEdgeSecurityPolicy( + request: protos.google.cloud.compute.v1.ISetEdgeSecurityPolicyBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetEdgeSecurityPolicyBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + setEdgeSecurityPolicy( + request?: protos.google.cloud.compute.v1.ISetEdgeSecurityPolicyBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetEdgeSecurityPolicyBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetEdgeSecurityPolicyBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'backend_service': request.backendService ?? '', + }); + this.initialize(); + return this.innerApiCalls.setEdgeSecurityPolicy(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalSetPolicyRequest} request.globalSetPolicyRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/backend_services.set_iam_policy.js + * region_tag:compute_v1_generated_BackendServices_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyBackendServiceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyBackendServiceRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyBackendServiceRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Sets the Google Cloud Armor security policy for the specified backend service. For more information, see Google Cloud Armor Overview + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendService + * Name of the BackendService resource to which the security policy should be set. The name should conform to RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.SecurityPolicyReference} request.securityPolicyReferenceResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/backend_services.set_security_policy.js + * region_tag:compute_v1_generated_BackendServices_SetSecurityPolicy_async + */ + setSecurityPolicy( + request?: protos.google.cloud.compute.v1.ISetSecurityPolicyBackendServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setSecurityPolicy( + request: protos.google.cloud.compute.v1.ISetSecurityPolicyBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSecurityPolicyBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + setSecurityPolicy( + request: protos.google.cloud.compute.v1.ISetSecurityPolicyBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSecurityPolicyBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + setSecurityPolicy( + request?: protos.google.cloud.compute.v1.ISetSecurityPolicyBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSecurityPolicyBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSecurityPolicyBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'backend_service': request.backendService ?? '', + }); + this.initialize(); + return this.innerApiCalls.setSecurityPolicy(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified BackendService resource with the data included in the request. For more information, see Backend services overview. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendService + * Name of the BackendService resource to update. + * @param {google.cloud.compute.v1.BackendService} request.backendServiceResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/backend_services.update.js + * region_tag:compute_v1_generated_BackendServices_Update_async + */ + update( + request?: protos.google.cloud.compute.v1.IUpdateBackendServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + update( + request: protos.google.cloud.compute.v1.IUpdateBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + update( + request: protos.google.cloud.compute.v1.IUpdateBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + update( + request?: protos.google.cloud.compute.v1.IUpdateBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'backend_service': request.backendService ?? '', + }); + this.initialize(); + return this.innerApiCalls.update(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves the list of all BackendService resources, regional and global, available to the specified project. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Name of the project scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.BackendServicesScopedList | BackendServicesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/backend_services.aggregated_list.js + * region_tag:compute_v1_generated_BackendServices_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListBackendServicesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IBackendServicesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IBackendServicesScopedList]>; + } + /** + * Retrieves the list of BackendService resources available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.BackendService | BackendService}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListBackendServicesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IBackendService[], + protos.google.cloud.compute.v1.IListBackendServicesRequest|null, + protos.google.cloud.compute.v1.IBackendServiceList + ]>; + list( + request: protos.google.cloud.compute.v1.IListBackendServicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListBackendServicesRequest, + protos.google.cloud.compute.v1.IBackendServiceList|null|undefined, + protos.google.cloud.compute.v1.IBackendService>): void; + list( + request: protos.google.cloud.compute.v1.IListBackendServicesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListBackendServicesRequest, + protos.google.cloud.compute.v1.IBackendServiceList|null|undefined, + protos.google.cloud.compute.v1.IBackendService>): void; + list( + request?: protos.google.cloud.compute.v1.IListBackendServicesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListBackendServicesRequest, + protos.google.cloud.compute.v1.IBackendServiceList|null|undefined, + protos.google.cloud.compute.v1.IBackendService>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListBackendServicesRequest, + protos.google.cloud.compute.v1.IBackendServiceList|null|undefined, + protos.google.cloud.compute.v1.IBackendService>): + Promise<[ + protos.google.cloud.compute.v1.IBackendService[], + protos.google.cloud.compute.v1.IListBackendServicesRequest|null, + protos.google.cloud.compute.v1.IBackendServiceList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.BackendService | BackendService} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListBackendServicesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.BackendService | BackendService}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/backend_services.list.js + * region_tag:compute_v1_generated_BackendServices_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListBackendServicesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.backendServicesStub && !this._terminated) { + return this.backendServicesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_services_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_services_client_config.json new file mode 100644 index 00000000000..0f343108c48 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_services_client_config.json @@ -0,0 +1,82 @@ +{ + "interfaces": { + "google.cloud.compute.v1.BackendServices": { + "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": { + "AddSignedUrlKey": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteSignedUrlKey": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetHealth": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetEdgeSecurityPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetSecurityPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Update": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_services_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_services_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/backend_services_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/disk_types_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/disk_types_client.ts new file mode 100644 index 00000000000..091718c9b37 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/disk_types_client.ts @@ -0,0 +1,653 @@ +// Copyright 2023 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/disk_types_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './disk_types_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The DiskTypes API. + * @class + * @memberof v1 + */ +export class DiskTypesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + diskTypesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DiskTypesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new DiskTypesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof DiskTypesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.DiskTypes', 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.diskTypesStub) { + return this.diskTypesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.DiskTypes. + this.diskTypesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.DiskTypes') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.DiskTypes, + 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 diskTypesStubMethods = + ['aggregatedList', 'get', 'list']; + for (const methodName of diskTypesStubMethods) { + const callPromise = this.diskTypesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.diskTypesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute.readonly', + 'https://www.googleapis.com/auth/compute', + '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 -- + // ------------------- +/** + * Returns the specified disk type. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.diskType + * Name of the disk type to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.DiskType | DiskType}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/disk_types.get.js + * region_tag:compute_v1_generated_DiskTypes_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetDiskTypeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IDiskType, + protos.google.cloud.compute.v1.IGetDiskTypeRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetDiskTypeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IDiskType, + protos.google.cloud.compute.v1.IGetDiskTypeRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetDiskTypeRequest, + callback: Callback< + protos.google.cloud.compute.v1.IDiskType, + protos.google.cloud.compute.v1.IGetDiskTypeRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetDiskTypeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IDiskType, + protos.google.cloud.compute.v1.IGetDiskTypeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IDiskType, + protos.google.cloud.compute.v1.IGetDiskTypeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IDiskType, + protos.google.cloud.compute.v1.IGetDiskTypeRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'disk_type': request.diskType ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } + + +/** + * Retrieves an aggregated list of disk types. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.DiskTypesScopedList | DiskTypesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/disk_types.aggregated_list.js + * region_tag:compute_v1_generated_DiskTypes_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListDiskTypesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IDiskTypesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IDiskTypesScopedList]>; + } + /** + * Retrieves a list of disk types available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.DiskType | DiskType}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListDiskTypesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IDiskType[], + protos.google.cloud.compute.v1.IListDiskTypesRequest|null, + protos.google.cloud.compute.v1.IDiskTypeList + ]>; + list( + request: protos.google.cloud.compute.v1.IListDiskTypesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListDiskTypesRequest, + protos.google.cloud.compute.v1.IDiskTypeList|null|undefined, + protos.google.cloud.compute.v1.IDiskType>): void; + list( + request: protos.google.cloud.compute.v1.IListDiskTypesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListDiskTypesRequest, + protos.google.cloud.compute.v1.IDiskTypeList|null|undefined, + protos.google.cloud.compute.v1.IDiskType>): void; + list( + request?: protos.google.cloud.compute.v1.IListDiskTypesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListDiskTypesRequest, + protos.google.cloud.compute.v1.IDiskTypeList|null|undefined, + protos.google.cloud.compute.v1.IDiskType>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListDiskTypesRequest, + protos.google.cloud.compute.v1.IDiskTypeList|null|undefined, + protos.google.cloud.compute.v1.IDiskType>): + Promise<[ + protos.google.cloud.compute.v1.IDiskType[], + protos.google.cloud.compute.v1.IListDiskTypesRequest|null, + protos.google.cloud.compute.v1.IDiskTypeList + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.DiskType | DiskType} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListDiskTypesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.DiskType | DiskType}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/disk_types.list.js + * region_tag:compute_v1_generated_DiskTypes_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListDiskTypesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.diskTypesStub && !this._terminated) { + return this.diskTypesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/disk_types_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/disk_types_client_config.json new file mode 100644 index 00000000000..22be88a04cc --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/disk_types_client_config.json @@ -0,0 +1,38 @@ +{ + "interfaces": { + "google.cloud.compute.v1.DiskTypes": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/disk_types_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/disk_types_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/disk_types_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/disks_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/disks_client.ts new file mode 100644 index 00000000000..9601afe7c84 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/disks_client.ts @@ -0,0 +1,1635 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/disks_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './disks_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Disks API. + * @class + * @memberof v1 + */ +export class DisksClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + disksStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DisksClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new DisksClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof DisksClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.Disks', 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.disksStub) { + return this.disksStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.Disks. + this.disksStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Disks') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.Disks, + 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 disksStubMethods = + ['addResourcePolicies', 'aggregatedList', 'createSnapshot', 'delete', 'get', 'getIamPolicy', 'insert', 'list', 'removeResourcePolicies', 'resize', 'setIamPolicy', 'setLabels', 'testIamPermissions', 'update']; + for (const methodName of disksStubMethods) { + const callPromise = this.disksStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.disksStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Adds existing resource policies to a disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.disk + * The disk name for this request. + * @param {google.cloud.compute.v1.DisksAddResourcePoliciesRequest} request.disksAddResourcePoliciesRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/disks.add_resource_policies.js + * region_tag:compute_v1_generated_Disks_AddResourcePolicies_async + */ + addResourcePolicies( + request?: protos.google.cloud.compute.v1.IAddResourcePoliciesDiskRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addResourcePolicies( + request: protos.google.cloud.compute.v1.IAddResourcePoliciesDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddResourcePoliciesDiskRequest|null|undefined, + {}|null|undefined>): void; + addResourcePolicies( + request: protos.google.cloud.compute.v1.IAddResourcePoliciesDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddResourcePoliciesDiskRequest|null|undefined, + {}|null|undefined>): void; + addResourcePolicies( + request?: protos.google.cloud.compute.v1.IAddResourcePoliciesDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddResourcePoliciesDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddResourcePoliciesDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'disk': request.disk ?? '', + }); + this.initialize(); + return this.innerApiCalls.addResourcePolicies(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.disk + * Name of the persistent disk to snapshot. + * @param {boolean} request.guestFlush + * [Input Only] Whether to attempt an application consistent snapshot by informing the OS to prepare for the snapshot process. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.Snapshot} request.snapshotResource + * The body resource for this request + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/disks.create_snapshot.js + * region_tag:compute_v1_generated_Disks_CreateSnapshot_async + */ + createSnapshot( + request?: protos.google.cloud.compute.v1.ICreateSnapshotDiskRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + createSnapshot( + request: protos.google.cloud.compute.v1.ICreateSnapshotDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICreateSnapshotDiskRequest|null|undefined, + {}|null|undefined>): void; + createSnapshot( + request: protos.google.cloud.compute.v1.ICreateSnapshotDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICreateSnapshotDiskRequest|null|undefined, + {}|null|undefined>): void; + createSnapshot( + request?: protos.google.cloud.compute.v1.ICreateSnapshotDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICreateSnapshotDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICreateSnapshotDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'disk': request.disk ?? '', + }); + this.initialize(); + return this.innerApiCalls.createSnapshot(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified persistent disk. Deleting a disk removes its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.disk + * Name of the persistent disk to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/disks.delete.js + * region_tag:compute_v1_generated_Disks_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteDiskRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteDiskRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteDiskRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'disk': request.disk ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified persistent disk. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.disk + * Name of the persistent disk to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.Disk | Disk}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/disks.get.js + * region_tag:compute_v1_generated_Disks_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetDiskRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IDisk, + protos.google.cloud.compute.v1.IGetDiskRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IDisk, + protos.google.cloud.compute.v1.IGetDiskRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IDisk, + protos.google.cloud.compute.v1.IGetDiskRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IDisk, + protos.google.cloud.compute.v1.IGetDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IDisk, + protos.google.cloud.compute.v1.IGetDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IDisk, + protos.google.cloud.compute.v1.IGetDiskRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'disk': request.disk ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/disks.get_iam_policy.js + * region_tag:compute_v1_generated_Disks_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Creates a persistent disk in the specified project using the data in the request. You can create a disk from a source (sourceImage, sourceSnapshot, or sourceDisk) or create an empty 500 GB data disk by omitting all properties. You can also create a disk that is larger than the default size by specifying the sizeGb property. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.Disk} request.diskResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.sourceImage + * Source image to restore onto a disk. This field is optional. + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/disks.insert.js + * region_tag:compute_v1_generated_Disks_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertDiskRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertDiskRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertDiskRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Removes resource policies from a disk. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.disk + * The disk name for this request. + * @param {google.cloud.compute.v1.DisksRemoveResourcePoliciesRequest} request.disksRemoveResourcePoliciesRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/disks.remove_resource_policies.js + * region_tag:compute_v1_generated_Disks_RemoveResourcePolicies_async + */ + removeResourcePolicies( + request?: protos.google.cloud.compute.v1.IRemoveResourcePoliciesDiskRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + removeResourcePolicies( + request: protos.google.cloud.compute.v1.IRemoveResourcePoliciesDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveResourcePoliciesDiskRequest|null|undefined, + {}|null|undefined>): void; + removeResourcePolicies( + request: protos.google.cloud.compute.v1.IRemoveResourcePoliciesDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveResourcePoliciesDiskRequest|null|undefined, + {}|null|undefined>): void; + removeResourcePolicies( + request?: protos.google.cloud.compute.v1.IRemoveResourcePoliciesDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveResourcePoliciesDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveResourcePoliciesDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'disk': request.disk ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeResourcePolicies(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Resizes the specified persistent disk. You can only increase the size of the disk. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.disk + * The name of the persistent disk. + * @param {google.cloud.compute.v1.DisksResizeRequest} request.disksResizeRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/disks.resize.js + * region_tag:compute_v1_generated_Disks_Resize_async + */ + resize( + request?: protos.google.cloud.compute.v1.IResizeDiskRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + resize( + request: protos.google.cloud.compute.v1.IResizeDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeDiskRequest|null|undefined, + {}|null|undefined>): void; + resize( + request: protos.google.cloud.compute.v1.IResizeDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeDiskRequest|null|undefined, + {}|null|undefined>): void; + resize( + request?: protos.google.cloud.compute.v1.IResizeDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'disk': request.disk ?? '', + }); + this.initialize(); + return this.innerApiCalls.resize(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @param {google.cloud.compute.v1.ZoneSetPolicyRequest} request.zoneSetPolicyRequestResource + * The body resource for this request + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/disks.set_iam_policy.js + * region_tag:compute_v1_generated_Disks_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Sets the labels on a disk. To learn more about labels, read the Labeling Resources documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @param {google.cloud.compute.v1.ZoneSetLabelsRequest} request.zoneSetLabelsRequestResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/disks.set_labels.js + * region_tag:compute_v1_generated_Disks_SetLabels_async + */ + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsDiskRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsDiskRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsDiskRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setLabels(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/disks.test_iam_permissions.js + * region_tag:compute_v1_generated_Disks_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } +/** + * Updates the specified disk with the data included in the request. The update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: user_license. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.disk + * The disk name for this request. + * @param {google.cloud.compute.v1.Disk} request.diskResource + * The body resource for this request + * @param {string} request.paths + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.updateMask + * update_mask indicates fields to be updated as part of this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/disks.update.js + * region_tag:compute_v1_generated_Disks_Update_async + */ + update( + request?: protos.google.cloud.compute.v1.IUpdateDiskRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + update( + request: protos.google.cloud.compute.v1.IUpdateDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateDiskRequest|null|undefined, + {}|null|undefined>): void; + update( + request: protos.google.cloud.compute.v1.IUpdateDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateDiskRequest|null|undefined, + {}|null|undefined>): void; + update( + request?: protos.google.cloud.compute.v1.IUpdateDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'disk': request.disk ?? '', + }); + this.initialize(); + return this.innerApiCalls.update(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves an aggregated list of persistent disks. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.DisksScopedList | DisksScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/disks.aggregated_list.js + * region_tag:compute_v1_generated_Disks_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListDisksRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IDisksScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IDisksScopedList]>; + } + /** + * Retrieves a list of persistent disks contained within the specified zone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.Disk | Disk}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListDisksRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IDisk[], + protos.google.cloud.compute.v1.IListDisksRequest|null, + protos.google.cloud.compute.v1.IDiskList + ]>; + list( + request: protos.google.cloud.compute.v1.IListDisksRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListDisksRequest, + protos.google.cloud.compute.v1.IDiskList|null|undefined, + protos.google.cloud.compute.v1.IDisk>): void; + list( + request: protos.google.cloud.compute.v1.IListDisksRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListDisksRequest, + protos.google.cloud.compute.v1.IDiskList|null|undefined, + protos.google.cloud.compute.v1.IDisk>): void; + list( + request?: protos.google.cloud.compute.v1.IListDisksRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListDisksRequest, + protos.google.cloud.compute.v1.IDiskList|null|undefined, + protos.google.cloud.compute.v1.IDisk>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListDisksRequest, + protos.google.cloud.compute.v1.IDiskList|null|undefined, + protos.google.cloud.compute.v1.IDisk>): + Promise<[ + protos.google.cloud.compute.v1.IDisk[], + protos.google.cloud.compute.v1.IListDisksRequest|null, + protos.google.cloud.compute.v1.IDiskList + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.Disk | Disk} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListDisksRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Disk | Disk}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/disks.list.js + * region_tag:compute_v1_generated_Disks_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListDisksRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.disksStub && !this._terminated) { + return this.disksStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/disks_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/disks_client_config.json new file mode 100644 index 00000000000..a905e6e3f85 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/disks_client_config.json @@ -0,0 +1,82 @@ +{ + "interfaces": { + "google.cloud.compute.v1.Disks": { + "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": { + "AddResourcePolicies": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateSnapshot": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveResourcePolicies": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Resize": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetLabels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Update": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/disks_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/disks_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/disks_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/external_vpn_gateways_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/external_vpn_gateways_client.ts new file mode 100644 index 00000000000..9b739661edb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/external_vpn_gateways_client.ts @@ -0,0 +1,921 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/external_vpn_gateways_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './external_vpn_gateways_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The ExternalVpnGateways API. + * @class + * @memberof v1 + */ +export class ExternalVpnGatewaysClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + externalVpnGatewaysStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ExternalVpnGatewaysClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ExternalVpnGatewaysClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ExternalVpnGatewaysClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.ExternalVpnGateways', 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.externalVpnGatewaysStub) { + return this.externalVpnGatewaysStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.ExternalVpnGateways. + this.externalVpnGatewaysStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.ExternalVpnGateways') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.ExternalVpnGateways, + 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 externalVpnGatewaysStubMethods = + ['delete', 'get', 'insert', 'list', 'setLabels', 'testIamPermissions']; + for (const methodName of externalVpnGatewaysStubMethods) { + const callPromise = this.externalVpnGatewaysStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.externalVpnGatewaysStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified externalVpnGateway. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.externalVpnGateway + * Name of the externalVpnGateways to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/external_vpn_gateways.delete.js + * region_tag:compute_v1_generated_ExternalVpnGateways_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteExternalVpnGatewayRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteExternalVpnGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteExternalVpnGatewayRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteExternalVpnGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'external_vpn_gateway': request.externalVpnGateway ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified externalVpnGateway. Get a list of available externalVpnGateways by making a list() request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.externalVpnGateway + * Name of the externalVpnGateway to return. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.ExternalVpnGateway | ExternalVpnGateway}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/external_vpn_gateways.get.js + * region_tag:compute_v1_generated_ExternalVpnGateways_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetExternalVpnGatewayRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IExternalVpnGateway, + protos.google.cloud.compute.v1.IGetExternalVpnGatewayRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetExternalVpnGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IExternalVpnGateway, + protos.google.cloud.compute.v1.IGetExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetExternalVpnGatewayRequest, + callback: Callback< + protos.google.cloud.compute.v1.IExternalVpnGateway, + protos.google.cloud.compute.v1.IGetExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetExternalVpnGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IExternalVpnGateway, + protos.google.cloud.compute.v1.IGetExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IExternalVpnGateway, + protos.google.cloud.compute.v1.IGetExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IExternalVpnGateway, + protos.google.cloud.compute.v1.IGetExternalVpnGatewayRequest|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({ + 'project': request.project ?? '', + 'external_vpn_gateway': request.externalVpnGateway ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a ExternalVpnGateway in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.ExternalVpnGateway} request.externalVpnGatewayResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/external_vpn_gateways.insert.js + * region_tag:compute_v1_generated_ExternalVpnGateways_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertExternalVpnGatewayRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertExternalVpnGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertExternalVpnGatewayRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertExternalVpnGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the labels on an ExternalVpnGateway. To learn more about labels, read the Labeling Resources documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalSetLabelsRequest} request.globalSetLabelsRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/external_vpn_gateways.set_labels.js + * region_tag:compute_v1_generated_ExternalVpnGateways_SetLabels_async + */ + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsExternalVpnGatewayRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsExternalVpnGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsExternalVpnGatewayRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsExternalVpnGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setLabels(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/external_vpn_gateways.test_iam_permissions.js + * region_tag:compute_v1_generated_ExternalVpnGateways_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsExternalVpnGatewayRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsExternalVpnGatewayRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsExternalVpnGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsExternalVpnGatewayRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsExternalVpnGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsExternalVpnGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsExternalVpnGatewayRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + /** + * Retrieves the list of ExternalVpnGateway available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.ExternalVpnGateway | ExternalVpnGateway}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListExternalVpnGatewaysRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IExternalVpnGateway[], + protos.google.cloud.compute.v1.IListExternalVpnGatewaysRequest|null, + protos.google.cloud.compute.v1.IExternalVpnGatewayList + ]>; + list( + request: protos.google.cloud.compute.v1.IListExternalVpnGatewaysRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListExternalVpnGatewaysRequest, + protos.google.cloud.compute.v1.IExternalVpnGatewayList|null|undefined, + protos.google.cloud.compute.v1.IExternalVpnGateway>): void; + list( + request: protos.google.cloud.compute.v1.IListExternalVpnGatewaysRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListExternalVpnGatewaysRequest, + protos.google.cloud.compute.v1.IExternalVpnGatewayList|null|undefined, + protos.google.cloud.compute.v1.IExternalVpnGateway>): void; + list( + request?: protos.google.cloud.compute.v1.IListExternalVpnGatewaysRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListExternalVpnGatewaysRequest, + protos.google.cloud.compute.v1.IExternalVpnGatewayList|null|undefined, + protos.google.cloud.compute.v1.IExternalVpnGateway>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListExternalVpnGatewaysRequest, + protos.google.cloud.compute.v1.IExternalVpnGatewayList|null|undefined, + protos.google.cloud.compute.v1.IExternalVpnGateway>): + Promise<[ + protos.google.cloud.compute.v1.IExternalVpnGateway[], + protos.google.cloud.compute.v1.IListExternalVpnGatewaysRequest|null, + protos.google.cloud.compute.v1.IExternalVpnGatewayList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.ExternalVpnGateway | ExternalVpnGateway} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListExternalVpnGatewaysRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.ExternalVpnGateway | ExternalVpnGateway}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/external_vpn_gateways.list.js + * region_tag:compute_v1_generated_ExternalVpnGateways_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListExternalVpnGatewaysRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.externalVpnGatewaysStub && !this._terminated) { + return this.externalVpnGatewaysStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/external_vpn_gateways_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/external_vpn_gateways_client_config.json new file mode 100644 index 00000000000..db73f24bf59 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/external_vpn_gateways_client_config.json @@ -0,0 +1,50 @@ +{ + "interfaces": { + "google.cloud.compute.v1.ExternalVpnGateways": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetLabels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/external_vpn_gateways_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/external_vpn_gateways_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/external_vpn_gateways_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/firewall_policies_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/firewall_policies_client.ts new file mode 100644 index 00000000000..d1c915f7837 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/firewall_policies_client.ts @@ -0,0 +1,1862 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/firewall_policies_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './firewall_policies_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The FirewallPolicies API. + * @class + * @memberof v1 + */ +export class FirewallPoliciesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + firewallPoliciesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of FirewallPoliciesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new FirewallPoliciesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof FirewallPoliciesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.FirewallPolicies', 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.firewallPoliciesStub) { + return this.firewallPoliciesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.FirewallPolicies. + this.firewallPoliciesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.FirewallPolicies') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.FirewallPolicies, + 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 firewallPoliciesStubMethods = + ['addAssociation', 'addRule', 'cloneRules', 'delete', 'get', 'getAssociation', 'getIamPolicy', 'getRule', 'insert', 'list', 'listAssociations', 'move', 'patch', 'patchRule', 'removeAssociation', 'removeRule', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of firewallPoliciesStubMethods) { + const callPromise = this.firewallPoliciesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.firewallPoliciesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Inserts an association for the specified firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {google.cloud.compute.v1.FirewallPolicyAssociation} request.firewallPolicyAssociationResource + * The body resource for this request + * @param {boolean} request.replaceExistingAssociation + * Indicates whether or not to replace it if an association of the attachment already exists. This is false by default, in which case an error will be returned if an association already exists. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/firewall_policies.add_association.js + * region_tag:compute_v1_generated_FirewallPolicies_AddAssociation_async + */ + addAssociation( + request?: protos.google.cloud.compute.v1.IAddAssociationFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addAssociation( + request: protos.google.cloud.compute.v1.IAddAssociationFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddAssociationFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + addAssociation( + request: protos.google.cloud.compute.v1.IAddAssociationFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddAssociationFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + addAssociation( + request?: protos.google.cloud.compute.v1.IAddAssociationFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddAssociationFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddAssociationFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.addAssociation(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Inserts a rule into a firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {google.cloud.compute.v1.FirewallPolicyRule} request.firewallPolicyRuleResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/firewall_policies.add_rule.js + * region_tag:compute_v1_generated_FirewallPolicies_AddRule_async + */ + addRule( + request?: protos.google.cloud.compute.v1.IAddRuleFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addRule( + request: protos.google.cloud.compute.v1.IAddRuleFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddRuleFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + addRule( + request: protos.google.cloud.compute.v1.IAddRuleFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddRuleFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + addRule( + request?: protos.google.cloud.compute.v1.IAddRuleFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddRuleFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddRuleFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.addRule(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Copies rules to the specified firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.sourceFirewallPolicy + * The firewall policy from which to copy rules. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/firewall_policies.clone_rules.js + * region_tag:compute_v1_generated_FirewallPolicies_CloneRules_async + */ + cloneRules( + request?: protos.google.cloud.compute.v1.ICloneRulesFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + cloneRules( + request: protos.google.cloud.compute.v1.ICloneRulesFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICloneRulesFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + cloneRules( + request: protos.google.cloud.compute.v1.ICloneRulesFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICloneRulesFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + cloneRules( + request?: protos.google.cloud.compute.v1.ICloneRulesFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICloneRulesFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICloneRulesFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.cloneRules(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to delete. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/firewall_policies.delete.js + * region_tag:compute_v1_generated_FirewallPolicies_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to get. + * @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.compute.v1.FirewallPolicy | FirewallPolicy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firewall_policies.get.js + * region_tag:compute_v1_generated_FirewallPolicies_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetFirewallPolicyRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetFirewallPolicyRequest|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({ + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets an association with the specified name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to which the queried rule belongs. + * @param {string} request.name + * The name of the association to get from the firewall policy. + * @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.compute.v1.FirewallPolicyAssociation | FirewallPolicyAssociation}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firewall_policies.get_association.js + * region_tag:compute_v1_generated_FirewallPolicies_GetAssociation_async + */ + getAssociation( + request?: protos.google.cloud.compute.v1.IGetAssociationFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationFirewallPolicyRequest|undefined, {}|undefined + ]>; + getAssociation( + request: protos.google.cloud.compute.v1.IGetAssociationFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getAssociation( + request: protos.google.cloud.compute.v1.IGetAssociationFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getAssociation( + request?: protos.google.cloud.compute.v1.IGetAssociationFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationFirewallPolicyRequest|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({ + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.getAssociation(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firewall_policies.get_iam_policy.js + * region_tag:compute_v1_generated_FirewallPolicies_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyFirewallPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyFirewallPolicyRequest|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({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Gets a rule of the specified priority. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to which the queried rule belongs. + * @param {number} request.priority + * The priority of the rule to get from the firewall policy. + * @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.compute.v1.FirewallPolicyRule | FirewallPolicyRule}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firewall_policies.get_rule.js + * region_tag:compute_v1_generated_FirewallPolicies_GetRule_async + */ + getRule( + request?: protos.google.cloud.compute.v1.IGetRuleFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleFirewallPolicyRequest|undefined, {}|undefined + ]>; + getRule( + request: protos.google.cloud.compute.v1.IGetRuleFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getRule( + request: protos.google.cloud.compute.v1.IGetRuleFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getRule( + request?: protos.google.cloud.compute.v1.IGetRuleFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleFirewallPolicyRequest|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({ + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.getRule(request, options, callback); + } +/** + * Creates a new policy in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.FirewallPolicy} request.firewallPolicyResource + * The body resource for this request + * @param {string} request.parentId + * Parent ID for this request. The ID can be either be "folders/[FOLDER_ID]" if the parent is a folder or "organizations/[ORGANIZATION_ID]" if the parent is an organization. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/firewall_policies.insert.js + * region_tag:compute_v1_generated_FirewallPolicies_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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 || {}; + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Lists associations of a specified target, i.e., organization or folder. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.targetResource + * The target resource to list associations. It is an organization, or a folder. + * @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.compute.v1.FirewallPoliciesListAssociationsResponse | FirewallPoliciesListAssociationsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firewall_policies.list_associations.js + * region_tag:compute_v1_generated_FirewallPolicies_ListAssociations_async + */ + listAssociations( + request?: protos.google.cloud.compute.v1.IListAssociationsFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPoliciesListAssociationsResponse, + protos.google.cloud.compute.v1.IListAssociationsFirewallPolicyRequest|undefined, {}|undefined + ]>; + listAssociations( + request: protos.google.cloud.compute.v1.IListAssociationsFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPoliciesListAssociationsResponse, + protos.google.cloud.compute.v1.IListAssociationsFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + listAssociations( + request: protos.google.cloud.compute.v1.IListAssociationsFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPoliciesListAssociationsResponse, + protos.google.cloud.compute.v1.IListAssociationsFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + listAssociations( + request?: protos.google.cloud.compute.v1.IListAssociationsFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IFirewallPoliciesListAssociationsResponse, + protos.google.cloud.compute.v1.IListAssociationsFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IFirewallPoliciesListAssociationsResponse, + protos.google.cloud.compute.v1.IListAssociationsFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPoliciesListAssociationsResponse, + protos.google.cloud.compute.v1.IListAssociationsFirewallPolicyRequest|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 || {}; + this.initialize(); + return this.innerApiCalls.listAssociations(request, options, callback); + } +/** + * Moves the specified firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {string} request.parentId + * The new parent of the firewall policy. The ID can be either be "folders/[FOLDER_ID]" if the parent is a folder or "organizations/[ORGANIZATION_ID]" if the parent is an organization. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/firewall_policies.move.js + * region_tag:compute_v1_generated_FirewallPolicies_Move_async + */ + move( + request?: protos.google.cloud.compute.v1.IMoveFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + move( + request: protos.google.cloud.compute.v1.IMoveFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IMoveFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + move( + request: protos.google.cloud.compute.v1.IMoveFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IMoveFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + move( + request?: protos.google.cloud.compute.v1.IMoveFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IMoveFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IMoveFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.move(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified policy with the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {google.cloud.compute.v1.FirewallPolicy} request.firewallPolicyResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/firewall_policies.patch.js + * region_tag:compute_v1_generated_FirewallPolicies_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches a rule of the specified priority. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {google.cloud.compute.v1.FirewallPolicyRule} request.firewallPolicyRuleResource + * The body resource for this request + * @param {number} request.priority + * The priority of the rule to patch. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/firewall_policies.patch_rule.js + * region_tag:compute_v1_generated_FirewallPolicies_PatchRule_async + */ + patchRule( + request?: protos.google.cloud.compute.v1.IPatchRuleFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patchRule( + request: protos.google.cloud.compute.v1.IPatchRuleFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRuleFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + patchRule( + request: protos.google.cloud.compute.v1.IPatchRuleFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRuleFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + patchRule( + request?: protos.google.cloud.compute.v1.IPatchRuleFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRuleFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRuleFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.patchRule(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Removes an association for the specified firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {string} request.name + * Name for the attachment that will be removed. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/firewall_policies.remove_association.js + * region_tag:compute_v1_generated_FirewallPolicies_RemoveAssociation_async + */ + removeAssociation( + request?: protos.google.cloud.compute.v1.IRemoveAssociationFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + removeAssociation( + request: protos.google.cloud.compute.v1.IRemoveAssociationFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveAssociationFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + removeAssociation( + request: protos.google.cloud.compute.v1.IRemoveAssociationFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveAssociationFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + removeAssociation( + request?: protos.google.cloud.compute.v1.IRemoveAssociationFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveAssociationFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveAssociationFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeAssociation(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes a rule of the specified priority. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {number} request.priority + * The priority of the rule to remove from the firewall policy. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/firewall_policies.remove_rule.js + * region_tag:compute_v1_generated_FirewallPolicies_RemoveRule_async + */ + removeRule( + request?: protos.google.cloud.compute.v1.IRemoveRuleFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + removeRule( + request: protos.google.cloud.compute.v1.IRemoveRuleFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveRuleFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + removeRule( + request: protos.google.cloud.compute.v1.IRemoveRuleFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveRuleFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + removeRule( + request?: protos.google.cloud.compute.v1.IRemoveRuleFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveRuleFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveRuleFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeRule(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalOrganizationSetPolicyRequest} request.globalOrganizationSetPolicyRequestResource + * The body resource for this request + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firewall_policies.set_iam_policy.js + * region_tag:compute_v1_generated_FirewallPolicies_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyFirewallPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyFirewallPolicyRequest|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({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firewall_policies.test_iam_permissions.js + * region_tag:compute_v1_generated_FirewallPolicies_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsFirewallPolicyRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsFirewallPolicyRequest|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({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + /** + * Lists all the policies that have been configured for the specified folder or organization. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.parentId + * Parent ID for this request. The ID can be either be "folders/[FOLDER_ID]" if the parent is a folder or "organizations/[ORGANIZATION_ID]" if the parent is an organization. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.FirewallPolicy | FirewallPolicy}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListFirewallPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicy[], + protos.google.cloud.compute.v1.IListFirewallPoliciesRequest|null, + protos.google.cloud.compute.v1.IFirewallPolicyList + ]>; + list( + request: protos.google.cloud.compute.v1.IListFirewallPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListFirewallPoliciesRequest, + protos.google.cloud.compute.v1.IFirewallPolicyList|null|undefined, + protos.google.cloud.compute.v1.IFirewallPolicy>): void; + list( + request: protos.google.cloud.compute.v1.IListFirewallPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListFirewallPoliciesRequest, + protos.google.cloud.compute.v1.IFirewallPolicyList|null|undefined, + protos.google.cloud.compute.v1.IFirewallPolicy>): void; + list( + request?: protos.google.cloud.compute.v1.IListFirewallPoliciesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListFirewallPoliciesRequest, + protos.google.cloud.compute.v1.IFirewallPolicyList|null|undefined, + protos.google.cloud.compute.v1.IFirewallPolicy>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListFirewallPoliciesRequest, + protos.google.cloud.compute.v1.IFirewallPolicyList|null|undefined, + protos.google.cloud.compute.v1.IFirewallPolicy>): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicy[], + protos.google.cloud.compute.v1.IListFirewallPoliciesRequest|null, + protos.google.cloud.compute.v1.IFirewallPolicyList + ]>|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 || {}; + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.parentId + * Parent ID for this request. The ID can be either be "folders/[FOLDER_ID]" if the parent is a folder or "organizations/[ORGANIZATION_ID]" if the parent is an organization. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.FirewallPolicy | FirewallPolicy} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListFirewallPoliciesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.parentId + * Parent ID for this request. The ID can be either be "folders/[FOLDER_ID]" if the parent is a folder or "organizations/[ORGANIZATION_ID]" if the parent is an organization. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.FirewallPolicy | FirewallPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/firewall_policies.list.js + * region_tag:compute_v1_generated_FirewallPolicies_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListFirewallPoliciesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.firewallPoliciesStub && !this._terminated) { + return this.firewallPoliciesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/firewall_policies_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/firewall_policies_client_config.json new file mode 100644 index 00000000000..1888d5e85f9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/firewall_policies_client_config.json @@ -0,0 +1,98 @@ +{ + "interfaces": { + "google.cloud.compute.v1.FirewallPolicies": { + "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": { + "AddAssociation": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AddRule": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CloneRules": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetAssociation": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetRule": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListAssociations": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Move": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PatchRule": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveAssociation": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveRule": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/firewall_policies_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/firewall_policies_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/firewall_policies_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/firewalls_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/firewalls_client.ts new file mode 100644 index 00000000000..f9fb0aa203e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/firewalls_client.ts @@ -0,0 +1,937 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/firewalls_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './firewalls_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Firewalls API. + * @class + * @memberof v1 + */ +export class FirewallsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + firewallsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of FirewallsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new FirewallsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof FirewallsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.Firewalls', 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.firewallsStub) { + return this.firewallsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.Firewalls. + this.firewallsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Firewalls') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.Firewalls, + 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 firewallsStubMethods = + ['delete', 'get', 'insert', 'list', 'patch', 'update']; + for (const methodName of firewallsStubMethods) { + const callPromise = this.firewallsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.firewallsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified firewall. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewall + * Name of the firewall rule to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/firewalls.delete.js + * region_tag:compute_v1_generated_Firewalls_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteFirewallRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteFirewallRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteFirewallRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteFirewallRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteFirewallRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteFirewallRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteFirewallRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteFirewallRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'firewall': request.firewall ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified firewall. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewall + * Name of the firewall rule to return. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.Firewall | Firewall}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firewalls.get.js + * region_tag:compute_v1_generated_Firewalls_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetFirewallRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IFirewall, + protos.google.cloud.compute.v1.IGetFirewallRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetFirewallRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IFirewall, + protos.google.cloud.compute.v1.IGetFirewallRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetFirewallRequest, + callback: Callback< + protos.google.cloud.compute.v1.IFirewall, + protos.google.cloud.compute.v1.IGetFirewallRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetFirewallRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IFirewall, + protos.google.cloud.compute.v1.IGetFirewallRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IFirewall, + protos.google.cloud.compute.v1.IGetFirewallRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IFirewall, + protos.google.cloud.compute.v1.IGetFirewallRequest|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({ + 'project': request.project ?? '', + 'firewall': request.firewall ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a firewall rule in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.Firewall} request.firewallResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/firewalls.insert.js + * region_tag:compute_v1_generated_Firewalls_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertFirewallRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertFirewallRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertFirewallRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertFirewallRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertFirewallRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertFirewallRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertFirewallRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertFirewallRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified firewall rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewall + * Name of the firewall rule to patch. + * @param {google.cloud.compute.v1.Firewall} request.firewallResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/firewalls.patch.js + * region_tag:compute_v1_generated_Firewalls_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchFirewallRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchFirewallRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchFirewallRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchFirewallRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchFirewallRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchFirewallRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchFirewallRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchFirewallRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'firewall': request.firewall ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified firewall rule with the data included in the request. Note that all fields will be updated if using PUT, even fields that are not specified. To update individual fields, please use PATCH instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewall + * Name of the firewall rule to update. + * @param {google.cloud.compute.v1.Firewall} request.firewallResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/firewalls.update.js + * region_tag:compute_v1_generated_Firewalls_Update_async + */ + update( + request?: protos.google.cloud.compute.v1.IUpdateFirewallRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + update( + request: protos.google.cloud.compute.v1.IUpdateFirewallRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateFirewallRequest|null|undefined, + {}|null|undefined>): void; + update( + request: protos.google.cloud.compute.v1.IUpdateFirewallRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateFirewallRequest|null|undefined, + {}|null|undefined>): void; + update( + request?: protos.google.cloud.compute.v1.IUpdateFirewallRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateFirewallRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateFirewallRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'firewall': request.firewall ?? '', + }); + this.initialize(); + return this.innerApiCalls.update(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves the list of firewall rules available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Firewall | Firewall}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListFirewallsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IFirewall[], + protos.google.cloud.compute.v1.IListFirewallsRequest|null, + protos.google.cloud.compute.v1.IFirewallList + ]>; + list( + request: protos.google.cloud.compute.v1.IListFirewallsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListFirewallsRequest, + protos.google.cloud.compute.v1.IFirewallList|null|undefined, + protos.google.cloud.compute.v1.IFirewall>): void; + list( + request: protos.google.cloud.compute.v1.IListFirewallsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListFirewallsRequest, + protos.google.cloud.compute.v1.IFirewallList|null|undefined, + protos.google.cloud.compute.v1.IFirewall>): void; + list( + request?: protos.google.cloud.compute.v1.IListFirewallsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListFirewallsRequest, + protos.google.cloud.compute.v1.IFirewallList|null|undefined, + protos.google.cloud.compute.v1.IFirewall>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListFirewallsRequest, + protos.google.cloud.compute.v1.IFirewallList|null|undefined, + protos.google.cloud.compute.v1.IFirewall>): + Promise<[ + protos.google.cloud.compute.v1.IFirewall[], + protos.google.cloud.compute.v1.IListFirewallsRequest|null, + protos.google.cloud.compute.v1.IFirewallList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Firewall | Firewall} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListFirewallsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Firewall | Firewall}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/firewalls.list.js + * region_tag:compute_v1_generated_Firewalls_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListFirewallsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.firewallsStub && !this._terminated) { + return this.firewallsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/firewalls_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/firewalls_client_config.json new file mode 100644 index 00000000000..9086e9d520d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/firewalls_client_config.json @@ -0,0 +1,50 @@ +{ + "interfaces": { + "google.cloud.compute.v1.Firewalls": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Update": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/firewalls_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/firewalls_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/firewalls_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/forwarding_rules_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/forwarding_rules_client.ts new file mode 100644 index 00000000000..5f97c5d0117 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/forwarding_rules_client.ts @@ -0,0 +1,1112 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/forwarding_rules_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './forwarding_rules_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The ForwardingRules API. + * @class + * @memberof v1 + */ +export class ForwardingRulesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + forwardingRulesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ForwardingRulesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ForwardingRulesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ForwardingRulesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.ForwardingRules', 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.forwardingRulesStub) { + return this.forwardingRulesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.ForwardingRules. + this.forwardingRulesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.ForwardingRules') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.ForwardingRules, + 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 forwardingRulesStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'list', 'patch', 'setLabels', 'setTarget']; + for (const methodName of forwardingRulesStubMethods) { + const callPromise = this.forwardingRulesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.forwardingRulesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified ForwardingRule resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.forwardingRule + * Name of the ForwardingRule resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/forwarding_rules.delete.js + * region_tag:compute_v1_generated_ForwardingRules_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteForwardingRuleRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteForwardingRuleRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteForwardingRuleRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteForwardingRuleRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteForwardingRuleRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteForwardingRuleRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'forwarding_rule': request.forwardingRule ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified ForwardingRule resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.forwardingRule + * Name of the ForwardingRule resource to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @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.compute.v1.ForwardingRule | ForwardingRule}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/forwarding_rules.get.js + * region_tag:compute_v1_generated_ForwardingRules_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetForwardingRuleRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IForwardingRule, + protos.google.cloud.compute.v1.IGetForwardingRuleRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetForwardingRuleRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IForwardingRule, + protos.google.cloud.compute.v1.IGetForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetForwardingRuleRequest, + callback: Callback< + protos.google.cloud.compute.v1.IForwardingRule, + protos.google.cloud.compute.v1.IGetForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetForwardingRuleRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IForwardingRule, + protos.google.cloud.compute.v1.IGetForwardingRuleRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IForwardingRule, + protos.google.cloud.compute.v1.IGetForwardingRuleRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IForwardingRule, + protos.google.cloud.compute.v1.IGetForwardingRuleRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'forwarding_rule': request.forwardingRule ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a ForwardingRule resource in the specified project and region using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.ForwardingRule} request.forwardingRuleResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/forwarding_rules.insert.js + * region_tag:compute_v1_generated_ForwardingRules_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertForwardingRuleRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertForwardingRuleRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertForwardingRuleRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertForwardingRuleRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertForwardingRuleRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertForwardingRuleRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. Currently, you can only patch the network_tier field. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.forwardingRule + * Name of the ForwardingRule resource to patch. + * @param {google.cloud.compute.v1.ForwardingRule} request.forwardingRuleResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/forwarding_rules.patch.js + * region_tag:compute_v1_generated_ForwardingRules_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchForwardingRuleRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchForwardingRuleRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchForwardingRuleRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchForwardingRuleRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchForwardingRuleRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchForwardingRuleRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'forwarding_rule': request.forwardingRule ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the labels on the specified resource. To learn more about labels, read the Labeling Resources documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The region for this request. + * @param {google.cloud.compute.v1.RegionSetLabelsRequest} request.regionSetLabelsRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.resource + * Name or id of the resource for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/forwarding_rules.set_labels.js + * region_tag:compute_v1_generated_ForwardingRules_SetLabels_async + */ + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsForwardingRuleRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsForwardingRuleRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsForwardingRuleRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsForwardingRuleRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsForwardingRuleRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsForwardingRuleRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setLabels(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes target URL for forwarding rule. The new target should be of the same type as the old target. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.forwardingRule + * Name of the ForwardingRule resource in which target is to be set. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetReference} request.targetReferenceResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/forwarding_rules.set_target.js + * region_tag:compute_v1_generated_ForwardingRules_SetTarget_async + */ + setTarget( + request?: protos.google.cloud.compute.v1.ISetTargetForwardingRuleRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setTarget( + request: protos.google.cloud.compute.v1.ISetTargetForwardingRuleRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTargetForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + setTarget( + request: protos.google.cloud.compute.v1.ISetTargetForwardingRuleRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTargetForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + setTarget( + request?: protos.google.cloud.compute.v1.ISetTargetForwardingRuleRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTargetForwardingRuleRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTargetForwardingRuleRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'forwarding_rule': request.forwardingRule ?? '', + }); + this.initialize(); + return this.innerApiCalls.setTarget(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves an aggregated list of forwarding rules. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.ForwardingRulesScopedList | ForwardingRulesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/forwarding_rules.aggregated_list.js + * region_tag:compute_v1_generated_ForwardingRules_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListForwardingRulesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IForwardingRulesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IForwardingRulesScopedList]>; + } + /** + * Retrieves a list of ForwardingRule resources available to the specified project and region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.ForwardingRule | ForwardingRule}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListForwardingRulesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IForwardingRule[], + protos.google.cloud.compute.v1.IListForwardingRulesRequest|null, + protos.google.cloud.compute.v1.IForwardingRuleList + ]>; + list( + request: protos.google.cloud.compute.v1.IListForwardingRulesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListForwardingRulesRequest, + protos.google.cloud.compute.v1.IForwardingRuleList|null|undefined, + protos.google.cloud.compute.v1.IForwardingRule>): void; + list( + request: protos.google.cloud.compute.v1.IListForwardingRulesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListForwardingRulesRequest, + protos.google.cloud.compute.v1.IForwardingRuleList|null|undefined, + protos.google.cloud.compute.v1.IForwardingRule>): void; + list( + request?: protos.google.cloud.compute.v1.IListForwardingRulesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListForwardingRulesRequest, + protos.google.cloud.compute.v1.IForwardingRuleList|null|undefined, + protos.google.cloud.compute.v1.IForwardingRule>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListForwardingRulesRequest, + protos.google.cloud.compute.v1.IForwardingRuleList|null|undefined, + protos.google.cloud.compute.v1.IForwardingRule>): + Promise<[ + protos.google.cloud.compute.v1.IForwardingRule[], + protos.google.cloud.compute.v1.IListForwardingRulesRequest|null, + protos.google.cloud.compute.v1.IForwardingRuleList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.ForwardingRule | ForwardingRule} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListForwardingRulesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.ForwardingRule | ForwardingRule}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/forwarding_rules.list.js + * region_tag:compute_v1_generated_ForwardingRules_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListForwardingRulesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.forwardingRulesStub && !this._terminated) { + return this.forwardingRulesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/forwarding_rules_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/forwarding_rules_client_config.json new file mode 100644 index 00000000000..f954dc6c474 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/forwarding_rules_client_config.json @@ -0,0 +1,58 @@ +{ + "interfaces": { + "google.cloud.compute.v1.ForwardingRules": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetLabels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetTarget": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/forwarding_rules_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/forwarding_rules_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/forwarding_rules_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..4f664cb9cc6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/gapic_metadata.json @@ -0,0 +1,8683 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.compute.v1", + "libraryPackage": "@google-cloud/compute", + "services": { + "AcceleratorTypes": { + "clients": { + "grpc": { + "libraryClient": "AcceleratorTypesClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "AcceleratorTypesClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "Addresses": { + "clients": { + "grpc": { + "libraryClient": "AddressesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "AddressesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "Autoscalers": { + "clients": { + "grpc": { + "libraryClient": "AutoscalersClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "AutoscalersClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "BackendBuckets": { + "clients": { + "grpc": { + "libraryClient": "BackendBucketsClient", + "rpcs": { + "AddSignedUrlKey": { + "methods": [ + "addSignedUrlKey" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "DeleteSignedUrlKey": { + "methods": [ + "deleteSignedUrlKey" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetEdgeSecurityPolicy": { + "methods": [ + "setEdgeSecurityPolicy" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "BackendBucketsClient", + "rpcs": { + "AddSignedUrlKey": { + "methods": [ + "addSignedUrlKey" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "DeleteSignedUrlKey": { + "methods": [ + "deleteSignedUrlKey" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetEdgeSecurityPolicy": { + "methods": [ + "setEdgeSecurityPolicy" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "BackendServices": { + "clients": { + "grpc": { + "libraryClient": "BackendServicesClient", + "rpcs": { + "AddSignedUrlKey": { + "methods": [ + "addSignedUrlKey" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "DeleteSignedUrlKey": { + "methods": [ + "deleteSignedUrlKey" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetHealth": { + "methods": [ + "getHealth" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetEdgeSecurityPolicy": { + "methods": [ + "setEdgeSecurityPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SetSecurityPolicy": { + "methods": [ + "setSecurityPolicy" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "BackendServicesClient", + "rpcs": { + "AddSignedUrlKey": { + "methods": [ + "addSignedUrlKey" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "DeleteSignedUrlKey": { + "methods": [ + "deleteSignedUrlKey" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetHealth": { + "methods": [ + "getHealth" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetEdgeSecurityPolicy": { + "methods": [ + "setEdgeSecurityPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SetSecurityPolicy": { + "methods": [ + "setSecurityPolicy" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "Disks": { + "clients": { + "grpc": { + "libraryClient": "DisksClient", + "rpcs": { + "AddResourcePolicies": { + "methods": [ + "addResourcePolicies" + ] + }, + "CreateSnapshot": { + "methods": [ + "createSnapshot" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "RemoveResourcePolicies": { + "methods": [ + "removeResourcePolicies" + ] + }, + "Resize": { + "methods": [ + "resize" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DisksClient", + "rpcs": { + "AddResourcePolicies": { + "methods": [ + "addResourcePolicies" + ] + }, + "CreateSnapshot": { + "methods": [ + "createSnapshot" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "RemoveResourcePolicies": { + "methods": [ + "removeResourcePolicies" + ] + }, + "Resize": { + "methods": [ + "resize" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "DiskTypes": { + "clients": { + "grpc": { + "libraryClient": "DiskTypesClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DiskTypesClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "ExternalVpnGateways": { + "clients": { + "grpc": { + "libraryClient": "ExternalVpnGatewaysClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ExternalVpnGatewaysClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "FirewallPolicies": { + "clients": { + "grpc": { + "libraryClient": "FirewallPoliciesClient", + "rpcs": { + "AddAssociation": { + "methods": [ + "addAssociation" + ] + }, + "AddRule": { + "methods": [ + "addRule" + ] + }, + "CloneRules": { + "methods": [ + "cloneRules" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetAssociation": { + "methods": [ + "getAssociation" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "GetRule": { + "methods": [ + "getRule" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "ListAssociations": { + "methods": [ + "listAssociations" + ] + }, + "Move": { + "methods": [ + "move" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "PatchRule": { + "methods": [ + "patchRule" + ] + }, + "RemoveAssociation": { + "methods": [ + "removeAssociation" + ] + }, + "RemoveRule": { + "methods": [ + "removeRule" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "FirewallPoliciesClient", + "rpcs": { + "AddAssociation": { + "methods": [ + "addAssociation" + ] + }, + "AddRule": { + "methods": [ + "addRule" + ] + }, + "CloneRules": { + "methods": [ + "cloneRules" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetAssociation": { + "methods": [ + "getAssociation" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "GetRule": { + "methods": [ + "getRule" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "ListAssociations": { + "methods": [ + "listAssociations" + ] + }, + "Move": { + "methods": [ + "move" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "PatchRule": { + "methods": [ + "patchRule" + ] + }, + "RemoveAssociation": { + "methods": [ + "removeAssociation" + ] + }, + "RemoveRule": { + "methods": [ + "removeRule" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "Firewalls": { + "clients": { + "grpc": { + "libraryClient": "FirewallsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "FirewallsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "ForwardingRules": { + "clients": { + "grpc": { + "libraryClient": "ForwardingRulesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "SetTarget": { + "methods": [ + "setTarget" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ForwardingRulesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "SetTarget": { + "methods": [ + "setTarget" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "GlobalAddresses": { + "clients": { + "grpc": { + "libraryClient": "GlobalAddressesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "GlobalAddressesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "GlobalForwardingRules": { + "clients": { + "grpc": { + "libraryClient": "GlobalForwardingRulesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "SetTarget": { + "methods": [ + "setTarget" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "GlobalForwardingRulesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "SetTarget": { + "methods": [ + "setTarget" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "GlobalNetworkEndpointGroups": { + "clients": { + "grpc": { + "libraryClient": "GlobalNetworkEndpointGroupsClient", + "rpcs": { + "AttachNetworkEndpoints": { + "methods": [ + "attachNetworkEndpoints" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "DetachNetworkEndpoints": { + "methods": [ + "detachNetworkEndpoints" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListNetworkEndpoints": { + "methods": [ + "listNetworkEndpoints", + "listNetworkEndpointsStream", + "listNetworkEndpointsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "GlobalNetworkEndpointGroupsClient", + "rpcs": { + "AttachNetworkEndpoints": { + "methods": [ + "attachNetworkEndpoints" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "DetachNetworkEndpoints": { + "methods": [ + "detachNetworkEndpoints" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListNetworkEndpoints": { + "methods": [ + "listNetworkEndpoints", + "listNetworkEndpointsStream", + "listNetworkEndpointsAsync" + ] + } + } + } + } + }, + "GlobalOperations": { + "clients": { + "grpc": { + "libraryClient": "GlobalOperationsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Wait": { + "methods": [ + "wait" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "GlobalOperationsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Wait": { + "methods": [ + "wait" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "GlobalOrganizationOperations": { + "clients": { + "grpc": { + "libraryClient": "GlobalOrganizationOperationsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "GlobalOrganizationOperationsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "GlobalPublicDelegatedPrefixes": { + "clients": { + "grpc": { + "libraryClient": "GlobalPublicDelegatedPrefixesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "GlobalPublicDelegatedPrefixesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "HealthChecks": { + "clients": { + "grpc": { + "libraryClient": "HealthChecksClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "HealthChecksClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "ImageFamilyViews": { + "clients": { + "grpc": { + "libraryClient": "ImageFamilyViewsClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageFamilyViewsClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + } + } + } + } + }, + "Images": { + "clients": { + "grpc": { + "libraryClient": "ImagesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Deprecate": { + "methods": [ + "deprecate" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetFromFamily": { + "methods": [ + "getFromFamily" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImagesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Deprecate": { + "methods": [ + "deprecate" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetFromFamily": { + "methods": [ + "getFromFamily" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "InstanceGroupManagers": { + "clients": { + "grpc": { + "libraryClient": "InstanceGroupManagersClient", + "rpcs": { + "AbandonInstances": { + "methods": [ + "abandonInstances" + ] + }, + "ApplyUpdatesToInstances": { + "methods": [ + "applyUpdatesToInstances" + ] + }, + "CreateInstances": { + "methods": [ + "createInstances" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "DeleteInstances": { + "methods": [ + "deleteInstances" + ] + }, + "DeletePerInstanceConfigs": { + "methods": [ + "deletePerInstanceConfigs" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "PatchPerInstanceConfigs": { + "methods": [ + "patchPerInstanceConfigs" + ] + }, + "RecreateInstances": { + "methods": [ + "recreateInstances" + ] + }, + "Resize": { + "methods": [ + "resize" + ] + }, + "SetInstanceTemplate": { + "methods": [ + "setInstanceTemplate" + ] + }, + "SetTargetPools": { + "methods": [ + "setTargetPools" + ] + }, + "UpdatePerInstanceConfigs": { + "methods": [ + "updatePerInstanceConfigs" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListErrors": { + "methods": [ + "listErrors", + "listErrorsStream", + "listErrorsAsync" + ] + }, + "ListManagedInstances": { + "methods": [ + "listManagedInstances", + "listManagedInstancesStream", + "listManagedInstancesAsync" + ] + }, + "ListPerInstanceConfigs": { + "methods": [ + "listPerInstanceConfigs", + "listPerInstanceConfigsStream", + "listPerInstanceConfigsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "InstanceGroupManagersClient", + "rpcs": { + "AbandonInstances": { + "methods": [ + "abandonInstances" + ] + }, + "ApplyUpdatesToInstances": { + "methods": [ + "applyUpdatesToInstances" + ] + }, + "CreateInstances": { + "methods": [ + "createInstances" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "DeleteInstances": { + "methods": [ + "deleteInstances" + ] + }, + "DeletePerInstanceConfigs": { + "methods": [ + "deletePerInstanceConfigs" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "PatchPerInstanceConfigs": { + "methods": [ + "patchPerInstanceConfigs" + ] + }, + "RecreateInstances": { + "methods": [ + "recreateInstances" + ] + }, + "Resize": { + "methods": [ + "resize" + ] + }, + "SetInstanceTemplate": { + "methods": [ + "setInstanceTemplate" + ] + }, + "SetTargetPools": { + "methods": [ + "setTargetPools" + ] + }, + "UpdatePerInstanceConfigs": { + "methods": [ + "updatePerInstanceConfigs" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListErrors": { + "methods": [ + "listErrors", + "listErrorsStream", + "listErrorsAsync" + ] + }, + "ListManagedInstances": { + "methods": [ + "listManagedInstances", + "listManagedInstancesStream", + "listManagedInstancesAsync" + ] + }, + "ListPerInstanceConfigs": { + "methods": [ + "listPerInstanceConfigs", + "listPerInstanceConfigsStream", + "listPerInstanceConfigsAsync" + ] + } + } + } + } + }, + "InstanceGroups": { + "clients": { + "grpc": { + "libraryClient": "InstanceGroupsClient", + "rpcs": { + "AddInstances": { + "methods": [ + "addInstances" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "RemoveInstances": { + "methods": [ + "removeInstances" + ] + }, + "SetNamedPorts": { + "methods": [ + "setNamedPorts" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "InstanceGroupsClient", + "rpcs": { + "AddInstances": { + "methods": [ + "addInstances" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "RemoveInstances": { + "methods": [ + "removeInstances" + ] + }, + "SetNamedPorts": { + "methods": [ + "setNamedPorts" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + } + } + } + } + }, + "Instances": { + "clients": { + "grpc": { + "libraryClient": "InstancesClient", + "rpcs": { + "AddAccessConfig": { + "methods": [ + "addAccessConfig" + ] + }, + "AddResourcePolicies": { + "methods": [ + "addResourcePolicies" + ] + }, + "AttachDisk": { + "methods": [ + "attachDisk" + ] + }, + "BulkInsert": { + "methods": [ + "bulkInsert" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "DeleteAccessConfig": { + "methods": [ + "deleteAccessConfig" + ] + }, + "DetachDisk": { + "methods": [ + "detachDisk" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetEffectiveFirewalls": { + "methods": [ + "getEffectiveFirewalls" + ] + }, + "GetGuestAttributes": { + "methods": [ + "getGuestAttributes" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "GetScreenshot": { + "methods": [ + "getScreenshot" + ] + }, + "GetSerialPortOutput": { + "methods": [ + "getSerialPortOutput" + ] + }, + "GetShieldedInstanceIdentity": { + "methods": [ + "getShieldedInstanceIdentity" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "RemoveResourcePolicies": { + "methods": [ + "removeResourcePolicies" + ] + }, + "Reset": { + "methods": [ + "reset" + ] + }, + "Resume": { + "methods": [ + "resume" + ] + }, + "SendDiagnosticInterrupt": { + "methods": [ + "sendDiagnosticInterrupt" + ] + }, + "SetDeletionProtection": { + "methods": [ + "setDeletionProtection" + ] + }, + "SetDiskAutoDelete": { + "methods": [ + "setDiskAutoDelete" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "SetMachineResources": { + "methods": [ + "setMachineResources" + ] + }, + "SetMachineType": { + "methods": [ + "setMachineType" + ] + }, + "SetMetadata": { + "methods": [ + "setMetadata" + ] + }, + "SetMinCpuPlatform": { + "methods": [ + "setMinCpuPlatform" + ] + }, + "SetName": { + "methods": [ + "setName" + ] + }, + "SetScheduling": { + "methods": [ + "setScheduling" + ] + }, + "SetServiceAccount": { + "methods": [ + "setServiceAccount" + ] + }, + "SetShieldedInstanceIntegrityPolicy": { + "methods": [ + "setShieldedInstanceIntegrityPolicy" + ] + }, + "SetTags": { + "methods": [ + "setTags" + ] + }, + "SimulateMaintenanceEvent": { + "methods": [ + "simulateMaintenanceEvent" + ] + }, + "Start": { + "methods": [ + "start" + ] + }, + "StartWithEncryptionKey": { + "methods": [ + "startWithEncryptionKey" + ] + }, + "Stop": { + "methods": [ + "stop" + ] + }, + "Suspend": { + "methods": [ + "suspend" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "UpdateAccessConfig": { + "methods": [ + "updateAccessConfig" + ] + }, + "UpdateDisplayDevice": { + "methods": [ + "updateDisplayDevice" + ] + }, + "UpdateNetworkInterface": { + "methods": [ + "updateNetworkInterface" + ] + }, + "UpdateShieldedInstanceConfig": { + "methods": [ + "updateShieldedInstanceConfig" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListReferrers": { + "methods": [ + "listReferrers", + "listReferrersStream", + "listReferrersAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "InstancesClient", + "rpcs": { + "AddAccessConfig": { + "methods": [ + "addAccessConfig" + ] + }, + "AddResourcePolicies": { + "methods": [ + "addResourcePolicies" + ] + }, + "AttachDisk": { + "methods": [ + "attachDisk" + ] + }, + "BulkInsert": { + "methods": [ + "bulkInsert" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "DeleteAccessConfig": { + "methods": [ + "deleteAccessConfig" + ] + }, + "DetachDisk": { + "methods": [ + "detachDisk" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetEffectiveFirewalls": { + "methods": [ + "getEffectiveFirewalls" + ] + }, + "GetGuestAttributes": { + "methods": [ + "getGuestAttributes" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "GetScreenshot": { + "methods": [ + "getScreenshot" + ] + }, + "GetSerialPortOutput": { + "methods": [ + "getSerialPortOutput" + ] + }, + "GetShieldedInstanceIdentity": { + "methods": [ + "getShieldedInstanceIdentity" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "RemoveResourcePolicies": { + "methods": [ + "removeResourcePolicies" + ] + }, + "Reset": { + "methods": [ + "reset" + ] + }, + "Resume": { + "methods": [ + "resume" + ] + }, + "SendDiagnosticInterrupt": { + "methods": [ + "sendDiagnosticInterrupt" + ] + }, + "SetDeletionProtection": { + "methods": [ + "setDeletionProtection" + ] + }, + "SetDiskAutoDelete": { + "methods": [ + "setDiskAutoDelete" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "SetMachineResources": { + "methods": [ + "setMachineResources" + ] + }, + "SetMachineType": { + "methods": [ + "setMachineType" + ] + }, + "SetMetadata": { + "methods": [ + "setMetadata" + ] + }, + "SetMinCpuPlatform": { + "methods": [ + "setMinCpuPlatform" + ] + }, + "SetName": { + "methods": [ + "setName" + ] + }, + "SetScheduling": { + "methods": [ + "setScheduling" + ] + }, + "SetServiceAccount": { + "methods": [ + "setServiceAccount" + ] + }, + "SetShieldedInstanceIntegrityPolicy": { + "methods": [ + "setShieldedInstanceIntegrityPolicy" + ] + }, + "SetTags": { + "methods": [ + "setTags" + ] + }, + "SimulateMaintenanceEvent": { + "methods": [ + "simulateMaintenanceEvent" + ] + }, + "Start": { + "methods": [ + "start" + ] + }, + "StartWithEncryptionKey": { + "methods": [ + "startWithEncryptionKey" + ] + }, + "Stop": { + "methods": [ + "stop" + ] + }, + "Suspend": { + "methods": [ + "suspend" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "UpdateAccessConfig": { + "methods": [ + "updateAccessConfig" + ] + }, + "UpdateDisplayDevice": { + "methods": [ + "updateDisplayDevice" + ] + }, + "UpdateNetworkInterface": { + "methods": [ + "updateNetworkInterface" + ] + }, + "UpdateShieldedInstanceConfig": { + "methods": [ + "updateShieldedInstanceConfig" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListReferrers": { + "methods": [ + "listReferrers", + "listReferrersStream", + "listReferrersAsync" + ] + } + } + } + } + }, + "InstanceTemplates": { + "clients": { + "grpc": { + "libraryClient": "InstanceTemplatesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "InstanceTemplatesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "InterconnectAttachments": { + "clients": { + "grpc": { + "libraryClient": "InterconnectAttachmentsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "InterconnectAttachmentsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "InterconnectLocations": { + "clients": { + "grpc": { + "libraryClient": "InterconnectLocationsClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "InterconnectLocationsClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "Interconnects": { + "clients": { + "grpc": { + "libraryClient": "InterconnectsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetDiagnostics": { + "methods": [ + "getDiagnostics" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "InterconnectsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetDiagnostics": { + "methods": [ + "getDiagnostics" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "LicenseCodes": { + "clients": { + "grpc": { + "libraryClient": "LicenseCodesClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "LicenseCodesClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + } + } + } + } + }, + "Licenses": { + "clients": { + "grpc": { + "libraryClient": "LicensesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "LicensesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "MachineImages": { + "clients": { + "grpc": { + "libraryClient": "MachineImagesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "MachineImagesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "MachineTypes": { + "clients": { + "grpc": { + "libraryClient": "MachineTypesClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "MachineTypesClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "NetworkAttachments": { + "clients": { + "grpc": { + "libraryClient": "NetworkAttachmentsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "NetworkAttachmentsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "NetworkEdgeSecurityServices": { + "clients": { + "grpc": { + "libraryClient": "NetworkEdgeSecurityServicesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "NetworkEdgeSecurityServicesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + } + } + } + } + }, + "NetworkEndpointGroups": { + "clients": { + "grpc": { + "libraryClient": "NetworkEndpointGroupsClient", + "rpcs": { + "AttachNetworkEndpoints": { + "methods": [ + "attachNetworkEndpoints" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "DetachNetworkEndpoints": { + "methods": [ + "detachNetworkEndpoints" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListNetworkEndpoints": { + "methods": [ + "listNetworkEndpoints", + "listNetworkEndpointsStream", + "listNetworkEndpointsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "NetworkEndpointGroupsClient", + "rpcs": { + "AttachNetworkEndpoints": { + "methods": [ + "attachNetworkEndpoints" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "DetachNetworkEndpoints": { + "methods": [ + "detachNetworkEndpoints" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListNetworkEndpoints": { + "methods": [ + "listNetworkEndpoints", + "listNetworkEndpointsStream", + "listNetworkEndpointsAsync" + ] + } + } + } + } + }, + "NetworkFirewallPolicies": { + "clients": { + "grpc": { + "libraryClient": "NetworkFirewallPoliciesClient", + "rpcs": { + "AddAssociation": { + "methods": [ + "addAssociation" + ] + }, + "AddRule": { + "methods": [ + "addRule" + ] + }, + "CloneRules": { + "methods": [ + "cloneRules" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetAssociation": { + "methods": [ + "getAssociation" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "GetRule": { + "methods": [ + "getRule" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "PatchRule": { + "methods": [ + "patchRule" + ] + }, + "RemoveAssociation": { + "methods": [ + "removeAssociation" + ] + }, + "RemoveRule": { + "methods": [ + "removeRule" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "NetworkFirewallPoliciesClient", + "rpcs": { + "AddAssociation": { + "methods": [ + "addAssociation" + ] + }, + "AddRule": { + "methods": [ + "addRule" + ] + }, + "CloneRules": { + "methods": [ + "cloneRules" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetAssociation": { + "methods": [ + "getAssociation" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "GetRule": { + "methods": [ + "getRule" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "PatchRule": { + "methods": [ + "patchRule" + ] + }, + "RemoveAssociation": { + "methods": [ + "removeAssociation" + ] + }, + "RemoveRule": { + "methods": [ + "removeRule" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "Networks": { + "clients": { + "grpc": { + "libraryClient": "NetworksClient", + "rpcs": { + "AddPeering": { + "methods": [ + "addPeering" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetEffectiveFirewalls": { + "methods": [ + "getEffectiveFirewalls" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "RemovePeering": { + "methods": [ + "removePeering" + ] + }, + "SwitchToCustomMode": { + "methods": [ + "switchToCustomMode" + ] + }, + "UpdatePeering": { + "methods": [ + "updatePeering" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListPeeringRoutes": { + "methods": [ + "listPeeringRoutes", + "listPeeringRoutesStream", + "listPeeringRoutesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "NetworksClient", + "rpcs": { + "AddPeering": { + "methods": [ + "addPeering" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetEffectiveFirewalls": { + "methods": [ + "getEffectiveFirewalls" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "RemovePeering": { + "methods": [ + "removePeering" + ] + }, + "SwitchToCustomMode": { + "methods": [ + "switchToCustomMode" + ] + }, + "UpdatePeering": { + "methods": [ + "updatePeering" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListPeeringRoutes": { + "methods": [ + "listPeeringRoutes", + "listPeeringRoutesStream", + "listPeeringRoutesAsync" + ] + } + } + } + } + }, + "NodeGroups": { + "clients": { + "grpc": { + "libraryClient": "NodeGroupsClient", + "rpcs": { + "AddNodes": { + "methods": [ + "addNodes" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "DeleteNodes": { + "methods": [ + "deleteNodes" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SetNodeTemplate": { + "methods": [ + "setNodeTemplate" + ] + }, + "SimulateMaintenanceEvent": { + "methods": [ + "simulateMaintenanceEvent" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListNodes": { + "methods": [ + "listNodes", + "listNodesStream", + "listNodesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "NodeGroupsClient", + "rpcs": { + "AddNodes": { + "methods": [ + "addNodes" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "DeleteNodes": { + "methods": [ + "deleteNodes" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SetNodeTemplate": { + "methods": [ + "setNodeTemplate" + ] + }, + "SimulateMaintenanceEvent": { + "methods": [ + "simulateMaintenanceEvent" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListNodes": { + "methods": [ + "listNodes", + "listNodesStream", + "listNodesAsync" + ] + } + } + } + } + }, + "NodeTemplates": { + "clients": { + "grpc": { + "libraryClient": "NodeTemplatesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "NodeTemplatesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "NodeTypes": { + "clients": { + "grpc": { + "libraryClient": "NodeTypesClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "NodeTypesClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "PacketMirrorings": { + "clients": { + "grpc": { + "libraryClient": "PacketMirroringsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "PacketMirroringsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "Projects": { + "clients": { + "grpc": { + "libraryClient": "ProjectsClient", + "rpcs": { + "DisableXpnHost": { + "methods": [ + "disableXpnHost" + ] + }, + "DisableXpnResource": { + "methods": [ + "disableXpnResource" + ] + }, + "EnableXpnHost": { + "methods": [ + "enableXpnHost" + ] + }, + "EnableXpnResource": { + "methods": [ + "enableXpnResource" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetXpnHost": { + "methods": [ + "getXpnHost" + ] + }, + "MoveDisk": { + "methods": [ + "moveDisk" + ] + }, + "MoveInstance": { + "methods": [ + "moveInstance" + ] + }, + "SetCommonInstanceMetadata": { + "methods": [ + "setCommonInstanceMetadata" + ] + }, + "SetDefaultNetworkTier": { + "methods": [ + "setDefaultNetworkTier" + ] + }, + "SetUsageExportBucket": { + "methods": [ + "setUsageExportBucket" + ] + }, + "GetXpnResources": { + "methods": [ + "getXpnResources", + "getXpnResourcesStream", + "getXpnResourcesAsync" + ] + }, + "ListXpnHosts": { + "methods": [ + "listXpnHosts", + "listXpnHostsStream", + "listXpnHostsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProjectsClient", + "rpcs": { + "DisableXpnHost": { + "methods": [ + "disableXpnHost" + ] + }, + "DisableXpnResource": { + "methods": [ + "disableXpnResource" + ] + }, + "EnableXpnHost": { + "methods": [ + "enableXpnHost" + ] + }, + "EnableXpnResource": { + "methods": [ + "enableXpnResource" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetXpnHost": { + "methods": [ + "getXpnHost" + ] + }, + "MoveDisk": { + "methods": [ + "moveDisk" + ] + }, + "MoveInstance": { + "methods": [ + "moveInstance" + ] + }, + "SetCommonInstanceMetadata": { + "methods": [ + "setCommonInstanceMetadata" + ] + }, + "SetDefaultNetworkTier": { + "methods": [ + "setDefaultNetworkTier" + ] + }, + "SetUsageExportBucket": { + "methods": [ + "setUsageExportBucket" + ] + }, + "GetXpnResources": { + "methods": [ + "getXpnResources", + "getXpnResourcesStream", + "getXpnResourcesAsync" + ] + }, + "ListXpnHosts": { + "methods": [ + "listXpnHosts", + "listXpnHostsStream", + "listXpnHostsAsync" + ] + } + } + } + } + }, + "PublicAdvertisedPrefixes": { + "clients": { + "grpc": { + "libraryClient": "PublicAdvertisedPrefixesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "PublicAdvertisedPrefixesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "PublicDelegatedPrefixes": { + "clients": { + "grpc": { + "libraryClient": "PublicDelegatedPrefixesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "PublicDelegatedPrefixesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionAutoscalers": { + "clients": { + "grpc": { + "libraryClient": "RegionAutoscalersClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionAutoscalersClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionBackendServices": { + "clients": { + "grpc": { + "libraryClient": "RegionBackendServicesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetHealth": { + "methods": [ + "getHealth" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionBackendServicesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetHealth": { + "methods": [ + "getHealth" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionCommitments": { + "clients": { + "grpc": { + "libraryClient": "RegionCommitmentsClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionCommitmentsClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionDisks": { + "clients": { + "grpc": { + "libraryClient": "RegionDisksClient", + "rpcs": { + "AddResourcePolicies": { + "methods": [ + "addResourcePolicies" + ] + }, + "CreateSnapshot": { + "methods": [ + "createSnapshot" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "RemoveResourcePolicies": { + "methods": [ + "removeResourcePolicies" + ] + }, + "Resize": { + "methods": [ + "resize" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionDisksClient", + "rpcs": { + "AddResourcePolicies": { + "methods": [ + "addResourcePolicies" + ] + }, + "CreateSnapshot": { + "methods": [ + "createSnapshot" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "RemoveResourcePolicies": { + "methods": [ + "removeResourcePolicies" + ] + }, + "Resize": { + "methods": [ + "resize" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionDiskTypes": { + "clients": { + "grpc": { + "libraryClient": "RegionDiskTypesClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionDiskTypesClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionHealthChecks": { + "clients": { + "grpc": { + "libraryClient": "RegionHealthChecksClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionHealthChecksClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionHealthCheckServices": { + "clients": { + "grpc": { + "libraryClient": "RegionHealthCheckServicesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionHealthCheckServicesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionInstanceGroupManagers": { + "clients": { + "grpc": { + "libraryClient": "RegionInstanceGroupManagersClient", + "rpcs": { + "AbandonInstances": { + "methods": [ + "abandonInstances" + ] + }, + "ApplyUpdatesToInstances": { + "methods": [ + "applyUpdatesToInstances" + ] + }, + "CreateInstances": { + "methods": [ + "createInstances" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "DeleteInstances": { + "methods": [ + "deleteInstances" + ] + }, + "DeletePerInstanceConfigs": { + "methods": [ + "deletePerInstanceConfigs" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "PatchPerInstanceConfigs": { + "methods": [ + "patchPerInstanceConfigs" + ] + }, + "RecreateInstances": { + "methods": [ + "recreateInstances" + ] + }, + "Resize": { + "methods": [ + "resize" + ] + }, + "SetInstanceTemplate": { + "methods": [ + "setInstanceTemplate" + ] + }, + "SetTargetPools": { + "methods": [ + "setTargetPools" + ] + }, + "UpdatePerInstanceConfigs": { + "methods": [ + "updatePerInstanceConfigs" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListErrors": { + "methods": [ + "listErrors", + "listErrorsStream", + "listErrorsAsync" + ] + }, + "ListManagedInstances": { + "methods": [ + "listManagedInstances", + "listManagedInstancesStream", + "listManagedInstancesAsync" + ] + }, + "ListPerInstanceConfigs": { + "methods": [ + "listPerInstanceConfigs", + "listPerInstanceConfigsStream", + "listPerInstanceConfigsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionInstanceGroupManagersClient", + "rpcs": { + "AbandonInstances": { + "methods": [ + "abandonInstances" + ] + }, + "ApplyUpdatesToInstances": { + "methods": [ + "applyUpdatesToInstances" + ] + }, + "CreateInstances": { + "methods": [ + "createInstances" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "DeleteInstances": { + "methods": [ + "deleteInstances" + ] + }, + "DeletePerInstanceConfigs": { + "methods": [ + "deletePerInstanceConfigs" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "PatchPerInstanceConfigs": { + "methods": [ + "patchPerInstanceConfigs" + ] + }, + "RecreateInstances": { + "methods": [ + "recreateInstances" + ] + }, + "Resize": { + "methods": [ + "resize" + ] + }, + "SetInstanceTemplate": { + "methods": [ + "setInstanceTemplate" + ] + }, + "SetTargetPools": { + "methods": [ + "setTargetPools" + ] + }, + "UpdatePerInstanceConfigs": { + "methods": [ + "updatePerInstanceConfigs" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListErrors": { + "methods": [ + "listErrors", + "listErrorsStream", + "listErrorsAsync" + ] + }, + "ListManagedInstances": { + "methods": [ + "listManagedInstances", + "listManagedInstancesStream", + "listManagedInstancesAsync" + ] + }, + "ListPerInstanceConfigs": { + "methods": [ + "listPerInstanceConfigs", + "listPerInstanceConfigsStream", + "listPerInstanceConfigsAsync" + ] + } + } + } + } + }, + "RegionInstanceGroups": { + "clients": { + "grpc": { + "libraryClient": "RegionInstanceGroupsClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "SetNamedPorts": { + "methods": [ + "setNamedPorts" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionInstanceGroupsClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "SetNamedPorts": { + "methods": [ + "setNamedPorts" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + } + } + } + } + }, + "RegionInstances": { + "clients": { + "grpc": { + "libraryClient": "RegionInstancesClient", + "rpcs": { + "BulkInsert": { + "methods": [ + "bulkInsert" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionInstancesClient", + "rpcs": { + "BulkInsert": { + "methods": [ + "bulkInsert" + ] + } + } + } + } + }, + "RegionInstanceTemplates": { + "clients": { + "grpc": { + "libraryClient": "RegionInstanceTemplatesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionInstanceTemplatesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionNetworkEndpointGroups": { + "clients": { + "grpc": { + "libraryClient": "RegionNetworkEndpointGroupsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionNetworkEndpointGroupsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionNetworkFirewallPolicies": { + "clients": { + "grpc": { + "libraryClient": "RegionNetworkFirewallPoliciesClient", + "rpcs": { + "AddAssociation": { + "methods": [ + "addAssociation" + ] + }, + "AddRule": { + "methods": [ + "addRule" + ] + }, + "CloneRules": { + "methods": [ + "cloneRules" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetAssociation": { + "methods": [ + "getAssociation" + ] + }, + "GetEffectiveFirewalls": { + "methods": [ + "getEffectiveFirewalls" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "GetRule": { + "methods": [ + "getRule" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "PatchRule": { + "methods": [ + "patchRule" + ] + }, + "RemoveAssociation": { + "methods": [ + "removeAssociation" + ] + }, + "RemoveRule": { + "methods": [ + "removeRule" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionNetworkFirewallPoliciesClient", + "rpcs": { + "AddAssociation": { + "methods": [ + "addAssociation" + ] + }, + "AddRule": { + "methods": [ + "addRule" + ] + }, + "CloneRules": { + "methods": [ + "cloneRules" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetAssociation": { + "methods": [ + "getAssociation" + ] + }, + "GetEffectiveFirewalls": { + "methods": [ + "getEffectiveFirewalls" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "GetRule": { + "methods": [ + "getRule" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "PatchRule": { + "methods": [ + "patchRule" + ] + }, + "RemoveAssociation": { + "methods": [ + "removeAssociation" + ] + }, + "RemoveRule": { + "methods": [ + "removeRule" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionNotificationEndpoints": { + "clients": { + "grpc": { + "libraryClient": "RegionNotificationEndpointsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionNotificationEndpointsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionOperations": { + "clients": { + "grpc": { + "libraryClient": "RegionOperationsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Wait": { + "methods": [ + "wait" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionOperationsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Wait": { + "methods": [ + "wait" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "Regions": { + "clients": { + "grpc": { + "libraryClient": "RegionsClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionsClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionSecurityPolicies": { + "clients": { + "grpc": { + "libraryClient": "RegionSecurityPoliciesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionSecurityPoliciesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionSslCertificates": { + "clients": { + "grpc": { + "libraryClient": "RegionSslCertificatesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionSslCertificatesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionSslPolicies": { + "clients": { + "grpc": { + "libraryClient": "RegionSslPoliciesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "ListAvailableFeatures": { + "methods": [ + "listAvailableFeatures" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionSslPoliciesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "ListAvailableFeatures": { + "methods": [ + "listAvailableFeatures" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionTargetHttpProxies": { + "clients": { + "grpc": { + "libraryClient": "RegionTargetHttpProxiesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetUrlMap": { + "methods": [ + "setUrlMap" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionTargetHttpProxiesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetUrlMap": { + "methods": [ + "setUrlMap" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionTargetHttpsProxies": { + "clients": { + "grpc": { + "libraryClient": "RegionTargetHttpsProxiesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetSslCertificates": { + "methods": [ + "setSslCertificates" + ] + }, + "SetUrlMap": { + "methods": [ + "setUrlMap" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionTargetHttpsProxiesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetSslCertificates": { + "methods": [ + "setSslCertificates" + ] + }, + "SetUrlMap": { + "methods": [ + "setUrlMap" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionTargetTcpProxies": { + "clients": { + "grpc": { + "libraryClient": "RegionTargetTcpProxiesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionTargetTcpProxiesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionUrlMaps": { + "clients": { + "grpc": { + "libraryClient": "RegionUrlMapsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "Validate": { + "methods": [ + "validate" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionUrlMapsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "Validate": { + "methods": [ + "validate" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "Reservations": { + "clients": { + "grpc": { + "libraryClient": "ReservationsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Resize": { + "methods": [ + "resize" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ReservationsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Resize": { + "methods": [ + "resize" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "ResourcePolicies": { + "clients": { + "grpc": { + "libraryClient": "ResourcePoliciesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ResourcePoliciesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "Routers": { + "clients": { + "grpc": { + "libraryClient": "RoutersClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetRouterStatus": { + "methods": [ + "getRouterStatus" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "Preview": { + "methods": [ + "preview" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "GetNatMappingInfo": { + "methods": [ + "getNatMappingInfo", + "getNatMappingInfoStream", + "getNatMappingInfoAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RoutersClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetRouterStatus": { + "methods": [ + "getRouterStatus" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "Preview": { + "methods": [ + "preview" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "GetNatMappingInfo": { + "methods": [ + "getNatMappingInfo", + "getNatMappingInfoStream", + "getNatMappingInfoAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "Routes": { + "clients": { + "grpc": { + "libraryClient": "RoutesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RoutesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "SecurityPolicies": { + "clients": { + "grpc": { + "libraryClient": "SecurityPoliciesClient", + "rpcs": { + "AddRule": { + "methods": [ + "addRule" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetRule": { + "methods": [ + "getRule" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "ListPreconfiguredExpressionSets": { + "methods": [ + "listPreconfiguredExpressionSets" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "PatchRule": { + "methods": [ + "patchRule" + ] + }, + "RemoveRule": { + "methods": [ + "removeRule" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SecurityPoliciesClient", + "rpcs": { + "AddRule": { + "methods": [ + "addRule" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetRule": { + "methods": [ + "getRule" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "ListPreconfiguredExpressionSets": { + "methods": [ + "listPreconfiguredExpressionSets" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "PatchRule": { + "methods": [ + "patchRule" + ] + }, + "RemoveRule": { + "methods": [ + "removeRule" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "ServiceAttachments": { + "clients": { + "grpc": { + "libraryClient": "ServiceAttachmentsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ServiceAttachmentsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "Snapshots": { + "clients": { + "grpc": { + "libraryClient": "SnapshotsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SnapshotsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "SslCertificates": { + "clients": { + "grpc": { + "libraryClient": "SslCertificatesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SslCertificatesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "SslPolicies": { + "clients": { + "grpc": { + "libraryClient": "SslPoliciesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "ListAvailableFeatures": { + "methods": [ + "listAvailableFeatures" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SslPoliciesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "ListAvailableFeatures": { + "methods": [ + "listAvailableFeatures" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "Subnetworks": { + "clients": { + "grpc": { + "libraryClient": "SubnetworksClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "ExpandIpCidrRange": { + "methods": [ + "expandIpCidrRange" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SetPrivateIpGoogleAccess": { + "methods": [ + "setPrivateIpGoogleAccess" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListUsable": { + "methods": [ + "listUsable", + "listUsableStream", + "listUsableAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SubnetworksClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "ExpandIpCidrRange": { + "methods": [ + "expandIpCidrRange" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SetPrivateIpGoogleAccess": { + "methods": [ + "setPrivateIpGoogleAccess" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + }, + "ListUsable": { + "methods": [ + "listUsable", + "listUsableStream", + "listUsableAsync" + ] + } + } + } + } + }, + "TargetGrpcProxies": { + "clients": { + "grpc": { + "libraryClient": "TargetGrpcProxiesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TargetGrpcProxiesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "TargetHttpProxies": { + "clients": { + "grpc": { + "libraryClient": "TargetHttpProxiesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetUrlMap": { + "methods": [ + "setUrlMap" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TargetHttpProxiesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetUrlMap": { + "methods": [ + "setUrlMap" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "TargetHttpsProxies": { + "clients": { + "grpc": { + "libraryClient": "TargetHttpsProxiesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetCertificateMap": { + "methods": [ + "setCertificateMap" + ] + }, + "SetQuicOverride": { + "methods": [ + "setQuicOverride" + ] + }, + "SetSslCertificates": { + "methods": [ + "setSslCertificates" + ] + }, + "SetSslPolicy": { + "methods": [ + "setSslPolicy" + ] + }, + "SetUrlMap": { + "methods": [ + "setUrlMap" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TargetHttpsProxiesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "SetCertificateMap": { + "methods": [ + "setCertificateMap" + ] + }, + "SetQuicOverride": { + "methods": [ + "setQuicOverride" + ] + }, + "SetSslCertificates": { + "methods": [ + "setSslCertificates" + ] + }, + "SetSslPolicy": { + "methods": [ + "setSslPolicy" + ] + }, + "SetUrlMap": { + "methods": [ + "setUrlMap" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "TargetInstances": { + "clients": { + "grpc": { + "libraryClient": "TargetInstancesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TargetInstancesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "TargetPools": { + "clients": { + "grpc": { + "libraryClient": "TargetPoolsClient", + "rpcs": { + "AddHealthCheck": { + "methods": [ + "addHealthCheck" + ] + }, + "AddInstance": { + "methods": [ + "addInstance" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetHealth": { + "methods": [ + "getHealth" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "RemoveHealthCheck": { + "methods": [ + "removeHealthCheck" + ] + }, + "RemoveInstance": { + "methods": [ + "removeInstance" + ] + }, + "SetBackup": { + "methods": [ + "setBackup" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TargetPoolsClient", + "rpcs": { + "AddHealthCheck": { + "methods": [ + "addHealthCheck" + ] + }, + "AddInstance": { + "methods": [ + "addInstance" + ] + }, + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetHealth": { + "methods": [ + "getHealth" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "RemoveHealthCheck": { + "methods": [ + "removeHealthCheck" + ] + }, + "RemoveInstance": { + "methods": [ + "removeInstance" + ] + }, + "SetBackup": { + "methods": [ + "setBackup" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "TargetSslProxies": { + "clients": { + "grpc": { + "libraryClient": "TargetSslProxiesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetBackendService": { + "methods": [ + "setBackendService" + ] + }, + "SetCertificateMap": { + "methods": [ + "setCertificateMap" + ] + }, + "SetProxyHeader": { + "methods": [ + "setProxyHeader" + ] + }, + "SetSslCertificates": { + "methods": [ + "setSslCertificates" + ] + }, + "SetSslPolicy": { + "methods": [ + "setSslPolicy" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TargetSslProxiesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetBackendService": { + "methods": [ + "setBackendService" + ] + }, + "SetCertificateMap": { + "methods": [ + "setCertificateMap" + ] + }, + "SetProxyHeader": { + "methods": [ + "setProxyHeader" + ] + }, + "SetSslCertificates": { + "methods": [ + "setSslCertificates" + ] + }, + "SetSslPolicy": { + "methods": [ + "setSslPolicy" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "TargetTcpProxies": { + "clients": { + "grpc": { + "libraryClient": "TargetTcpProxiesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetBackendService": { + "methods": [ + "setBackendService" + ] + }, + "SetProxyHeader": { + "methods": [ + "setProxyHeader" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TargetTcpProxiesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetBackendService": { + "methods": [ + "setBackendService" + ] + }, + "SetProxyHeader": { + "methods": [ + "setProxyHeader" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "TargetVpnGateways": { + "clients": { + "grpc": { + "libraryClient": "TargetVpnGatewaysClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TargetVpnGatewaysClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "UrlMaps": { + "clients": { + "grpc": { + "libraryClient": "UrlMapsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "InvalidateCache": { + "methods": [ + "invalidateCache" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "Validate": { + "methods": [ + "validate" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "UrlMapsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "InvalidateCache": { + "methods": [ + "invalidateCache" + ] + }, + "Patch": { + "methods": [ + "patch" + ] + }, + "Update": { + "methods": [ + "update" + ] + }, + "Validate": { + "methods": [ + "validate" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "VpnGateways": { + "clients": { + "grpc": { + "libraryClient": "VpnGatewaysClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetStatus": { + "methods": [ + "getStatus" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "VpnGatewaysClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "GetStatus": { + "methods": [ + "getStatus" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "VpnTunnels": { + "clients": { + "grpc": { + "libraryClient": "VpnTunnelsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "VpnTunnelsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "SetLabels": { + "methods": [ + "setLabels" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "ZoneOperations": { + "clients": { + "grpc": { + "libraryClient": "ZoneOperationsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Wait": { + "methods": [ + "wait" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ZoneOperationsClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Get": { + "methods": [ + "get" + ] + }, + "Wait": { + "methods": [ + "wait" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "Zones": { + "clients": { + "grpc": { + "libraryClient": "ZonesClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ZonesClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_addresses_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_addresses_client.ts new file mode 100644 index 00000000000..9e9ceff2b79 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_addresses_client.ts @@ -0,0 +1,845 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/global_addresses_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './global_addresses_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The GlobalAddresses API. + * @class + * @memberof v1 + */ +export class GlobalAddressesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + globalAddressesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of GlobalAddressesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new GlobalAddressesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof GlobalAddressesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.GlobalAddresses', 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.globalAddressesStub) { + return this.globalAddressesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.GlobalAddresses. + this.globalAddressesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.GlobalAddresses') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.GlobalAddresses, + 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 globalAddressesStubMethods = + ['delete', 'get', 'insert', 'list', 'setLabels']; + for (const methodName of globalAddressesStubMethods) { + const callPromise = this.globalAddressesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.globalAddressesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified address resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.address + * Name of the address resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/global_addresses.delete.js + * region_tag:compute_v1_generated_GlobalAddresses_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteGlobalAddressRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteGlobalAddressRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteGlobalAddressRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteGlobalAddressRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteGlobalAddressRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteGlobalAddressRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteGlobalAddressRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteGlobalAddressRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'address': request.address ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified address resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.address + * Name of the address resource to return. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.Address | Address}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/global_addresses.get.js + * region_tag:compute_v1_generated_GlobalAddresses_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetGlobalAddressRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IAddress, + protos.google.cloud.compute.v1.IGetGlobalAddressRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetGlobalAddressRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IAddress, + protos.google.cloud.compute.v1.IGetGlobalAddressRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetGlobalAddressRequest, + callback: Callback< + protos.google.cloud.compute.v1.IAddress, + protos.google.cloud.compute.v1.IGetGlobalAddressRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetGlobalAddressRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IAddress, + protos.google.cloud.compute.v1.IGetGlobalAddressRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IAddress, + protos.google.cloud.compute.v1.IGetGlobalAddressRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IAddress, + protos.google.cloud.compute.v1.IGetGlobalAddressRequest|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({ + 'project': request.project ?? '', + 'address': request.address ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates an address resource in the specified project by using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.Address} request.addressResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/global_addresses.insert.js + * region_tag:compute_v1_generated_GlobalAddresses_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertGlobalAddressRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertGlobalAddressRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertGlobalAddressRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertGlobalAddressRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertGlobalAddressRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertGlobalAddressRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertGlobalAddressRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertGlobalAddressRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the labels on a GlobalAddress. To learn more about labels, read the Labeling Resources documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalSetLabelsRequest} request.globalSetLabelsRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/global_addresses.set_labels.js + * region_tag:compute_v1_generated_GlobalAddresses_SetLabels_async + */ + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsGlobalAddressRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsGlobalAddressRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsGlobalAddressRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsGlobalAddressRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsGlobalAddressRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsGlobalAddressRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsGlobalAddressRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsGlobalAddressRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setLabels(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves a list of global addresses. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Address | Address}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListGlobalAddressesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IAddress[], + protos.google.cloud.compute.v1.IListGlobalAddressesRequest|null, + protos.google.cloud.compute.v1.IAddressList + ]>; + list( + request: protos.google.cloud.compute.v1.IListGlobalAddressesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalAddressesRequest, + protos.google.cloud.compute.v1.IAddressList|null|undefined, + protos.google.cloud.compute.v1.IAddress>): void; + list( + request: protos.google.cloud.compute.v1.IListGlobalAddressesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalAddressesRequest, + protos.google.cloud.compute.v1.IAddressList|null|undefined, + protos.google.cloud.compute.v1.IAddress>): void; + list( + request?: protos.google.cloud.compute.v1.IListGlobalAddressesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalAddressesRequest, + protos.google.cloud.compute.v1.IAddressList|null|undefined, + protos.google.cloud.compute.v1.IAddress>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalAddressesRequest, + protos.google.cloud.compute.v1.IAddressList|null|undefined, + protos.google.cloud.compute.v1.IAddress>): + Promise<[ + protos.google.cloud.compute.v1.IAddress[], + protos.google.cloud.compute.v1.IListGlobalAddressesRequest|null, + protos.google.cloud.compute.v1.IAddressList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Address | Address} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListGlobalAddressesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Address | Address}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/global_addresses.list.js + * region_tag:compute_v1_generated_GlobalAddresses_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListGlobalAddressesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.globalAddressesStub && !this._terminated) { + return this.globalAddressesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_addresses_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_addresses_client_config.json new file mode 100644 index 00000000000..f6cf35993f6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_addresses_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.compute.v1.GlobalAddresses": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetLabels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_addresses_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_addresses_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_addresses_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_forwarding_rules_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_forwarding_rules_client.ts new file mode 100644 index 00000000000..bc97ed289b5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_forwarding_rules_client.ts @@ -0,0 +1,1025 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/global_forwarding_rules_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './global_forwarding_rules_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The GlobalForwardingRules API. + * @class + * @memberof v1 + */ +export class GlobalForwardingRulesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + globalForwardingRulesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of GlobalForwardingRulesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new GlobalForwardingRulesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof GlobalForwardingRulesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.GlobalForwardingRules', 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.globalForwardingRulesStub) { + return this.globalForwardingRulesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.GlobalForwardingRules. + this.globalForwardingRulesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.GlobalForwardingRules') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.GlobalForwardingRules, + 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 globalForwardingRulesStubMethods = + ['delete', 'get', 'insert', 'list', 'patch', 'setLabels', 'setTarget']; + for (const methodName of globalForwardingRulesStubMethods) { + const callPromise = this.globalForwardingRulesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.globalForwardingRulesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified GlobalForwardingRule resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.forwardingRule + * Name of the ForwardingRule resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/global_forwarding_rules.delete.js + * region_tag:compute_v1_generated_GlobalForwardingRules_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteGlobalForwardingRuleRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteGlobalForwardingRuleRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteGlobalForwardingRuleRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteGlobalForwardingRuleRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'forwarding_rule': request.forwardingRule ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified GlobalForwardingRule resource. Gets a list of available forwarding rules by making a list() request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.forwardingRule + * Name of the ForwardingRule resource to return. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.ForwardingRule | ForwardingRule}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/global_forwarding_rules.get.js + * region_tag:compute_v1_generated_GlobalForwardingRules_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetGlobalForwardingRuleRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IForwardingRule, + protos.google.cloud.compute.v1.IGetGlobalForwardingRuleRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetGlobalForwardingRuleRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IForwardingRule, + protos.google.cloud.compute.v1.IGetGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetGlobalForwardingRuleRequest, + callback: Callback< + protos.google.cloud.compute.v1.IForwardingRule, + protos.google.cloud.compute.v1.IGetGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetGlobalForwardingRuleRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IForwardingRule, + protos.google.cloud.compute.v1.IGetGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IForwardingRule, + protos.google.cloud.compute.v1.IGetGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IForwardingRule, + protos.google.cloud.compute.v1.IGetGlobalForwardingRuleRequest|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({ + 'project': request.project ?? '', + 'forwarding_rule': request.forwardingRule ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a GlobalForwardingRule resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.ForwardingRule} request.forwardingRuleResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/global_forwarding_rules.insert.js + * region_tag:compute_v1_generated_GlobalForwardingRules_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertGlobalForwardingRuleRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertGlobalForwardingRuleRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertGlobalForwardingRuleRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertGlobalForwardingRuleRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. Currently, you can only patch the network_tier field. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.forwardingRule + * Name of the ForwardingRule resource to patch. + * @param {google.cloud.compute.v1.ForwardingRule} request.forwardingRuleResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/global_forwarding_rules.patch.js + * region_tag:compute_v1_generated_GlobalForwardingRules_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchGlobalForwardingRuleRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchGlobalForwardingRuleRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchGlobalForwardingRuleRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchGlobalForwardingRuleRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'forwarding_rule': request.forwardingRule ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the labels on the specified resource. To learn more about labels, read the Labeling resources documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalSetLabelsRequest} request.globalSetLabelsRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/global_forwarding_rules.set_labels.js + * region_tag:compute_v1_generated_GlobalForwardingRules_SetLabels_async + */ + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsGlobalForwardingRuleRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsGlobalForwardingRuleRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsGlobalForwardingRuleRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsGlobalForwardingRuleRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setLabels(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes target URL for the GlobalForwardingRule resource. The new target should be of the same type as the old target. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.forwardingRule + * Name of the ForwardingRule resource in which target is to be set. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetReference} request.targetReferenceResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/global_forwarding_rules.set_target.js + * region_tag:compute_v1_generated_GlobalForwardingRules_SetTarget_async + */ + setTarget( + request?: protos.google.cloud.compute.v1.ISetTargetGlobalForwardingRuleRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setTarget( + request: protos.google.cloud.compute.v1.ISetTargetGlobalForwardingRuleRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTargetGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + setTarget( + request: protos.google.cloud.compute.v1.ISetTargetGlobalForwardingRuleRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTargetGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): void; + setTarget( + request?: protos.google.cloud.compute.v1.ISetTargetGlobalForwardingRuleRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTargetGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTargetGlobalForwardingRuleRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'forwarding_rule': request.forwardingRule ?? '', + }); + this.initialize(); + return this.innerApiCalls.setTarget(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves a list of GlobalForwardingRule resources available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.ForwardingRule | ForwardingRule}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListGlobalForwardingRulesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IForwardingRule[], + protos.google.cloud.compute.v1.IListGlobalForwardingRulesRequest|null, + protos.google.cloud.compute.v1.IForwardingRuleList + ]>; + list( + request: protos.google.cloud.compute.v1.IListGlobalForwardingRulesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalForwardingRulesRequest, + protos.google.cloud.compute.v1.IForwardingRuleList|null|undefined, + protos.google.cloud.compute.v1.IForwardingRule>): void; + list( + request: protos.google.cloud.compute.v1.IListGlobalForwardingRulesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalForwardingRulesRequest, + protos.google.cloud.compute.v1.IForwardingRuleList|null|undefined, + protos.google.cloud.compute.v1.IForwardingRule>): void; + list( + request?: protos.google.cloud.compute.v1.IListGlobalForwardingRulesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalForwardingRulesRequest, + protos.google.cloud.compute.v1.IForwardingRuleList|null|undefined, + protos.google.cloud.compute.v1.IForwardingRule>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalForwardingRulesRequest, + protos.google.cloud.compute.v1.IForwardingRuleList|null|undefined, + protos.google.cloud.compute.v1.IForwardingRule>): + Promise<[ + protos.google.cloud.compute.v1.IForwardingRule[], + protos.google.cloud.compute.v1.IListGlobalForwardingRulesRequest|null, + protos.google.cloud.compute.v1.IForwardingRuleList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.ForwardingRule | ForwardingRule} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListGlobalForwardingRulesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.ForwardingRule | ForwardingRule}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/global_forwarding_rules.list.js + * region_tag:compute_v1_generated_GlobalForwardingRules_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListGlobalForwardingRulesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.globalForwardingRulesStub && !this._terminated) { + return this.globalForwardingRulesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_forwarding_rules_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_forwarding_rules_client_config.json new file mode 100644 index 00000000000..e69560c0511 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_forwarding_rules_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.compute.v1.GlobalForwardingRules": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetLabels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetTarget": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_forwarding_rules_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_forwarding_rules_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_forwarding_rules_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_network_endpoint_groups_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_network_endpoint_groups_client.ts new file mode 100644 index 00000000000..a7eab7f8bbe --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_network_endpoint_groups_client.ts @@ -0,0 +1,1139 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/global_network_endpoint_groups_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './global_network_endpoint_groups_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The GlobalNetworkEndpointGroups API. + * @class + * @memberof v1 + */ +export class GlobalNetworkEndpointGroupsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + globalNetworkEndpointGroupsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of GlobalNetworkEndpointGroupsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new GlobalNetworkEndpointGroupsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof GlobalNetworkEndpointGroupsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + listNetworkEndpoints: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.GlobalNetworkEndpointGroups', 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.globalNetworkEndpointGroupsStub) { + return this.globalNetworkEndpointGroupsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.GlobalNetworkEndpointGroups. + this.globalNetworkEndpointGroupsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.GlobalNetworkEndpointGroups') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.GlobalNetworkEndpointGroups, + 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 globalNetworkEndpointGroupsStubMethods = + ['attachNetworkEndpoints', 'delete', 'detachNetworkEndpoints', 'get', 'insert', 'list', 'listNetworkEndpoints']; + for (const methodName of globalNetworkEndpointGroupsStubMethods) { + const callPromise = this.globalNetworkEndpointGroupsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.globalNetworkEndpointGroupsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Attach a network endpoint to the specified network endpoint group. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalNetworkEndpointGroupsAttachEndpointsRequest} request.globalNetworkEndpointGroupsAttachEndpointsRequestResource + * The body resource for this request + * @param {string} request.networkEndpointGroup + * The name of the network endpoint group where you are attaching network endpoints to. It should comply with RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/global_network_endpoint_groups.attach_network_endpoints.js + * region_tag:compute_v1_generated_GlobalNetworkEndpointGroups_AttachNetworkEndpoints_async + */ + attachNetworkEndpoints( + request?: protos.google.cloud.compute.v1.IAttachNetworkEndpointsGlobalNetworkEndpointGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + attachNetworkEndpoints( + request: protos.google.cloud.compute.v1.IAttachNetworkEndpointsGlobalNetworkEndpointGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAttachNetworkEndpointsGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + attachNetworkEndpoints( + request: protos.google.cloud.compute.v1.IAttachNetworkEndpointsGlobalNetworkEndpointGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAttachNetworkEndpointsGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + attachNetworkEndpoints( + request?: protos.google.cloud.compute.v1.IAttachNetworkEndpointsGlobalNetworkEndpointGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAttachNetworkEndpointsGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAttachNetworkEndpointsGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'network_endpoint_group': request.networkEndpointGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.attachNetworkEndpoints(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified network endpoint group.Note that the NEG cannot be deleted if there are backend services referencing it. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.networkEndpointGroup + * The name of the network endpoint group to delete. It should comply with RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/global_network_endpoint_groups.delete.js + * region_tag:compute_v1_generated_GlobalNetworkEndpointGroups_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteGlobalNetworkEndpointGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteGlobalNetworkEndpointGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteGlobalNetworkEndpointGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteGlobalNetworkEndpointGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'network_endpoint_group': request.networkEndpointGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Detach the network endpoint from the specified network endpoint group. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalNetworkEndpointGroupsDetachEndpointsRequest} request.globalNetworkEndpointGroupsDetachEndpointsRequestResource + * The body resource for this request + * @param {string} request.networkEndpointGroup + * The name of the network endpoint group where you are removing network endpoints. It should comply with RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/global_network_endpoint_groups.detach_network_endpoints.js + * region_tag:compute_v1_generated_GlobalNetworkEndpointGroups_DetachNetworkEndpoints_async + */ + detachNetworkEndpoints( + request?: protos.google.cloud.compute.v1.IDetachNetworkEndpointsGlobalNetworkEndpointGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + detachNetworkEndpoints( + request: protos.google.cloud.compute.v1.IDetachNetworkEndpointsGlobalNetworkEndpointGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDetachNetworkEndpointsGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + detachNetworkEndpoints( + request: protos.google.cloud.compute.v1.IDetachNetworkEndpointsGlobalNetworkEndpointGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDetachNetworkEndpointsGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + detachNetworkEndpoints( + request?: protos.google.cloud.compute.v1.IDetachNetworkEndpointsGlobalNetworkEndpointGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDetachNetworkEndpointsGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDetachNetworkEndpointsGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'network_endpoint_group': request.networkEndpointGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.detachNetworkEndpoints(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified network endpoint group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.networkEndpointGroup + * The name of the network endpoint group. It should comply with RFC1035. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.NetworkEndpointGroup | NetworkEndpointGroup}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/global_network_endpoint_groups.get.js + * region_tag:compute_v1_generated_GlobalNetworkEndpointGroups_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetGlobalNetworkEndpointGroupRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetGlobalNetworkEndpointGroupRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetGlobalNetworkEndpointGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetGlobalNetworkEndpointGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetGlobalNetworkEndpointGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetGlobalNetworkEndpointGroupRequest|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({ + 'project': request.project ?? '', + 'network_endpoint_group': request.networkEndpointGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a network endpoint group in the specified project using the parameters that are included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.NetworkEndpointGroup} request.networkEndpointGroupResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/global_network_endpoint_groups.insert.js + * region_tag:compute_v1_generated_GlobalNetworkEndpointGroups_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertGlobalNetworkEndpointGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertGlobalNetworkEndpointGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertGlobalNetworkEndpointGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertGlobalNetworkEndpointGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertGlobalNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves the list of network endpoint groups that are located in the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.NetworkEndpointGroup | NetworkEndpointGroup}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListGlobalNetworkEndpointGroupsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INetworkEndpointGroup[], + protos.google.cloud.compute.v1.IListGlobalNetworkEndpointGroupsRequest|null, + protos.google.cloud.compute.v1.INetworkEndpointGroupList + ]>; + list( + request: protos.google.cloud.compute.v1.IListGlobalNetworkEndpointGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupList|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointGroup>): void; + list( + request: protos.google.cloud.compute.v1.IListGlobalNetworkEndpointGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupList|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointGroup>): void; + list( + request?: protos.google.cloud.compute.v1.IListGlobalNetworkEndpointGroupsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupList|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointGroup>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupList|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointGroup>): + Promise<[ + protos.google.cloud.compute.v1.INetworkEndpointGroup[], + protos.google.cloud.compute.v1.IListGlobalNetworkEndpointGroupsRequest|null, + protos.google.cloud.compute.v1.INetworkEndpointGroupList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.NetworkEndpointGroup | NetworkEndpointGroup} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListGlobalNetworkEndpointGroupsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.NetworkEndpointGroup | NetworkEndpointGroup}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/global_network_endpoint_groups.list.js + * region_tag:compute_v1_generated_GlobalNetworkEndpointGroups_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListGlobalNetworkEndpointGroupsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the network endpoints in the specified network endpoint group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.networkEndpointGroup + * The name of the network endpoint group from which you want to generate a list of included network endpoints. It should comply with RFC1035. + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.NetworkEndpointWithHealthStatus | NetworkEndpointWithHealthStatus}. + * 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 `listNetworkEndpointsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listNetworkEndpoints( + request?: protos.google.cloud.compute.v1.IListNetworkEndpointsGlobalNetworkEndpointGroupsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus[], + protos.google.cloud.compute.v1.IListNetworkEndpointsGlobalNetworkEndpointGroupsRequest|null, + protos.google.cloud.compute.v1.INetworkEndpointGroupsListNetworkEndpoints + ]>; + listNetworkEndpoints( + request: protos.google.cloud.compute.v1.IListNetworkEndpointsGlobalNetworkEndpointGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkEndpointsGlobalNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupsListNetworkEndpoints|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus>): void; + listNetworkEndpoints( + request: protos.google.cloud.compute.v1.IListNetworkEndpointsGlobalNetworkEndpointGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkEndpointsGlobalNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupsListNetworkEndpoints|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus>): void; + listNetworkEndpoints( + request?: protos.google.cloud.compute.v1.IListNetworkEndpointsGlobalNetworkEndpointGroupsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkEndpointsGlobalNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupsListNetworkEndpoints|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkEndpointsGlobalNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupsListNetworkEndpoints|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus>): + Promise<[ + protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus[], + protos.google.cloud.compute.v1.IListNetworkEndpointsGlobalNetworkEndpointGroupsRequest|null, + protos.google.cloud.compute.v1.INetworkEndpointGroupsListNetworkEndpoints + ]>|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({ + 'project': request.project ?? '', + 'network_endpoint_group': request.networkEndpointGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.listNetworkEndpoints(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.networkEndpointGroup + * The name of the network endpoint group from which you want to generate a list of included network endpoints. It should comply with RFC1035. + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.NetworkEndpointWithHealthStatus | NetworkEndpointWithHealthStatus} 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 `listNetworkEndpointsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listNetworkEndpointsStream( + request?: protos.google.cloud.compute.v1.IListNetworkEndpointsGlobalNetworkEndpointGroupsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'network_endpoint_group': request.networkEndpointGroup ?? '', + }); + const defaultCallSettings = this._defaults['listNetworkEndpoints']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listNetworkEndpoints.createStream( + this.innerApiCalls.listNetworkEndpoints as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listNetworkEndpoints`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.networkEndpointGroup + * The name of the network endpoint group from which you want to generate a list of included network endpoints. It should comply with RFC1035. + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.NetworkEndpointWithHealthStatus | NetworkEndpointWithHealthStatus}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/global_network_endpoint_groups.list_network_endpoints.js + * region_tag:compute_v1_generated_GlobalNetworkEndpointGroups_ListNetworkEndpoints_async + */ + listNetworkEndpointsAsync( + request?: protos.google.cloud.compute.v1.IListNetworkEndpointsGlobalNetworkEndpointGroupsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'network_endpoint_group': request.networkEndpointGroup ?? '', + }); + const defaultCallSettings = this._defaults['listNetworkEndpoints']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listNetworkEndpoints.asyncIterate( + this.innerApiCalls['listNetworkEndpoints'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.globalNetworkEndpointGroupsStub && !this._terminated) { + return this.globalNetworkEndpointGroupsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_network_endpoint_groups_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_network_endpoint_groups_client_config.json new file mode 100644 index 00000000000..e353418e07d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_network_endpoint_groups_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.compute.v1.GlobalNetworkEndpointGroups": { + "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": { + "AttachNetworkEndpoints": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DetachNetworkEndpoints": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListNetworkEndpoints": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_network_endpoint_groups_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_network_endpoint_groups_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_network_endpoint_groups_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_operations_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_operations_client.ts new file mode 100644 index 00000000000..95705df938b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_operations_client.ts @@ -0,0 +1,788 @@ +// Copyright 2023 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/global_operations_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './global_operations_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The GlobalOperations API. + * @class + * @memberof v1 + */ +export class GlobalOperationsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + globalOperationsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of GlobalOperationsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new GlobalOperationsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof GlobalOperationsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.GlobalOperations', 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.globalOperationsStub) { + return this.globalOperationsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.GlobalOperations. + this.globalOperationsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.GlobalOperations') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.GlobalOperations, + 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 globalOperationsStubMethods = + ['aggregatedList', 'delete', 'get', 'list', 'wait']; + for (const methodName of globalOperationsStubMethods) { + const callPromise = this.globalOperationsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.globalOperationsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified Operations resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Name of the Operations resource to delete. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.DeleteGlobalOperationResponse | DeleteGlobalOperationResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/global_operations.delete.js + * region_tag:compute_v1_generated_GlobalOperations_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteGlobalOperationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IDeleteGlobalOperationResponse, + protos.google.cloud.compute.v1.IDeleteGlobalOperationRequest|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteGlobalOperationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IDeleteGlobalOperationResponse, + protos.google.cloud.compute.v1.IDeleteGlobalOperationRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteGlobalOperationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IDeleteGlobalOperationResponse, + protos.google.cloud.compute.v1.IDeleteGlobalOperationRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteGlobalOperationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IDeleteGlobalOperationResponse, + protos.google.cloud.compute.v1.IDeleteGlobalOperationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IDeleteGlobalOperationResponse, + protos.google.cloud.compute.v1.IDeleteGlobalOperationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IDeleteGlobalOperationResponse, + protos.google.cloud.compute.v1.IDeleteGlobalOperationRequest|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({ + 'project': request.project ?? '', + 'operation': request.operation ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback); + } +/** + * Retrieves the specified Operations resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Name of the Operations resource to return. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.Operation | Operation}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/global_operations.get.js + * region_tag:compute_v1_generated_GlobalOperations_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetGlobalOperationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetGlobalOperationRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetGlobalOperationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetGlobalOperationRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetGlobalOperationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetGlobalOperationRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetGlobalOperationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetGlobalOperationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetGlobalOperationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetGlobalOperationRequest|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({ + 'project': request.project ?? '', + 'operation': request.operation ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the `GET` method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Name of the Operations resource to return. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.Operation | Operation}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/global_operations.wait.js + * region_tag:compute_v1_generated_GlobalOperations_Wait_async + */ + wait( + request?: protos.google.cloud.compute.v1.IWaitGlobalOperationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitGlobalOperationRequest|undefined, {}|undefined + ]>; + wait( + request: protos.google.cloud.compute.v1.IWaitGlobalOperationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitGlobalOperationRequest|null|undefined, + {}|null|undefined>): void; + wait( + request: protos.google.cloud.compute.v1.IWaitGlobalOperationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitGlobalOperationRequest|null|undefined, + {}|null|undefined>): void; + wait( + request?: protos.google.cloud.compute.v1.IWaitGlobalOperationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitGlobalOperationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitGlobalOperationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitGlobalOperationRequest|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({ + 'project': request.project ?? '', + 'operation': request.operation ?? '', + }); + this.initialize(); + return this.innerApiCalls.wait(request, options, callback); + } + + +/** + * Retrieves an aggregated list of all operations. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.OperationsScopedList | OperationsScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/global_operations.aggregated_list.js + * region_tag:compute_v1_generated_GlobalOperations_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListGlobalOperationsRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IOperationsScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IOperationsScopedList]>; + } + /** + * Retrieves a list of Operation resources contained within the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Operation | Operation}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListGlobalOperationsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IOperation[], + protos.google.cloud.compute.v1.IListGlobalOperationsRequest|null, + protos.google.cloud.compute.v1.IOperationList + ]>; + list( + request: protos.google.cloud.compute.v1.IListGlobalOperationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalOperationsRequest, + protos.google.cloud.compute.v1.IOperationList|null|undefined, + protos.google.cloud.compute.v1.IOperation>): void; + list( + request: protos.google.cloud.compute.v1.IListGlobalOperationsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalOperationsRequest, + protos.google.cloud.compute.v1.IOperationList|null|undefined, + protos.google.cloud.compute.v1.IOperation>): void; + list( + request?: protos.google.cloud.compute.v1.IListGlobalOperationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalOperationsRequest, + protos.google.cloud.compute.v1.IOperationList|null|undefined, + protos.google.cloud.compute.v1.IOperation>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalOperationsRequest, + protos.google.cloud.compute.v1.IOperationList|null|undefined, + protos.google.cloud.compute.v1.IOperation>): + Promise<[ + protos.google.cloud.compute.v1.IOperation[], + protos.google.cloud.compute.v1.IListGlobalOperationsRequest|null, + protos.google.cloud.compute.v1.IOperationList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Operation | Operation} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListGlobalOperationsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Operation | Operation}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/global_operations.list.js + * region_tag:compute_v1_generated_GlobalOperations_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListGlobalOperationsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.globalOperationsStub && !this._terminated) { + return this.globalOperationsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_operations_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_operations_client_config.json new file mode 100644 index 00000000000..a732080c9ab --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_operations_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.compute.v1.GlobalOperations": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Wait": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_operations_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_operations_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_operations_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_organization_operations_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_organization_operations_client.ts new file mode 100644 index 00000000000..a8909aec910 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_organization_operations_client.ts @@ -0,0 +1,639 @@ +// Copyright 2023 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/global_organization_operations_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './global_organization_operations_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The GlobalOrganizationOperations API. + * @class + * @memberof v1 + */ +export class GlobalOrganizationOperationsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + globalOrganizationOperationsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of GlobalOrganizationOperationsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new GlobalOrganizationOperationsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof GlobalOrganizationOperationsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.GlobalOrganizationOperations', 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.globalOrganizationOperationsStub) { + return this.globalOrganizationOperationsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.GlobalOrganizationOperations. + this.globalOrganizationOperationsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.GlobalOrganizationOperations') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.GlobalOrganizationOperations, + 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 globalOrganizationOperationsStubMethods = + ['delete', 'get', 'list']; + for (const methodName of globalOrganizationOperationsStubMethods) { + const callPromise = this.globalOrganizationOperationsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.globalOrganizationOperationsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified Operations resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Name of the Operations resource to delete. + * @param {string} request.parentId + * Parent ID for this request. + * @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.compute.v1.DeleteGlobalOrganizationOperationResponse | DeleteGlobalOrganizationOperationResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/global_organization_operations.delete.js + * region_tag:compute_v1_generated_GlobalOrganizationOperations_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationResponse, + protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationRequest|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationResponse, + protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationResponse, + protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationResponse, + protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationResponse, + protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationResponse, + protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationRequest|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({ + 'operation': request.operation ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback); + } +/** + * Retrieves the specified Operations resource. Gets a list of operations by making a `list()` request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Name of the Operations resource to return. + * @param {string} request.parentId + * Parent ID for this request. + * @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.compute.v1.Operation | Operation}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/global_organization_operations.get.js + * region_tag:compute_v1_generated_GlobalOrganizationOperations_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetGlobalOrganizationOperationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetGlobalOrganizationOperationRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetGlobalOrganizationOperationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetGlobalOrganizationOperationRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetGlobalOrganizationOperationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetGlobalOrganizationOperationRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetGlobalOrganizationOperationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetGlobalOrganizationOperationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetGlobalOrganizationOperationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetGlobalOrganizationOperationRequest|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({ + 'operation': request.operation ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } + + /** + * Retrieves a list of Operation resources contained within the specified organization. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.parentId + * Parent ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Operation | Operation}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListGlobalOrganizationOperationsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IOperation[], + protos.google.cloud.compute.v1.IListGlobalOrganizationOperationsRequest|null, + protos.google.cloud.compute.v1.IOperationList + ]>; + list( + request: protos.google.cloud.compute.v1.IListGlobalOrganizationOperationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalOrganizationOperationsRequest, + protos.google.cloud.compute.v1.IOperationList|null|undefined, + protos.google.cloud.compute.v1.IOperation>): void; + list( + request: protos.google.cloud.compute.v1.IListGlobalOrganizationOperationsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalOrganizationOperationsRequest, + protos.google.cloud.compute.v1.IOperationList|null|undefined, + protos.google.cloud.compute.v1.IOperation>): void; + list( + request?: protos.google.cloud.compute.v1.IListGlobalOrganizationOperationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalOrganizationOperationsRequest, + protos.google.cloud.compute.v1.IOperationList|null|undefined, + protos.google.cloud.compute.v1.IOperation>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalOrganizationOperationsRequest, + protos.google.cloud.compute.v1.IOperationList|null|undefined, + protos.google.cloud.compute.v1.IOperation>): + Promise<[ + protos.google.cloud.compute.v1.IOperation[], + protos.google.cloud.compute.v1.IListGlobalOrganizationOperationsRequest|null, + protos.google.cloud.compute.v1.IOperationList + ]>|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 || {}; + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.parentId + * Parent ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Operation | Operation} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListGlobalOrganizationOperationsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.parentId + * Parent ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Operation | Operation}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/global_organization_operations.list.js + * region_tag:compute_v1_generated_GlobalOrganizationOperations_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListGlobalOrganizationOperationsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.globalOrganizationOperationsStub && !this._terminated) { + return this.globalOrganizationOperationsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_organization_operations_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_organization_operations_client_config.json new file mode 100644 index 00000000000..1a261cc2ca9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_organization_operations_client_config.json @@ -0,0 +1,38 @@ +{ + "interfaces": { + "google.cloud.compute.v1.GlobalOrganizationOperations": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_organization_operations_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_organization_operations_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_organization_operations_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_public_delegated_prefixes_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_public_delegated_prefixes_client.ts new file mode 100644 index 00000000000..aa6e74ba27f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_public_delegated_prefixes_client.ts @@ -0,0 +1,847 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/global_public_delegated_prefixes_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './global_public_delegated_prefixes_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The GlobalPublicDelegatedPrefixes API. + * @class + * @memberof v1 + */ +export class GlobalPublicDelegatedPrefixesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + globalPublicDelegatedPrefixesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of GlobalPublicDelegatedPrefixesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new GlobalPublicDelegatedPrefixesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof GlobalPublicDelegatedPrefixesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.GlobalPublicDelegatedPrefixes', 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.globalPublicDelegatedPrefixesStub) { + return this.globalPublicDelegatedPrefixesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.GlobalPublicDelegatedPrefixes. + this.globalPublicDelegatedPrefixesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.GlobalPublicDelegatedPrefixes') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.GlobalPublicDelegatedPrefixes, + 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 globalPublicDelegatedPrefixesStubMethods = + ['delete', 'get', 'insert', 'list', 'patch']; + for (const methodName of globalPublicDelegatedPrefixesStubMethods) { + const callPromise = this.globalPublicDelegatedPrefixesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.globalPublicDelegatedPrefixesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified global PublicDelegatedPrefix. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.publicDelegatedPrefix + * Name of the PublicDelegatedPrefix resource to delete. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/global_public_delegated_prefixes.delete.js + * region_tag:compute_v1_generated_GlobalPublicDelegatedPrefixes_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteGlobalPublicDelegatedPrefixeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteGlobalPublicDelegatedPrefixeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteGlobalPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteGlobalPublicDelegatedPrefixeRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteGlobalPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteGlobalPublicDelegatedPrefixeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteGlobalPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteGlobalPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'public_delegated_prefix': request.publicDelegatedPrefix ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified global PublicDelegatedPrefix resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.publicDelegatedPrefix + * Name of the PublicDelegatedPrefix resource to return. + * @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.compute.v1.PublicDelegatedPrefix | PublicDelegatedPrefix}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/global_public_delegated_prefixes.get.js + * region_tag:compute_v1_generated_GlobalPublicDelegatedPrefixes_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetGlobalPublicDelegatedPrefixeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPublicDelegatedPrefix, + protos.google.cloud.compute.v1.IGetGlobalPublicDelegatedPrefixeRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetGlobalPublicDelegatedPrefixeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPublicDelegatedPrefix, + protos.google.cloud.compute.v1.IGetGlobalPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetGlobalPublicDelegatedPrefixeRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPublicDelegatedPrefix, + protos.google.cloud.compute.v1.IGetGlobalPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetGlobalPublicDelegatedPrefixeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPublicDelegatedPrefix, + protos.google.cloud.compute.v1.IGetGlobalPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPublicDelegatedPrefix, + protos.google.cloud.compute.v1.IGetGlobalPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPublicDelegatedPrefix, + protos.google.cloud.compute.v1.IGetGlobalPublicDelegatedPrefixeRequest|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({ + 'project': request.project ?? '', + 'public_delegated_prefix': request.publicDelegatedPrefix ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a global PublicDelegatedPrefix in the specified project using the parameters that are included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {google.cloud.compute.v1.PublicDelegatedPrefix} request.publicDelegatedPrefixResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/global_public_delegated_prefixes.insert.js + * region_tag:compute_v1_generated_GlobalPublicDelegatedPrefixes_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertGlobalPublicDelegatedPrefixeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertGlobalPublicDelegatedPrefixeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertGlobalPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertGlobalPublicDelegatedPrefixeRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertGlobalPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertGlobalPublicDelegatedPrefixeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertGlobalPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertGlobalPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified global PublicDelegatedPrefix resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.publicDelegatedPrefix + * Name of the PublicDelegatedPrefix resource to patch. + * @param {google.cloud.compute.v1.PublicDelegatedPrefix} request.publicDelegatedPrefixResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/global_public_delegated_prefixes.patch.js + * region_tag:compute_v1_generated_GlobalPublicDelegatedPrefixes_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchGlobalPublicDelegatedPrefixeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchGlobalPublicDelegatedPrefixeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchGlobalPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchGlobalPublicDelegatedPrefixeRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchGlobalPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchGlobalPublicDelegatedPrefixeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchGlobalPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchGlobalPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'public_delegated_prefix': request.publicDelegatedPrefix ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Lists the global PublicDelegatedPrefixes for a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.PublicDelegatedPrefix | PublicDelegatedPrefix}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListGlobalPublicDelegatedPrefixesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPublicDelegatedPrefix[], + protos.google.cloud.compute.v1.IListGlobalPublicDelegatedPrefixesRequest|null, + protos.google.cloud.compute.v1.IPublicDelegatedPrefixList + ]>; + list( + request: protos.google.cloud.compute.v1.IListGlobalPublicDelegatedPrefixesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalPublicDelegatedPrefixesRequest, + protos.google.cloud.compute.v1.IPublicDelegatedPrefixList|null|undefined, + protos.google.cloud.compute.v1.IPublicDelegatedPrefix>): void; + list( + request: protos.google.cloud.compute.v1.IListGlobalPublicDelegatedPrefixesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalPublicDelegatedPrefixesRequest, + protos.google.cloud.compute.v1.IPublicDelegatedPrefixList|null|undefined, + protos.google.cloud.compute.v1.IPublicDelegatedPrefix>): void; + list( + request?: protos.google.cloud.compute.v1.IListGlobalPublicDelegatedPrefixesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalPublicDelegatedPrefixesRequest, + protos.google.cloud.compute.v1.IPublicDelegatedPrefixList|null|undefined, + protos.google.cloud.compute.v1.IPublicDelegatedPrefix>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListGlobalPublicDelegatedPrefixesRequest, + protos.google.cloud.compute.v1.IPublicDelegatedPrefixList|null|undefined, + protos.google.cloud.compute.v1.IPublicDelegatedPrefix>): + Promise<[ + protos.google.cloud.compute.v1.IPublicDelegatedPrefix[], + protos.google.cloud.compute.v1.IListGlobalPublicDelegatedPrefixesRequest|null, + protos.google.cloud.compute.v1.IPublicDelegatedPrefixList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.PublicDelegatedPrefix | PublicDelegatedPrefix} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListGlobalPublicDelegatedPrefixesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.PublicDelegatedPrefix | PublicDelegatedPrefix}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/global_public_delegated_prefixes.list.js + * region_tag:compute_v1_generated_GlobalPublicDelegatedPrefixes_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListGlobalPublicDelegatedPrefixesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.globalPublicDelegatedPrefixesStub && !this._terminated) { + return this.globalPublicDelegatedPrefixesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_public_delegated_prefixes_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_public_delegated_prefixes_client_config.json new file mode 100644 index 00000000000..7304040dc41 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_public_delegated_prefixes_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/global_public_delegated_prefixes_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_public_delegated_prefixes_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/global_public_delegated_prefixes_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/health_checks_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/health_checks_client.ts new file mode 100644 index 00000000000..1dbf5339b89 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/health_checks_client.ts @@ -0,0 +1,995 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/health_checks_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './health_checks_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The HealthChecks API. + * @class + * @memberof v1 + */ +export class HealthChecksClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + healthChecksStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of HealthChecksClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new HealthChecksClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof HealthChecksClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.HealthChecks', 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.healthChecksStub) { + return this.healthChecksStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.HealthChecks. + this.healthChecksStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.HealthChecks') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.HealthChecks, + 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 healthChecksStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'list', 'patch', 'update']; + for (const methodName of healthChecksStubMethods) { + const callPromise = this.healthChecksStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.healthChecksStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified HealthCheck resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.healthCheck + * Name of the HealthCheck resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/health_checks.delete.js + * region_tag:compute_v1_generated_HealthChecks_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteHealthCheckRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteHealthCheckRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteHealthCheckRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteHealthCheckRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteHealthCheckRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteHealthCheckRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'health_check': request.healthCheck ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified HealthCheck resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.healthCheck + * Name of the HealthCheck resource to return. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.HealthCheck | HealthCheck}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/health_checks.get.js + * region_tag:compute_v1_generated_HealthChecks_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetHealthCheckRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IHealthCheck, + protos.google.cloud.compute.v1.IGetHealthCheckRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetHealthCheckRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IHealthCheck, + protos.google.cloud.compute.v1.IGetHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetHealthCheckRequest, + callback: Callback< + protos.google.cloud.compute.v1.IHealthCheck, + protos.google.cloud.compute.v1.IGetHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetHealthCheckRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IHealthCheck, + protos.google.cloud.compute.v1.IGetHealthCheckRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IHealthCheck, + protos.google.cloud.compute.v1.IGetHealthCheckRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IHealthCheck, + protos.google.cloud.compute.v1.IGetHealthCheckRequest|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({ + 'project': request.project ?? '', + 'health_check': request.healthCheck ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a HealthCheck resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.HealthCheck} request.healthCheckResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/health_checks.insert.js + * region_tag:compute_v1_generated_HealthChecks_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertHealthCheckRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertHealthCheckRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertHealthCheckRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertHealthCheckRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertHealthCheckRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertHealthCheckRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates a HealthCheck resource in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.healthCheck + * Name of the HealthCheck resource to patch. + * @param {google.cloud.compute.v1.HealthCheck} request.healthCheckResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/health_checks.patch.js + * region_tag:compute_v1_generated_HealthChecks_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchHealthCheckRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchHealthCheckRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchHealthCheckRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchHealthCheckRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchHealthCheckRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchHealthCheckRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'health_check': request.healthCheck ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates a HealthCheck resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.healthCheck + * Name of the HealthCheck resource to update. + * @param {google.cloud.compute.v1.HealthCheck} request.healthCheckResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/health_checks.update.js + * region_tag:compute_v1_generated_HealthChecks_Update_async + */ + update( + request?: protos.google.cloud.compute.v1.IUpdateHealthCheckRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + update( + request: protos.google.cloud.compute.v1.IUpdateHealthCheckRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + update( + request: protos.google.cloud.compute.v1.IUpdateHealthCheckRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + update( + request?: protos.google.cloud.compute.v1.IUpdateHealthCheckRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateHealthCheckRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateHealthCheckRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'health_check': request.healthCheck ?? '', + }); + this.initialize(); + return this.innerApiCalls.update(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves the list of all HealthCheck resources, regional and global, available to the specified project. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Name of the project scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.HealthChecksScopedList | HealthChecksScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/health_checks.aggregated_list.js + * region_tag:compute_v1_generated_HealthChecks_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListHealthChecksRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IHealthChecksScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IHealthChecksScopedList]>; + } + /** + * Retrieves the list of HealthCheck resources available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.HealthCheck | HealthCheck}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListHealthChecksRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IHealthCheck[], + protos.google.cloud.compute.v1.IListHealthChecksRequest|null, + protos.google.cloud.compute.v1.IHealthCheckList + ]>; + list( + request: protos.google.cloud.compute.v1.IListHealthChecksRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListHealthChecksRequest, + protos.google.cloud.compute.v1.IHealthCheckList|null|undefined, + protos.google.cloud.compute.v1.IHealthCheck>): void; + list( + request: protos.google.cloud.compute.v1.IListHealthChecksRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListHealthChecksRequest, + protos.google.cloud.compute.v1.IHealthCheckList|null|undefined, + protos.google.cloud.compute.v1.IHealthCheck>): void; + list( + request?: protos.google.cloud.compute.v1.IListHealthChecksRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListHealthChecksRequest, + protos.google.cloud.compute.v1.IHealthCheckList|null|undefined, + protos.google.cloud.compute.v1.IHealthCheck>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListHealthChecksRequest, + protos.google.cloud.compute.v1.IHealthCheckList|null|undefined, + protos.google.cloud.compute.v1.IHealthCheck>): + Promise<[ + protos.google.cloud.compute.v1.IHealthCheck[], + protos.google.cloud.compute.v1.IListHealthChecksRequest|null, + protos.google.cloud.compute.v1.IHealthCheckList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.HealthCheck | HealthCheck} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListHealthChecksRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.HealthCheck | HealthCheck}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/health_checks.list.js + * region_tag:compute_v1_generated_HealthChecks_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListHealthChecksRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.healthChecksStub && !this._terminated) { + return this.healthChecksStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/health_checks_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/health_checks_client_config.json new file mode 100644 index 00000000000..b84bd9760a0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/health_checks_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.compute.v1.HealthChecks": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Update": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/health_checks_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/health_checks_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/health_checks_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/image_family_views_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/image_family_views_client.ts new file mode 100644 index 00000000000..0658a50557f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/image_family_views_client.ts @@ -0,0 +1,386 @@ +// Copyright 2023 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} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/image_family_views_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_family_views_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The ImageFamilyViews API. + * @class + * @memberof v1 + */ +export class ImageFamilyViewsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + imageFamilyViewsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageFamilyViewsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ImageFamilyViewsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ImageFamilyViewsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.ImageFamilyViews', 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.imageFamilyViewsStub) { + return this.imageFamilyViewsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.ImageFamilyViews. + this.imageFamilyViewsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.ImageFamilyViews') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.ImageFamilyViews, + 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 imageFamilyViewsStubMethods = + ['get']; + for (const methodName of imageFamilyViewsStubMethods) { + const callPromise = this.imageFamilyViewsStub.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 = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.imageFamilyViewsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute.readonly', + 'https://www.googleapis.com/auth/compute', + '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 -- + // ------------------- +/** + * Returns the latest image that is part of an image family, is not deprecated and is rolled out in the specified zone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.family + * Name of the image family to search for. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.ImageFamilyView | ImageFamilyView}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/image_family_views.get.js + * region_tag:compute_v1_generated_ImageFamilyViews_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetImageFamilyViewRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IImageFamilyView, + protos.google.cloud.compute.v1.IGetImageFamilyViewRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetImageFamilyViewRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IImageFamilyView, + protos.google.cloud.compute.v1.IGetImageFamilyViewRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetImageFamilyViewRequest, + callback: Callback< + protos.google.cloud.compute.v1.IImageFamilyView, + protos.google.cloud.compute.v1.IGetImageFamilyViewRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetImageFamilyViewRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IImageFamilyView, + protos.google.cloud.compute.v1.IGetImageFamilyViewRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IImageFamilyView, + protos.google.cloud.compute.v1.IGetImageFamilyViewRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IImageFamilyView, + protos.google.cloud.compute.v1.IGetImageFamilyViewRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'family': request.family ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } + + + /** + * 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.imageFamilyViewsStub && !this._terminated) { + return this.imageFamilyViewsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/image_family_views_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/image_family_views_client_config.json new file mode 100644 index 00000000000..d7d8a84d9fe --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/image_family_views_client_config.json @@ -0,0 +1,30 @@ +{ + "interfaces": { + "google.cloud.compute.v1.ImageFamilyViews": { + "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": { + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/image_family_views_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/image_family_views_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/image_family_views_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/images_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/images_client.ts new file mode 100644 index 00000000000..eebe4529c0c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/images_client.ts @@ -0,0 +1,1329 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/images_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './images_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Images API. + * @class + * @memberof v1 + */ +export class ImagesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + imagesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImagesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ImagesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ImagesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.Images', 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.imagesStub) { + return this.imagesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.Images. + this.imagesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Images') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.Images, + 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 imagesStubMethods = + ['delete', 'deprecate', 'get', 'getFromFamily', 'getIamPolicy', 'insert', 'list', 'patch', 'setIamPolicy', 'setLabels', 'testIamPermissions']; + for (const methodName of imagesStubMethods) { + const callPromise = this.imagesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.imagesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified image. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.image + * Name of the image resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/images.delete.js + * region_tag:compute_v1_generated_Images_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteImageRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteImageRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteImageRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteImageRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'image': request.image ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the deprecation status of an image. If an empty request body is given, clears the deprecation status instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.DeprecationStatus} request.deprecationStatusResource + * The body resource for this request + * @param {string} request.image + * Image name. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/images.deprecate.js + * region_tag:compute_v1_generated_Images_Deprecate_async + */ + deprecate( + request?: protos.google.cloud.compute.v1.IDeprecateImageRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + deprecate( + request: protos.google.cloud.compute.v1.IDeprecateImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeprecateImageRequest|null|undefined, + {}|null|undefined>): void; + deprecate( + request: protos.google.cloud.compute.v1.IDeprecateImageRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeprecateImageRequest|null|undefined, + {}|null|undefined>): void; + deprecate( + request?: protos.google.cloud.compute.v1.IDeprecateImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeprecateImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeprecateImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'image': request.image ?? '', + }); + this.initialize(); + return this.innerApiCalls.deprecate(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified image. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.image + * Name of the image resource to return. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.Image | Image}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/images.get.js + * region_tag:compute_v1_generated_Images_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IImage, + protos.google.cloud.compute.v1.IGetImageRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IImage, + protos.google.cloud.compute.v1.IGetImageRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetImageRequest, + callback: Callback< + protos.google.cloud.compute.v1.IImage, + protos.google.cloud.compute.v1.IGetImageRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IImage, + protos.google.cloud.compute.v1.IGetImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IImage, + protos.google.cloud.compute.v1.IGetImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IImage, + protos.google.cloud.compute.v1.IGetImageRequest|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({ + 'project': request.project ?? '', + 'image': request.image ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Returns the latest image that is part of an image family and is not deprecated. For more information on image families, see Public image families documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.family + * Name of the image family to search for. + * @param {string} request.project + * The image project that the image belongs to. For example, to get a CentOS image, specify centos-cloud as the image project. + * @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.compute.v1.Image | Image}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/images.get_from_family.js + * region_tag:compute_v1_generated_Images_GetFromFamily_async + */ + getFromFamily( + request?: protos.google.cloud.compute.v1.IGetFromFamilyImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IImage, + protos.google.cloud.compute.v1.IGetFromFamilyImageRequest|undefined, {}|undefined + ]>; + getFromFamily( + request: protos.google.cloud.compute.v1.IGetFromFamilyImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IImage, + protos.google.cloud.compute.v1.IGetFromFamilyImageRequest|null|undefined, + {}|null|undefined>): void; + getFromFamily( + request: protos.google.cloud.compute.v1.IGetFromFamilyImageRequest, + callback: Callback< + protos.google.cloud.compute.v1.IImage, + protos.google.cloud.compute.v1.IGetFromFamilyImageRequest|null|undefined, + {}|null|undefined>): void; + getFromFamily( + request?: protos.google.cloud.compute.v1.IGetFromFamilyImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IImage, + protos.google.cloud.compute.v1.IGetFromFamilyImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IImage, + protos.google.cloud.compute.v1.IGetFromFamilyImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IImage, + protos.google.cloud.compute.v1.IGetFromFamilyImageRequest|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({ + 'project': request.project ?? '', + 'family': request.family ?? '', + }); + this.initialize(); + return this.innerApiCalls.getFromFamily(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/images.get_iam_policy.js + * region_tag:compute_v1_generated_Images_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyImageRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyImageRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyImageRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyImageRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyImageRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Creates an image in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {boolean} request.forceCreate + * Force image creation if true. + * @param {google.cloud.compute.v1.Image} request.imageResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/images.insert.js + * region_tag:compute_v1_generated_Images_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertImageRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertImageRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertImageRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertImageRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified image with the data included in the request. Only the following fields can be modified: family, description, deprecation status. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.image + * Name of the image resource to patch. + * @param {google.cloud.compute.v1.Image} request.imageResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/images.patch.js + * region_tag:compute_v1_generated_Images_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchImageRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchImageRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchImageRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchImageRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'image': request.image ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalSetPolicyRequest} request.globalSetPolicyRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/images.set_iam_policy.js + * region_tag:compute_v1_generated_Images_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyImageRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyImageRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyImageRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyImageRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyImageRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Sets the labels on an image. To learn more about labels, read the Labeling Resources documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalSetLabelsRequest} request.globalSetLabelsRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/images.set_labels.js + * region_tag:compute_v1_generated_Images_SetLabels_async + */ + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsImageRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsImageRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsImageRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsImageRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setLabels(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/images.test_iam_permissions.js + * region_tag:compute_v1_generated_Images_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsImageRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsImageRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsImageRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsImageRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsImageRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + /** + * Retrieves the list of custom images available to the specified project. Custom images are images you create that belong to your project. This method does not get any images that belong to other projects, including publicly-available images, like Debian 8. If you want to get a list of publicly-available images, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Image | Image}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IImage[], + protos.google.cloud.compute.v1.IListImagesRequest|null, + protos.google.cloud.compute.v1.IImageList + ]>; + list( + request: protos.google.cloud.compute.v1.IListImagesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListImagesRequest, + protos.google.cloud.compute.v1.IImageList|null|undefined, + protos.google.cloud.compute.v1.IImage>): void; + list( + request: protos.google.cloud.compute.v1.IListImagesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListImagesRequest, + protos.google.cloud.compute.v1.IImageList|null|undefined, + protos.google.cloud.compute.v1.IImage>): void; + list( + request?: protos.google.cloud.compute.v1.IListImagesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListImagesRequest, + protos.google.cloud.compute.v1.IImageList|null|undefined, + protos.google.cloud.compute.v1.IImage>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListImagesRequest, + protos.google.cloud.compute.v1.IImageList|null|undefined, + protos.google.cloud.compute.v1.IImage>): + Promise<[ + protos.google.cloud.compute.v1.IImage[], + protos.google.cloud.compute.v1.IListImagesRequest|null, + protos.google.cloud.compute.v1.IImageList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Image | Image} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListImagesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Image | Image}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/images.list.js + * region_tag:compute_v1_generated_Images_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListImagesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.imagesStub && !this._terminated) { + return this.imagesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/images_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/images_client_config.json new file mode 100644 index 00000000000..fa2e7fe9230 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/images_client_config.json @@ -0,0 +1,70 @@ +{ + "interfaces": { + "google.cloud.compute.v1.Images": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Deprecate": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetFromFamily": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetLabels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/images_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/images_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/images_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/index.ts new file mode 100644 index 00000000000..2c1d8882a27 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/index.ts @@ -0,0 +1,107 @@ +// Copyright 2023 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. ** + +export {AcceleratorTypesClient} from './accelerator_types_client'; +export {AddressesClient} from './addresses_client'; +export {AutoscalersClient} from './autoscalers_client'; +export {BackendBucketsClient} from './backend_buckets_client'; +export {BackendServicesClient} from './backend_services_client'; +export {DisksClient} from './disks_client'; +export {DiskTypesClient} from './disk_types_client'; +export {ExternalVpnGatewaysClient} from './external_vpn_gateways_client'; +export {FirewallPoliciesClient} from './firewall_policies_client'; +export {FirewallsClient} from './firewalls_client'; +export {ForwardingRulesClient} from './forwarding_rules_client'; +export {GlobalAddressesClient} from './global_addresses_client'; +export {GlobalForwardingRulesClient} from './global_forwarding_rules_client'; +export {GlobalNetworkEndpointGroupsClient} from './global_network_endpoint_groups_client'; +export {GlobalOperationsClient} from './global_operations_client'; +export {GlobalOrganizationOperationsClient} from './global_organization_operations_client'; +export {GlobalPublicDelegatedPrefixesClient} from './global_public_delegated_prefixes_client'; +export {HealthChecksClient} from './health_checks_client'; +export {ImageFamilyViewsClient} from './image_family_views_client'; +export {ImagesClient} from './images_client'; +export {InstanceGroupManagersClient} from './instance_group_managers_client'; +export {InstanceGroupsClient} from './instance_groups_client'; +export {InstancesClient} from './instances_client'; +export {InstanceTemplatesClient} from './instance_templates_client'; +export {InterconnectAttachmentsClient} from './interconnect_attachments_client'; +export {InterconnectLocationsClient} from './interconnect_locations_client'; +export {InterconnectsClient} from './interconnects_client'; +export {LicenseCodesClient} from './license_codes_client'; +export {LicensesClient} from './licenses_client'; +export {MachineImagesClient} from './machine_images_client'; +export {MachineTypesClient} from './machine_types_client'; +export {NetworkAttachmentsClient} from './network_attachments_client'; +export {NetworkEdgeSecurityServicesClient} from './network_edge_security_services_client'; +export {NetworkEndpointGroupsClient} from './network_endpoint_groups_client'; +export {NetworkFirewallPoliciesClient} from './network_firewall_policies_client'; +export {NetworksClient} from './networks_client'; +export {NodeGroupsClient} from './node_groups_client'; +export {NodeTemplatesClient} from './node_templates_client'; +export {NodeTypesClient} from './node_types_client'; +export {PacketMirroringsClient} from './packet_mirrorings_client'; +export {ProjectsClient} from './projects_client'; +export {PublicAdvertisedPrefixesClient} from './public_advertised_prefixes_client'; +export {PublicDelegatedPrefixesClient} from './public_delegated_prefixes_client'; +export {RegionAutoscalersClient} from './region_autoscalers_client'; +export {RegionBackendServicesClient} from './region_backend_services_client'; +export {RegionCommitmentsClient} from './region_commitments_client'; +export {RegionDisksClient} from './region_disks_client'; +export {RegionDiskTypesClient} from './region_disk_types_client'; +export {RegionHealthChecksClient} from './region_health_checks_client'; +export {RegionHealthCheckServicesClient} from './region_health_check_services_client'; +export {RegionInstanceGroupManagersClient} from './region_instance_group_managers_client'; +export {RegionInstanceGroupsClient} from './region_instance_groups_client'; +export {RegionInstancesClient} from './region_instances_client'; +export {RegionInstanceTemplatesClient} from './region_instance_templates_client'; +export {RegionNetworkEndpointGroupsClient} from './region_network_endpoint_groups_client'; +export {RegionNetworkFirewallPoliciesClient} from './region_network_firewall_policies_client'; +export {RegionNotificationEndpointsClient} from './region_notification_endpoints_client'; +export {RegionOperationsClient} from './region_operations_client'; +export {RegionsClient} from './regions_client'; +export {RegionSecurityPoliciesClient} from './region_security_policies_client'; +export {RegionSslCertificatesClient} from './region_ssl_certificates_client'; +export {RegionSslPoliciesClient} from './region_ssl_policies_client'; +export {RegionTargetHttpProxiesClient} from './region_target_http_proxies_client'; +export {RegionTargetHttpsProxiesClient} from './region_target_https_proxies_client'; +export {RegionTargetTcpProxiesClient} from './region_target_tcp_proxies_client'; +export {RegionUrlMapsClient} from './region_url_maps_client'; +export {ReservationsClient} from './reservations_client'; +export {ResourcePoliciesClient} from './resource_policies_client'; +export {RoutersClient} from './routers_client'; +export {RoutesClient} from './routes_client'; +export {SecurityPoliciesClient} from './security_policies_client'; +export {ServiceAttachmentsClient} from './service_attachments_client'; +export {SnapshotsClient} from './snapshots_client'; +export {SslCertificatesClient} from './ssl_certificates_client'; +export {SslPoliciesClient} from './ssl_policies_client'; +export {SubnetworksClient} from './subnetworks_client'; +export {TargetGrpcProxiesClient} from './target_grpc_proxies_client'; +export {TargetHttpProxiesClient} from './target_http_proxies_client'; +export {TargetHttpsProxiesClient} from './target_https_proxies_client'; +export {TargetInstancesClient} from './target_instances_client'; +export {TargetPoolsClient} from './target_pools_client'; +export {TargetSslProxiesClient} from './target_ssl_proxies_client'; +export {TargetTcpProxiesClient} from './target_tcp_proxies_client'; +export {TargetVpnGatewaysClient} from './target_vpn_gateways_client'; +export {UrlMapsClient} from './url_maps_client'; +export {VpnGatewaysClient} from './vpn_gateways_client'; +export {VpnTunnelsClient} from './vpn_tunnels_client'; +export {ZoneOperationsClient} from './zone_operations_client'; +export {ZonesClient} from './zones_client'; diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_group_managers_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_group_managers_client.ts new file mode 100644 index 00000000000..0adb2b8040e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_group_managers_client.ts @@ -0,0 +1,2578 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/instance_group_managers_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './instance_group_managers_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The InstanceGroupManagers API. + * @class + * @memberof v1 + */ +export class InstanceGroupManagersClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + instanceGroupManagersStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of InstanceGroupManagersClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new InstanceGroupManagersClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof InstanceGroupManagersClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + listErrors: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + listManagedInstances: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'managedInstances'), + listPerInstanceConfigs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.InstanceGroupManagers', 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.instanceGroupManagersStub) { + return this.instanceGroupManagersStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.InstanceGroupManagers. + this.instanceGroupManagersStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.InstanceGroupManagers') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.InstanceGroupManagers, + 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 instanceGroupManagersStubMethods = + ['abandonInstances', 'aggregatedList', 'applyUpdatesToInstances', 'createInstances', 'delete', 'deleteInstances', 'deletePerInstanceConfigs', 'get', 'insert', 'list', 'listErrors', 'listManagedInstances', 'listPerInstanceConfigs', 'patch', 'patchPerInstanceConfigs', 'recreateInstances', 'resize', 'setInstanceTemplate', 'setTargetPools', 'updatePerInstanceConfigs']; + for (const methodName of instanceGroupManagersStubMethods) { + const callPromise = this.instanceGroupManagersStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.instanceGroupManagersStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Flags the specified instances to be removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. + * @param {google.cloud.compute.v1.InstanceGroupManagersAbandonInstancesRequest} request.instanceGroupManagersAbandonInstancesRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where the managed instance group is located. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_group_managers.abandon_instances.js + * region_tag:compute_v1_generated_InstanceGroupManagers_AbandonInstances_async + */ + abandonInstances( + request?: protos.google.cloud.compute.v1.IAbandonInstancesInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + abandonInstances( + request: protos.google.cloud.compute.v1.IAbandonInstancesInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAbandonInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + abandonInstances( + request: protos.google.cloud.compute.v1.IAbandonInstancesInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAbandonInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + abandonInstances( + request?: protos.google.cloud.compute.v1.IAbandonInstancesInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAbandonInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAbandonInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.abandonInstances(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Applies changes to selected instances on the managed instance group. This method can be used to apply new overrides and/or new versions. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group, should conform to RFC1035. + * @param {google.cloud.compute.v1.InstanceGroupManagersApplyUpdatesRequest} request.instanceGroupManagersApplyUpdatesRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone where the managed instance group is located. Should conform to RFC1035. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_group_managers.apply_updates_to_instances.js + * region_tag:compute_v1_generated_InstanceGroupManagers_ApplyUpdatesToInstances_async + */ + applyUpdatesToInstances( + request?: protos.google.cloud.compute.v1.IApplyUpdatesToInstancesInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + applyUpdatesToInstances( + request: protos.google.cloud.compute.v1.IApplyUpdatesToInstancesInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IApplyUpdatesToInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + applyUpdatesToInstances( + request: protos.google.cloud.compute.v1.IApplyUpdatesToInstancesInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IApplyUpdatesToInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + applyUpdatesToInstances( + request?: protos.google.cloud.compute.v1.IApplyUpdatesToInstancesInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IApplyUpdatesToInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IApplyUpdatesToInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.applyUpdatesToInstances(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Creates instances with per-instance configurations in this managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It should conform to RFC1035. + * @param {google.cloud.compute.v1.InstanceGroupManagersCreateInstancesRequest} request.instanceGroupManagersCreateInstancesRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where the managed instance group is located. It should conform to RFC1035. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_group_managers.create_instances.js + * region_tag:compute_v1_generated_InstanceGroupManagers_CreateInstances_async + */ + createInstances( + request?: protos.google.cloud.compute.v1.ICreateInstancesInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + createInstances( + request: protos.google.cloud.compute.v1.ICreateInstancesInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICreateInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + createInstances( + request: protos.google.cloud.compute.v1.ICreateInstancesInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICreateInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + createInstances( + request?: protos.google.cloud.compute.v1.ICreateInstancesInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICreateInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICreateInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.createInstances(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified managed instance group and all of the instances in that group. Note that the instance group must not belong to a backend service. Read Deleting an instance group for more information. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where the managed instance group is located. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_group_managers.delete.js + * region_tag:compute_v1_generated_InstanceGroupManagers_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Flags the specified instances in the managed instance group for immediate deletion. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. This operation is marked as DONE when the action is scheduled even if the instances are still being deleted. You must separately verify the status of the deleting action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. + * @param {google.cloud.compute.v1.InstanceGroupManagersDeleteInstancesRequest} request.instanceGroupManagersDeleteInstancesRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where the managed instance group is located. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_group_managers.delete_instances.js + * region_tag:compute_v1_generated_InstanceGroupManagers_DeleteInstances_async + */ + deleteInstances( + request?: protos.google.cloud.compute.v1.IDeleteInstancesInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + deleteInstances( + request: protos.google.cloud.compute.v1.IDeleteInstancesInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + deleteInstances( + request: protos.google.cloud.compute.v1.IDeleteInstancesInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + deleteInstances( + request?: protos.google.cloud.compute.v1.IDeleteInstancesInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteInstances(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes selected per-instance configurations for the managed instance group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It should conform to RFC1035. + * @param {google.cloud.compute.v1.InstanceGroupManagersDeletePerInstanceConfigsReq} request.instanceGroupManagersDeletePerInstanceConfigsReqResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone where the managed instance group is located. It should conform to RFC1035. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_group_managers.delete_per_instance_configs.js + * region_tag:compute_v1_generated_InstanceGroupManagers_DeletePerInstanceConfigs_async + */ + deletePerInstanceConfigs( + request?: protos.google.cloud.compute.v1.IDeletePerInstanceConfigsInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + deletePerInstanceConfigs( + request: protos.google.cloud.compute.v1.IDeletePerInstanceConfigsInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePerInstanceConfigsInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + deletePerInstanceConfigs( + request: protos.google.cloud.compute.v1.IDeletePerInstanceConfigsInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePerInstanceConfigsInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + deletePerInstanceConfigs( + request?: protos.google.cloud.compute.v1.IDeletePerInstanceConfigsInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePerInstanceConfigsInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePerInstanceConfigsInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.deletePerInstanceConfigs(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns all of the details about the specified managed instance group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone where the managed instance group is located. + * @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.compute.v1.InstanceGroupManager | InstanceGroupManager}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instance_group_managers.get.js + * region_tag:compute_v1_generated_InstanceGroupManagers_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstanceGroupManager, + protos.google.cloud.compute.v1.IGetInstanceGroupManagerRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IInstanceGroupManager, + protos.google.cloud.compute.v1.IGetInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IInstanceGroupManager, + protos.google.cloud.compute.v1.IGetInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IInstanceGroupManager, + protos.google.cloud.compute.v1.IGetInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IInstanceGroupManager, + protos.google.cloud.compute.v1.IGetInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IInstanceGroupManager, + protos.google.cloud.compute.v1.IGetInstanceGroupManagerRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. A managed instance group can have up to 1000 VM instances per group. Please contact Cloud Support if you need an increase in this limit. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.InstanceGroupManager} request.instanceGroupManagerResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where you want to create the managed instance group. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_group_managers.insert.js + * region_tag:compute_v1_generated_InstanceGroupManagers_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listManagedInstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. If you update your group to specify a new template or instance configuration, it's possible that your intended specification for each VM in the group is different from the current state of that VM. To learn how to apply an updated configuration to the VMs in a MIG, see Updating instances in a MIG. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the instance group manager. + * @param {google.cloud.compute.v1.InstanceGroupManager} request.instanceGroupManagerResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where you want to create the managed instance group. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_group_managers.patch.js + * region_tag:compute_v1_generated_InstanceGroupManagers_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It should conform to RFC1035. + * @param {google.cloud.compute.v1.InstanceGroupManagersPatchPerInstanceConfigsReq} request.instanceGroupManagersPatchPerInstanceConfigsReqResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where the managed instance group is located. It should conform to RFC1035. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_group_managers.patch_per_instance_configs.js + * region_tag:compute_v1_generated_InstanceGroupManagers_PatchPerInstanceConfigs_async + */ + patchPerInstanceConfigs( + request?: protos.google.cloud.compute.v1.IPatchPerInstanceConfigsInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patchPerInstanceConfigs( + request: protos.google.cloud.compute.v1.IPatchPerInstanceConfigsInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPerInstanceConfigsInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + patchPerInstanceConfigs( + request: protos.google.cloud.compute.v1.IPatchPerInstanceConfigsInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPerInstanceConfigsInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + patchPerInstanceConfigs( + request?: protos.google.cloud.compute.v1.IPatchPerInstanceConfigsInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPerInstanceConfigsInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPerInstanceConfigsInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.patchPerInstanceConfigs(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group's current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. + * @param {google.cloud.compute.v1.InstanceGroupManagersRecreateInstancesRequest} request.instanceGroupManagersRecreateInstancesRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where the managed instance group is located. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_group_managers.recreate_instances.js + * region_tag:compute_v1_generated_InstanceGroupManagers_RecreateInstances_async + */ + recreateInstances( + request?: protos.google.cloud.compute.v1.IRecreateInstancesInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + recreateInstances( + request: protos.google.cloud.compute.v1.IRecreateInstancesInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRecreateInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + recreateInstances( + request: protos.google.cloud.compute.v1.IRecreateInstancesInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRecreateInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + recreateInstances( + request?: protos.google.cloud.compute.v1.IRecreateInstancesInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRecreateInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRecreateInstancesInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.recreateInstances(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Resizes the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes instances. The resize operation is marked DONE when the resize actions are scheduled even if the group has not yet added or deleted any instances. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. When resizing down, the instance group arbitrarily chooses the order in which VMs are deleted. The group takes into account some VM attributes when making the selection including: + The status of the VM instance. + The health of the VM instance. + The instance template version the VM is based on. + For regional managed instance groups, the location of the VM instance. This list is subject to change. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {number} request.size + * The number of running instances that the managed instance group should maintain at any given time. The group automatically adds or removes instances to maintain the number of instances specified by this parameter. + * @param {string} request.zone + * The name of the zone where the managed instance group is located. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_group_managers.resize.js + * region_tag:compute_v1_generated_InstanceGroupManagers_Resize_async + */ + resize( + request?: protos.google.cloud.compute.v1.IResizeInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + resize( + request: protos.google.cloud.compute.v1.IResizeInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + resize( + request: protos.google.cloud.compute.v1.IResizeInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + resize( + request?: protos.google.cloud.compute.v1.IResizeInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.resize(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Specifies the instance template to use when creating new instances in this group. The templates for existing instances in the group do not change unless you run recreateInstances, run applyUpdatesToInstances, or set the group's updatePolicy.type to PROACTIVE. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. + * @param {google.cloud.compute.v1.InstanceGroupManagersSetInstanceTemplateRequest} request.instanceGroupManagersSetInstanceTemplateRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where the managed instance group is located. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_group_managers.set_instance_template.js + * region_tag:compute_v1_generated_InstanceGroupManagers_SetInstanceTemplate_async + */ + setInstanceTemplate( + request?: protos.google.cloud.compute.v1.ISetInstanceTemplateInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setInstanceTemplate( + request: protos.google.cloud.compute.v1.ISetInstanceTemplateInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetInstanceTemplateInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + setInstanceTemplate( + request: protos.google.cloud.compute.v1.ISetInstanceTemplateInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetInstanceTemplateInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + setInstanceTemplate( + request?: protos.google.cloud.compute.v1.ISetInstanceTemplateInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetInstanceTemplateInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetInstanceTemplateInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.setInstanceTemplate(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Modifies the target pools to which all instances in this managed instance group are assigned. The target pools automatically apply to all of the instances in the managed instance group. This operation is marked DONE when you make the request even if the instances have not yet been added to their target pools. The change might take some time to apply to all of the instances in the group depending on the size of the group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. + * @param {google.cloud.compute.v1.InstanceGroupManagersSetTargetPoolsRequest} request.instanceGroupManagersSetTargetPoolsRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where the managed instance group is located. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_group_managers.set_target_pools.js + * region_tag:compute_v1_generated_InstanceGroupManagers_SetTargetPools_async + */ + setTargetPools( + request?: protos.google.cloud.compute.v1.ISetTargetPoolsInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setTargetPools( + request: protos.google.cloud.compute.v1.ISetTargetPoolsInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTargetPoolsInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + setTargetPools( + request: protos.google.cloud.compute.v1.ISetTargetPoolsInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTargetPoolsInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + setTargetPools( + request?: protos.google.cloud.compute.v1.ISetTargetPoolsInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTargetPoolsInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTargetPoolsInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.setTargetPools(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It should conform to RFC1035. + * @param {google.cloud.compute.v1.InstanceGroupManagersUpdatePerInstanceConfigsReq} request.instanceGroupManagersUpdatePerInstanceConfigsReqResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where the managed instance group is located. It should conform to RFC1035. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_group_managers.update_per_instance_configs.js + * region_tag:compute_v1_generated_InstanceGroupManagers_UpdatePerInstanceConfigs_async + */ + updatePerInstanceConfigs( + request?: protos.google.cloud.compute.v1.IUpdatePerInstanceConfigsInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + updatePerInstanceConfigs( + request: protos.google.cloud.compute.v1.IUpdatePerInstanceConfigsInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdatePerInstanceConfigsInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + updatePerInstanceConfigs( + request: protos.google.cloud.compute.v1.IUpdatePerInstanceConfigsInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdatePerInstanceConfigsInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + updatePerInstanceConfigs( + request?: protos.google.cloud.compute.v1.IUpdatePerInstanceConfigsInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdatePerInstanceConfigsInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdatePerInstanceConfigsInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.updatePerInstanceConfigs(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves the list of managed instance groups and groups them by zone. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.InstanceGroupManagersScopedList | InstanceGroupManagersScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/instance_group_managers.aggregated_list.js + * region_tag:compute_v1_generated_InstanceGroupManagers_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListInstanceGroupManagersRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IInstanceGroupManagersScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IInstanceGroupManagersScopedList]>; + } + /** + * Retrieves a list of managed instance groups that are contained within the specified project and zone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the managed instance group is located. + * @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 google.cloud.compute.v1.InstanceGroupManager | InstanceGroupManager}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListInstanceGroupManagersRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstanceGroupManager[], + protos.google.cloud.compute.v1.IListInstanceGroupManagersRequest|null, + protos.google.cloud.compute.v1.IInstanceGroupManagerList + ]>; + list( + request: protos.google.cloud.compute.v1.IListInstanceGroupManagersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IInstanceGroupManagerList|null|undefined, + protos.google.cloud.compute.v1.IInstanceGroupManager>): void; + list( + request: protos.google.cloud.compute.v1.IListInstanceGroupManagersRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IInstanceGroupManagerList|null|undefined, + protos.google.cloud.compute.v1.IInstanceGroupManager>): void; + list( + request?: protos.google.cloud.compute.v1.IListInstanceGroupManagersRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IInstanceGroupManagerList|null|undefined, + protos.google.cloud.compute.v1.IInstanceGroupManager>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IInstanceGroupManagerList|null|undefined, + protos.google.cloud.compute.v1.IInstanceGroupManager>): + Promise<[ + protos.google.cloud.compute.v1.IInstanceGroupManager[], + protos.google.cloud.compute.v1.IListInstanceGroupManagersRequest|null, + protos.google.cloud.compute.v1.IInstanceGroupManagerList + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the managed instance group is located. + * @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 google.cloud.compute.v1.InstanceGroupManager | InstanceGroupManager} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListInstanceGroupManagersRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the managed instance group is located. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.InstanceGroupManager | InstanceGroupManager}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/instance_group_managers.list.js + * region_tag:compute_v1_generated_InstanceGroupManagers_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListInstanceGroupManagersRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists all errors thrown by actions on instances for a given managed instance group. The filter and orderBy query parameters are not supported. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It must be a string that meets the requirements in RFC1035, or an unsigned long integer: must match regexp pattern: (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)|1-9{0,19}. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the managed instance group is located. It should conform to RFC1035. + * @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 google.cloud.compute.v1.InstanceManagedByIgmError | InstanceManagedByIgmError}. + * 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 `listErrorsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listErrors( + request?: protos.google.cloud.compute.v1.IListErrorsInstanceGroupManagersRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstanceManagedByIgmError[], + protos.google.cloud.compute.v1.IListErrorsInstanceGroupManagersRequest|null, + protos.google.cloud.compute.v1.IInstanceGroupManagersListErrorsResponse + ]>; + listErrors( + request: protos.google.cloud.compute.v1.IListErrorsInstanceGroupManagersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListErrorsInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IInstanceGroupManagersListErrorsResponse|null|undefined, + protos.google.cloud.compute.v1.IInstanceManagedByIgmError>): void; + listErrors( + request: protos.google.cloud.compute.v1.IListErrorsInstanceGroupManagersRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListErrorsInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IInstanceGroupManagersListErrorsResponse|null|undefined, + protos.google.cloud.compute.v1.IInstanceManagedByIgmError>): void; + listErrors( + request?: protos.google.cloud.compute.v1.IListErrorsInstanceGroupManagersRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListErrorsInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IInstanceGroupManagersListErrorsResponse|null|undefined, + protos.google.cloud.compute.v1.IInstanceManagedByIgmError>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListErrorsInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IInstanceGroupManagersListErrorsResponse|null|undefined, + protos.google.cloud.compute.v1.IInstanceManagedByIgmError>): + Promise<[ + protos.google.cloud.compute.v1.IInstanceManagedByIgmError[], + protos.google.cloud.compute.v1.IListErrorsInstanceGroupManagersRequest|null, + protos.google.cloud.compute.v1.IInstanceGroupManagersListErrorsResponse + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.listErrors(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It must be a string that meets the requirements in RFC1035, or an unsigned long integer: must match regexp pattern: (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)|1-9{0,19}. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the managed instance group is located. It should conform to RFC1035. + * @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 google.cloud.compute.v1.InstanceManagedByIgmError | InstanceManagedByIgmError} 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 `listErrorsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listErrorsStream( + request?: protos.google.cloud.compute.v1.IListErrorsInstanceGroupManagersRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + const defaultCallSettings = this._defaults['listErrors']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listErrors.createStream( + this.innerApiCalls.listErrors as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listErrors`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It must be a string that meets the requirements in RFC1035, or an unsigned long integer: must match regexp pattern: (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)|1-9{0,19}. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the managed instance group is located. It should conform to RFC1035. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.InstanceManagedByIgmError | InstanceManagedByIgmError}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/instance_group_managers.list_errors.js + * region_tag:compute_v1_generated_InstanceGroupManagers_ListErrors_async + */ + listErrorsAsync( + request?: protos.google.cloud.compute.v1.IListErrorsInstanceGroupManagersRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + const defaultCallSettings = this._defaults['listErrors']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listErrors.asyncIterate( + this.innerApiCalls['listErrors'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists all of the instances in the managed instance group. Each instance in the list has a currentAction, which indicates the action that the managed instance group is performing on the instance. For example, if the group is still creating an instance, the currentAction is CREATING. If a previous action failed, the list displays the errors for that failed action. The orderBy query parameter is not supported. The `pageToken` query parameter is supported only in the alpha and beta API and only if the group's `listManagedInstancesResults` field is set to `PAGINATED`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the managed instance group is located. + * @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 google.cloud.compute.v1.ManagedInstance | ManagedInstance}. + * 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 `listManagedInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listManagedInstances( + request?: protos.google.cloud.compute.v1.IListManagedInstancesInstanceGroupManagersRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IManagedInstance[], + protos.google.cloud.compute.v1.IListManagedInstancesInstanceGroupManagersRequest|null, + protos.google.cloud.compute.v1.IInstanceGroupManagersListManagedInstancesResponse + ]>; + listManagedInstances( + request: protos.google.cloud.compute.v1.IListManagedInstancesInstanceGroupManagersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListManagedInstancesInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IInstanceGroupManagersListManagedInstancesResponse|null|undefined, + protos.google.cloud.compute.v1.IManagedInstance>): void; + listManagedInstances( + request: protos.google.cloud.compute.v1.IListManagedInstancesInstanceGroupManagersRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListManagedInstancesInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IInstanceGroupManagersListManagedInstancesResponse|null|undefined, + protos.google.cloud.compute.v1.IManagedInstance>): void; + listManagedInstances( + request?: protos.google.cloud.compute.v1.IListManagedInstancesInstanceGroupManagersRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListManagedInstancesInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IInstanceGroupManagersListManagedInstancesResponse|null|undefined, + protos.google.cloud.compute.v1.IManagedInstance>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListManagedInstancesInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IInstanceGroupManagersListManagedInstancesResponse|null|undefined, + protos.google.cloud.compute.v1.IManagedInstance>): + Promise<[ + protos.google.cloud.compute.v1.IManagedInstance[], + protos.google.cloud.compute.v1.IListManagedInstancesInstanceGroupManagersRequest|null, + protos.google.cloud.compute.v1.IInstanceGroupManagersListManagedInstancesResponse + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.listManagedInstances(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the managed instance group is located. + * @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 google.cloud.compute.v1.ManagedInstance | ManagedInstance} 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 `listManagedInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listManagedInstancesStream( + request?: protos.google.cloud.compute.v1.IListManagedInstancesInstanceGroupManagersRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + const defaultCallSettings = this._defaults['listManagedInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listManagedInstances.createStream( + this.innerApiCalls.listManagedInstances as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listManagedInstances`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the managed instance group is located. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.ManagedInstance | ManagedInstance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/instance_group_managers.list_managed_instances.js + * region_tag:compute_v1_generated_InstanceGroupManagers_ListManagedInstances_async + */ + listManagedInstancesAsync( + request?: protos.google.cloud.compute.v1.IListManagedInstancesInstanceGroupManagersRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + const defaultCallSettings = this._defaults['listManagedInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listManagedInstances.asyncIterate( + this.innerApiCalls['listManagedInstances'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists all of the per-instance configurations defined for the managed instance group. The orderBy query parameter is not supported. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It should conform to RFC1035. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the managed instance group is located. It should conform to RFC1035. + * @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 google.cloud.compute.v1.PerInstanceConfig | PerInstanceConfig}. + * 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 `listPerInstanceConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listPerInstanceConfigs( + request?: protos.google.cloud.compute.v1.IListPerInstanceConfigsInstanceGroupManagersRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPerInstanceConfig[], + protos.google.cloud.compute.v1.IListPerInstanceConfigsInstanceGroupManagersRequest|null, + protos.google.cloud.compute.v1.IInstanceGroupManagersListPerInstanceConfigsResp + ]>; + listPerInstanceConfigs( + request: protos.google.cloud.compute.v1.IListPerInstanceConfigsInstanceGroupManagersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListPerInstanceConfigsInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IInstanceGroupManagersListPerInstanceConfigsResp|null|undefined, + protos.google.cloud.compute.v1.IPerInstanceConfig>): void; + listPerInstanceConfigs( + request: protos.google.cloud.compute.v1.IListPerInstanceConfigsInstanceGroupManagersRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListPerInstanceConfigsInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IInstanceGroupManagersListPerInstanceConfigsResp|null|undefined, + protos.google.cloud.compute.v1.IPerInstanceConfig>): void; + listPerInstanceConfigs( + request?: protos.google.cloud.compute.v1.IListPerInstanceConfigsInstanceGroupManagersRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListPerInstanceConfigsInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IInstanceGroupManagersListPerInstanceConfigsResp|null|undefined, + protos.google.cloud.compute.v1.IPerInstanceConfig>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListPerInstanceConfigsInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IInstanceGroupManagersListPerInstanceConfigsResp|null|undefined, + protos.google.cloud.compute.v1.IPerInstanceConfig>): + Promise<[ + protos.google.cloud.compute.v1.IPerInstanceConfig[], + protos.google.cloud.compute.v1.IListPerInstanceConfigsInstanceGroupManagersRequest|null, + protos.google.cloud.compute.v1.IInstanceGroupManagersListPerInstanceConfigsResp + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.listPerInstanceConfigs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It should conform to RFC1035. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the managed instance group is located. It should conform to RFC1035. + * @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 google.cloud.compute.v1.PerInstanceConfig | PerInstanceConfig} 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 `listPerInstanceConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listPerInstanceConfigsStream( + request?: protos.google.cloud.compute.v1.IListPerInstanceConfigsInstanceGroupManagersRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + const defaultCallSettings = this._defaults['listPerInstanceConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPerInstanceConfigs.createStream( + this.innerApiCalls.listPerInstanceConfigs as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listPerInstanceConfigs`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It should conform to RFC1035. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the managed instance group is located. It should conform to RFC1035. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.PerInstanceConfig | PerInstanceConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/instance_group_managers.list_per_instance_configs.js + * region_tag:compute_v1_generated_InstanceGroupManagers_ListPerInstanceConfigs_async + */ + listPerInstanceConfigsAsync( + request?: protos.google.cloud.compute.v1.IListPerInstanceConfigsInstanceGroupManagersRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + const defaultCallSettings = this._defaults['listPerInstanceConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPerInstanceConfigs.asyncIterate( + this.innerApiCalls['listPerInstanceConfigs'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.instanceGroupManagersStub && !this._terminated) { + return this.instanceGroupManagersStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_group_managers_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_group_managers_client_config.json new file mode 100644 index 00000000000..a082a15ecc9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_group_managers_client_config.json @@ -0,0 +1,106 @@ +{ + "interfaces": { + "google.cloud.compute.v1.InstanceGroupManagers": { + "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": { + "AbandonInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ApplyUpdatesToInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeletePerInstanceConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListErrors": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListManagedInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListPerInstanceConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PatchPerInstanceConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RecreateInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Resize": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetInstanceTemplate": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetTargetPools": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdatePerInstanceConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_group_managers_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_group_managers_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_group_managers_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_groups_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_groups_client.ts new file mode 100644 index 00000000000..f0180b6996b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_groups_client.ts @@ -0,0 +1,1329 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/instance_groups_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './instance_groups_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The InstanceGroups API. + * @class + * @memberof v1 + */ +export class InstanceGroupsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + instanceGroupsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of InstanceGroupsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new InstanceGroupsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof InstanceGroupsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + listInstances: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.InstanceGroups', 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.instanceGroupsStub) { + return this.instanceGroupsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.InstanceGroups. + this.instanceGroupsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.InstanceGroups') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.InstanceGroups, + 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 instanceGroupsStubMethods = + ['addInstances', 'aggregatedList', 'delete', 'get', 'insert', 'list', 'listInstances', 'removeInstances', 'setNamedPorts']; + for (const methodName of instanceGroupsStubMethods) { + const callPromise = this.instanceGroupsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.instanceGroupsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Adds a list of instances to the specified instance group. All of the instances in the instance group must be in the same network/subnetwork. Read Adding instances for more information. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroup + * The name of the instance group where you are adding instances. + * @param {google.cloud.compute.v1.InstanceGroupsAddInstancesRequest} request.instanceGroupsAddInstancesRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where the instance group is located. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_groups.add_instances.js + * region_tag:compute_v1_generated_InstanceGroups_AddInstances_async + */ + addInstances( + request?: protos.google.cloud.compute.v1.IAddInstancesInstanceGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addInstances( + request: protos.google.cloud.compute.v1.IAddInstancesInstanceGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddInstancesInstanceGroupRequest|null|undefined, + {}|null|undefined>): void; + addInstances( + request: protos.google.cloud.compute.v1.IAddInstancesInstanceGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddInstancesInstanceGroupRequest|null|undefined, + {}|null|undefined>): void; + addInstances( + request?: protos.google.cloud.compute.v1.IAddInstancesInstanceGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddInstancesInstanceGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddInstancesInstanceGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group': request.instanceGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.addInstances(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified instance group. The instances in the group are not deleted. Note that instance group must not belong to a backend service. Read Deleting an instance group for more information. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroup + * The name of the instance group to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where the instance group is located. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_groups.delete.js + * region_tag:compute_v1_generated_InstanceGroups_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteInstanceGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteInstanceGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstanceGroupRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteInstanceGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstanceGroupRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteInstanceGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstanceGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstanceGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group': request.instanceGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified zonal instance group. Get a list of available zonal instance groups by making a list() request. For managed instance groups, use the instanceGroupManagers or regionInstanceGroupManagers methods instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroup + * The name of the instance group. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone where the instance group is located. + * @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.compute.v1.InstanceGroup | InstanceGroup}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instance_groups.get.js + * region_tag:compute_v1_generated_InstanceGroups_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetInstanceGroupRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstanceGroup, + protos.google.cloud.compute.v1.IGetInstanceGroupRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetInstanceGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IInstanceGroup, + protos.google.cloud.compute.v1.IGetInstanceGroupRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetInstanceGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IInstanceGroup, + protos.google.cloud.compute.v1.IGetInstanceGroupRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetInstanceGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IInstanceGroup, + protos.google.cloud.compute.v1.IGetInstanceGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IInstanceGroup, + protos.google.cloud.compute.v1.IGetInstanceGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IInstanceGroup, + protos.google.cloud.compute.v1.IGetInstanceGroupRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group': request.instanceGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates an instance group in the specified project using the parameters that are included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.InstanceGroup} request.instanceGroupResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where you want to create the instance group. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_groups.insert.js + * region_tag:compute_v1_generated_InstanceGroups_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertInstanceGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertInstanceGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInstanceGroupRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertInstanceGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInstanceGroupRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertInstanceGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInstanceGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInstanceGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Removes one or more instances from the specified instance group, but does not delete those instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration before the VM instance is removed or deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroup + * The name of the instance group where the specified instances will be removed. + * @param {google.cloud.compute.v1.InstanceGroupsRemoveInstancesRequest} request.instanceGroupsRemoveInstancesRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where the instance group is located. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_groups.remove_instances.js + * region_tag:compute_v1_generated_InstanceGroups_RemoveInstances_async + */ + removeInstances( + request?: protos.google.cloud.compute.v1.IRemoveInstancesInstanceGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + removeInstances( + request: protos.google.cloud.compute.v1.IRemoveInstancesInstanceGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveInstancesInstanceGroupRequest|null|undefined, + {}|null|undefined>): void; + removeInstances( + request: protos.google.cloud.compute.v1.IRemoveInstancesInstanceGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveInstancesInstanceGroupRequest|null|undefined, + {}|null|undefined>): void; + removeInstances( + request?: protos.google.cloud.compute.v1.IRemoveInstancesInstanceGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveInstancesInstanceGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveInstancesInstanceGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group': request.instanceGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeInstances(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the named ports for the specified instance group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroup + * The name of the instance group where the named ports are updated. + * @param {google.cloud.compute.v1.InstanceGroupsSetNamedPortsRequest} request.instanceGroupsSetNamedPortsRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where the instance group is located. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_groups.set_named_ports.js + * region_tag:compute_v1_generated_InstanceGroups_SetNamedPorts_async + */ + setNamedPorts( + request?: protos.google.cloud.compute.v1.ISetNamedPortsInstanceGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setNamedPorts( + request: protos.google.cloud.compute.v1.ISetNamedPortsInstanceGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetNamedPortsInstanceGroupRequest|null|undefined, + {}|null|undefined>): void; + setNamedPorts( + request: protos.google.cloud.compute.v1.ISetNamedPortsInstanceGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetNamedPortsInstanceGroupRequest|null|undefined, + {}|null|undefined>): void; + setNamedPorts( + request?: protos.google.cloud.compute.v1.ISetNamedPortsInstanceGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetNamedPortsInstanceGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetNamedPortsInstanceGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group': request.instanceGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.setNamedPorts(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves the list of instance groups and sorts them by zone. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.InstanceGroupsScopedList | InstanceGroupsScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/instance_groups.aggregated_list.js + * region_tag:compute_v1_generated_InstanceGroups_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListInstanceGroupsRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IInstanceGroupsScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IInstanceGroupsScopedList]>; + } + /** + * Retrieves the list of zonal instance group resources contained within the specified zone. For managed instance groups, use the instanceGroupManagers or regionInstanceGroupManagers methods instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the instance group is located. + * @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 google.cloud.compute.v1.InstanceGroup | InstanceGroup}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListInstanceGroupsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstanceGroup[], + protos.google.cloud.compute.v1.IListInstanceGroupsRequest|null, + protos.google.cloud.compute.v1.IInstanceGroupList + ]>; + list( + request: protos.google.cloud.compute.v1.IListInstanceGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInstanceGroupsRequest, + protos.google.cloud.compute.v1.IInstanceGroupList|null|undefined, + protos.google.cloud.compute.v1.IInstanceGroup>): void; + list( + request: protos.google.cloud.compute.v1.IListInstanceGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInstanceGroupsRequest, + protos.google.cloud.compute.v1.IInstanceGroupList|null|undefined, + protos.google.cloud.compute.v1.IInstanceGroup>): void; + list( + request?: protos.google.cloud.compute.v1.IListInstanceGroupsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListInstanceGroupsRequest, + protos.google.cloud.compute.v1.IInstanceGroupList|null|undefined, + protos.google.cloud.compute.v1.IInstanceGroup>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListInstanceGroupsRequest, + protos.google.cloud.compute.v1.IInstanceGroupList|null|undefined, + protos.google.cloud.compute.v1.IInstanceGroup>): + Promise<[ + protos.google.cloud.compute.v1.IInstanceGroup[], + protos.google.cloud.compute.v1.IListInstanceGroupsRequest|null, + protos.google.cloud.compute.v1.IInstanceGroupList + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the instance group is located. + * @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 google.cloud.compute.v1.InstanceGroup | InstanceGroup} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListInstanceGroupsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the instance group is located. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.InstanceGroup | InstanceGroup}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/instance_groups.list.js + * region_tag:compute_v1_generated_InstanceGroups_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListInstanceGroupsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the instances in the specified instance group. The orderBy query parameter is not supported. The filter query parameter is supported, but only for expressions that use `eq` (equal) or `ne` (not equal) operators. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroup + * The name of the instance group from which you want to generate a list of included instances. + * @param {google.cloud.compute.v1.InstanceGroupsListInstancesRequest} request.instanceGroupsListInstancesRequestResource + * The body resource for this request + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the instance group is located. + * @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 google.cloud.compute.v1.InstanceWithNamedPorts | InstanceWithNamedPorts}. + * 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 + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listInstances( + request?: protos.google.cloud.compute.v1.IListInstancesInstanceGroupsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstanceWithNamedPorts[], + protos.google.cloud.compute.v1.IListInstancesInstanceGroupsRequest|null, + protos.google.cloud.compute.v1.IInstanceGroupsListInstances + ]>; + listInstances( + request: protos.google.cloud.compute.v1.IListInstancesInstanceGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInstancesInstanceGroupsRequest, + protos.google.cloud.compute.v1.IInstanceGroupsListInstances|null|undefined, + protos.google.cloud.compute.v1.IInstanceWithNamedPorts>): void; + listInstances( + request: protos.google.cloud.compute.v1.IListInstancesInstanceGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInstancesInstanceGroupsRequest, + protos.google.cloud.compute.v1.IInstanceGroupsListInstances|null|undefined, + protos.google.cloud.compute.v1.IInstanceWithNamedPorts>): void; + listInstances( + request?: protos.google.cloud.compute.v1.IListInstancesInstanceGroupsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListInstancesInstanceGroupsRequest, + protos.google.cloud.compute.v1.IInstanceGroupsListInstances|null|undefined, + protos.google.cloud.compute.v1.IInstanceWithNamedPorts>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListInstancesInstanceGroupsRequest, + protos.google.cloud.compute.v1.IInstanceGroupsListInstances|null|undefined, + protos.google.cloud.compute.v1.IInstanceWithNamedPorts>): + Promise<[ + protos.google.cloud.compute.v1.IInstanceWithNamedPorts[], + protos.google.cloud.compute.v1.IListInstancesInstanceGroupsRequest|null, + protos.google.cloud.compute.v1.IInstanceGroupsListInstances + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group': request.instanceGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.listInstances(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroup + * The name of the instance group from which you want to generate a list of included instances. + * @param {google.cloud.compute.v1.InstanceGroupsListInstancesRequest} request.instanceGroupsListInstancesRequestResource + * The body resource for this request + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the instance group is located. + * @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 google.cloud.compute.v1.InstanceWithNamedPorts | InstanceWithNamedPorts} 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 + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listInstancesStream( + request?: protos.google.cloud.compute.v1.IListInstancesInstanceGroupsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group': request.instanceGroup ?? '', + }); + const defaultCallSettings = this._defaults['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroup + * The name of the instance group from which you want to generate a list of included instances. + * @param {google.cloud.compute.v1.InstanceGroupsListInstancesRequest} request.instanceGroupsListInstancesRequestResource + * The body resource for this request + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the instance group is located. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.InstanceWithNamedPorts | InstanceWithNamedPorts}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/instance_groups.list_instances.js + * region_tag:compute_v1_generated_InstanceGroups_ListInstances_async + */ + listInstancesAsync( + request?: protos.google.cloud.compute.v1.IListInstancesInstanceGroupsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance_group': request.instanceGroup ?? '', + }); + const defaultCallSettings = this._defaults['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstances.asyncIterate( + this.innerApiCalls['listInstances'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.instanceGroupsStub && !this._terminated) { + return this.instanceGroupsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_groups_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_groups_client_config.json new file mode 100644 index 00000000000..cd3de4b8870 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_groups_client_config.json @@ -0,0 +1,62 @@ +{ + "interfaces": { + "google.cloud.compute.v1.InstanceGroups": { + "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": { + "AddInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetNamedPorts": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_groups_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_groups_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_groups_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_templates_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_templates_client.ts new file mode 100644 index 00000000000..ecc92a4b0ed --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_templates_client.ts @@ -0,0 +1,1043 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/instance_templates_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './instance_templates_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The InstanceTemplates API. + * @class + * @memberof v1 + */ +export class InstanceTemplatesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + instanceTemplatesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of InstanceTemplatesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new InstanceTemplatesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof InstanceTemplatesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.InstanceTemplates', 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.instanceTemplatesStub) { + return this.instanceTemplatesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.InstanceTemplates. + this.instanceTemplatesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.InstanceTemplates') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.InstanceTemplates, + 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 instanceTemplatesStubMethods = + ['aggregatedList', 'delete', 'get', 'getIamPolicy', 'insert', 'list', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of instanceTemplatesStubMethods) { + const callPromise = this.instanceTemplatesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.instanceTemplatesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified instance template. Deleting an instance template is permanent and cannot be undone. It is not possible to delete templates that are already in use by a managed instance group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceTemplate + * The name of the instance template to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_templates.delete.js + * region_tag:compute_v1_generated_InstanceTemplates_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteInstanceTemplateRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteInstanceTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteInstanceTemplateRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteInstanceTemplateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstanceTemplateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstanceTemplateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'instance_template': request.instanceTemplate ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified instance template. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceTemplate + * The name of the instance template. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.InstanceTemplate | InstanceTemplate}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instance_templates.get.js + * region_tag:compute_v1_generated_InstanceTemplates_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetInstanceTemplateRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstanceTemplate, + protos.google.cloud.compute.v1.IGetInstanceTemplateRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetInstanceTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IInstanceTemplate, + protos.google.cloud.compute.v1.IGetInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetInstanceTemplateRequest, + callback: Callback< + protos.google.cloud.compute.v1.IInstanceTemplate, + protos.google.cloud.compute.v1.IGetInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetInstanceTemplateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IInstanceTemplate, + protos.google.cloud.compute.v1.IGetInstanceTemplateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IInstanceTemplate, + protos.google.cloud.compute.v1.IGetInstanceTemplateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IInstanceTemplate, + protos.google.cloud.compute.v1.IGetInstanceTemplateRequest|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({ + 'project': request.project ?? '', + 'instance_template': request.instanceTemplate ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instance_templates.get_iam_policy.js + * region_tag:compute_v1_generated_InstanceTemplates_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyInstanceTemplateRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyInstanceTemplateRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyInstanceTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyInstanceTemplateRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyInstanceTemplateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyInstanceTemplateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyInstanceTemplateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyInstanceTemplateRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Creates an instance template in the specified project using the data that is included in the request. If you are creating a new template to update an existing instance group, your new instance template must use the same network or, if applicable, the same subnetwork as the original template. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.InstanceTemplate} request.instanceTemplateResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instance_templates.insert.js + * region_tag:compute_v1_generated_InstanceTemplates_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertInstanceTemplateRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertInstanceTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertInstanceTemplateRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertInstanceTemplateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInstanceTemplateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInstanceTemplateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalSetPolicyRequest} request.globalSetPolicyRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instance_templates.set_iam_policy.js + * region_tag:compute_v1_generated_InstanceTemplates_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyInstanceTemplateRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyInstanceTemplateRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyInstanceTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyInstanceTemplateRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyInstanceTemplateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyInstanceTemplateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyInstanceTemplateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyInstanceTemplateRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instance_templates.test_iam_permissions.js + * region_tag:compute_v1_generated_InstanceTemplates_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsInstanceTemplateRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsInstanceTemplateRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsInstanceTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsInstanceTemplateRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsInstanceTemplateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsInstanceTemplateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsInstanceTemplateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsInstanceTemplateRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + +/** + * Retrieves the list of all InstanceTemplates resources, regional and global, available to the specified project. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Name of the project scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.InstanceTemplatesScopedList | InstanceTemplatesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/instance_templates.aggregated_list.js + * region_tag:compute_v1_generated_InstanceTemplates_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListInstanceTemplatesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IInstanceTemplatesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IInstanceTemplatesScopedList]>; + } + /** + * Retrieves a list of instance templates that are contained within the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.InstanceTemplate | InstanceTemplate}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListInstanceTemplatesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstanceTemplate[], + protos.google.cloud.compute.v1.IListInstanceTemplatesRequest|null, + protos.google.cloud.compute.v1.IInstanceTemplateList + ]>; + list( + request: protos.google.cloud.compute.v1.IListInstanceTemplatesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInstanceTemplatesRequest, + protos.google.cloud.compute.v1.IInstanceTemplateList|null|undefined, + protos.google.cloud.compute.v1.IInstanceTemplate>): void; + list( + request: protos.google.cloud.compute.v1.IListInstanceTemplatesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInstanceTemplatesRequest, + protos.google.cloud.compute.v1.IInstanceTemplateList|null|undefined, + protos.google.cloud.compute.v1.IInstanceTemplate>): void; + list( + request?: protos.google.cloud.compute.v1.IListInstanceTemplatesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListInstanceTemplatesRequest, + protos.google.cloud.compute.v1.IInstanceTemplateList|null|undefined, + protos.google.cloud.compute.v1.IInstanceTemplate>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListInstanceTemplatesRequest, + protos.google.cloud.compute.v1.IInstanceTemplateList|null|undefined, + protos.google.cloud.compute.v1.IInstanceTemplate>): + Promise<[ + protos.google.cloud.compute.v1.IInstanceTemplate[], + protos.google.cloud.compute.v1.IListInstanceTemplatesRequest|null, + protos.google.cloud.compute.v1.IInstanceTemplateList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.InstanceTemplate | InstanceTemplate} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListInstanceTemplatesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.InstanceTemplate | InstanceTemplate}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/instance_templates.list.js + * region_tag:compute_v1_generated_InstanceTemplates_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListInstanceTemplatesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.instanceTemplatesStub && !this._terminated) { + return this.instanceTemplatesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_templates_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_templates_client_config.json new file mode 100644 index 00000000000..3117de45c09 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_templates_client_config.json @@ -0,0 +1,58 @@ +{ + "interfaces": { + "google.cloud.compute.v1.InstanceTemplates": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_templates_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_templates_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/instance_templates_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/instances_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/instances_client.ts new file mode 100644 index 00000000000..186770e2329 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/instances_client.ts @@ -0,0 +1,4645 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/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 Instances API. + * @class + * @memberof v1 + */ +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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + 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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new InstancesClient({fallback: 'rest'}, 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; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + listReferrers: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.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.compute.v1.Instances. + this.instancesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Instances') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.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 = + ['addAccessConfig', 'addResourcePolicies', 'aggregatedList', 'attachDisk', 'bulkInsert', 'delete', 'deleteAccessConfig', 'detachDisk', 'get', 'getEffectiveFirewalls', 'getGuestAttributes', 'getIamPolicy', 'getScreenshot', 'getSerialPortOutput', 'getShieldedInstanceIdentity', 'insert', 'list', 'listReferrers', 'removeResourcePolicies', 'reset', 'resume', 'sendDiagnosticInterrupt', 'setDeletionProtection', 'setDiskAutoDelete', 'setIamPolicy', 'setLabels', 'setMachineResources', 'setMachineType', 'setMetadata', 'setMinCpuPlatform', 'setName', 'setScheduling', 'setServiceAccount', 'setShieldedInstanceIntegrityPolicy', 'setTags', 'simulateMaintenanceEvent', 'start', 'startWithEncryptionKey', 'stop', 'suspend', 'testIamPermissions', 'update', 'updateAccessConfig', 'updateDisplayDevice', 'updateNetworkInterface', 'updateShieldedInstanceConfig']; + 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] || + 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. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Adds an access config to an instance's network interface. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.AccessConfig} request.accessConfigResource + * The body resource for this request + * @param {string} request.instance + * The instance name for this request. + * @param {string} request.networkInterface + * The name of the network interface to add to this instance. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.add_access_config.js + * region_tag:compute_v1_generated_Instances_AddAccessConfig_async + */ + addAccessConfig( + request?: protos.google.cloud.compute.v1.IAddAccessConfigInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addAccessConfig( + request: protos.google.cloud.compute.v1.IAddAccessConfigInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddAccessConfigInstanceRequest|null|undefined, + {}|null|undefined>): void; + addAccessConfig( + request: protos.google.cloud.compute.v1.IAddAccessConfigInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddAccessConfigInstanceRequest|null|undefined, + {}|null|undefined>): void; + addAccessConfig( + request?: protos.google.cloud.compute.v1.IAddAccessConfigInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddAccessConfigInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddAccessConfigInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.addAccessConfig(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Adds existing resource policies to an instance. You can only add one policy right now which will be applied to this instance for scheduling live migrations. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * The instance name for this request. + * @param {google.cloud.compute.v1.InstancesAddResourcePoliciesRequest} request.instancesAddResourcePoliciesRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.add_resource_policies.js + * region_tag:compute_v1_generated_Instances_AddResourcePolicies_async + */ + addResourcePolicies( + request?: protos.google.cloud.compute.v1.IAddResourcePoliciesInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addResourcePolicies( + request: protos.google.cloud.compute.v1.IAddResourcePoliciesInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddResourcePoliciesInstanceRequest|null|undefined, + {}|null|undefined>): void; + addResourcePolicies( + request: protos.google.cloud.compute.v1.IAddResourcePoliciesInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddResourcePoliciesInstanceRequest|null|undefined, + {}|null|undefined>): void; + addResourcePolicies( + request?: protos.google.cloud.compute.v1.IAddResourcePoliciesInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddResourcePoliciesInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddResourcePoliciesInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.addResourcePolicies(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Attaches an existing Disk resource to an instance. You must first create the disk before you can attach it. It is not possible to create and attach a disk at the same time. For more information, read Adding a persistent disk to your instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.AttachedDisk} request.attachedDiskResource + * The body resource for this request + * @param {boolean} request.forceAttach + * Whether to force attach the regional disk even if it's currently attached to another instance. If you try to force attach a zonal disk to an instance, you will receive an error. + * @param {string} request.instance + * The instance name for this request. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.attach_disk.js + * region_tag:compute_v1_generated_Instances_AttachDisk_async + */ + attachDisk( + request?: protos.google.cloud.compute.v1.IAttachDiskInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + attachDisk( + request: protos.google.cloud.compute.v1.IAttachDiskInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAttachDiskInstanceRequest|null|undefined, + {}|null|undefined>): void; + attachDisk( + request: protos.google.cloud.compute.v1.IAttachDiskInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAttachDiskInstanceRequest|null|undefined, + {}|null|undefined>): void; + attachDisk( + request?: protos.google.cloud.compute.v1.IAttachDiskInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAttachDiskInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAttachDiskInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.attachDisk(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Creates multiple instances. Count specifies the number of instances to create. For more information, see About bulk creation of VMs. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.BulkInsertInstanceResource} request.bulkInsertInstanceResourceResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.bulk_insert.js + * region_tag:compute_v1_generated_Instances_BulkInsert_async + */ + bulkInsert( + request?: protos.google.cloud.compute.v1.IBulkInsertInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + bulkInsert( + request: protos.google.cloud.compute.v1.IBulkInsertInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IBulkInsertInstanceRequest|null|undefined, + {}|null|undefined>): void; + bulkInsert( + request: protos.google.cloud.compute.v1.IBulkInsertInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IBulkInsertInstanceRequest|null|undefined, + {}|null|undefined>): void; + bulkInsert( + request?: protos.google.cloud.compute.v1.IBulkInsertInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IBulkInsertInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IBulkInsertInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.bulkInsert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified Instance resource. For more information, see Deleting an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.delete.js + * region_tag:compute_v1_generated_Instances_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstanceRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstanceRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes an access config from an instance's network interface. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.accessConfig + * The name of the access config to delete. + * @param {string} request.instance + * The instance name for this request. + * @param {string} request.networkInterface + * The name of the network interface. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.delete_access_config.js + * region_tag:compute_v1_generated_Instances_DeleteAccessConfig_async + */ + deleteAccessConfig( + request?: protos.google.cloud.compute.v1.IDeleteAccessConfigInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + deleteAccessConfig( + request: protos.google.cloud.compute.v1.IDeleteAccessConfigInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteAccessConfigInstanceRequest|null|undefined, + {}|null|undefined>): void; + deleteAccessConfig( + request: protos.google.cloud.compute.v1.IDeleteAccessConfigInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteAccessConfigInstanceRequest|null|undefined, + {}|null|undefined>): void; + deleteAccessConfig( + request?: protos.google.cloud.compute.v1.IDeleteAccessConfigInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteAccessConfigInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteAccessConfigInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteAccessConfig(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Detaches a disk from an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.deviceName + * The device name of the disk to detach. Make a get() request on the instance to view currently attached disks and device names. + * @param {string} request.instance + * Instance name for this request. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.detach_disk.js + * region_tag:compute_v1_generated_Instances_DetachDisk_async + */ + detachDisk( + request?: protos.google.cloud.compute.v1.IDetachDiskInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + detachDisk( + request: protos.google.cloud.compute.v1.IDetachDiskInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDetachDiskInstanceRequest|null|undefined, + {}|null|undefined>): void; + detachDisk( + request: protos.google.cloud.compute.v1.IDetachDiskInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDetachDiskInstanceRequest|null|undefined, + {}|null|undefined>): void; + detachDisk( + request?: protos.google.cloud.compute.v1.IDetachDiskInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDetachDiskInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDetachDiskInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.detachDisk(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified Instance resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance resource to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.Instance | Instance}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instances.get.js + * region_tag:compute_v1_generated_Instances_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstance, + protos.google.cloud.compute.v1.IGetInstanceRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IInstance, + protos.google.cloud.compute.v1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IInstance, + protos.google.cloud.compute.v1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IInstance, + protos.google.cloud.compute.v1.IGetInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IInstance, + protos.google.cloud.compute.v1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IInstance, + protos.google.cloud.compute.v1.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 || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Returns effective firewalls applied to an interface of the instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance scoping this request. + * @param {string} request.networkInterface + * The name of the network interface to get the effective firewalls. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.InstancesGetEffectiveFirewallsResponse | InstancesGetEffectiveFirewallsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instances.get_effective_firewalls.js + * region_tag:compute_v1_generated_Instances_GetEffectiveFirewalls_async + */ + getEffectiveFirewalls( + request?: protos.google.cloud.compute.v1.IGetEffectiveFirewallsInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstancesGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsInstanceRequest|undefined, {}|undefined + ]>; + getEffectiveFirewalls( + request: protos.google.cloud.compute.v1.IGetEffectiveFirewallsInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IInstancesGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsInstanceRequest|null|undefined, + {}|null|undefined>): void; + getEffectiveFirewalls( + request: protos.google.cloud.compute.v1.IGetEffectiveFirewallsInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IInstancesGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsInstanceRequest|null|undefined, + {}|null|undefined>): void; + getEffectiveFirewalls( + request?: protos.google.cloud.compute.v1.IGetEffectiveFirewallsInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IInstancesGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IInstancesGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IInstancesGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsInstanceRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.getEffectiveFirewalls(request, options, callback); + } +/** + * Returns the specified guest attributes entry. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance scoping this request. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.queryPath + * Specifies the guest attributes path to be queried. + * @param {string} request.variableKey + * Specifies the key for the guest attributes entry. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.GuestAttributes | GuestAttributes}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instances.get_guest_attributes.js + * region_tag:compute_v1_generated_Instances_GetGuestAttributes_async + */ + getGuestAttributes( + request?: protos.google.cloud.compute.v1.IGetGuestAttributesInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IGuestAttributes, + protos.google.cloud.compute.v1.IGetGuestAttributesInstanceRequest|undefined, {}|undefined + ]>; + getGuestAttributes( + request: protos.google.cloud.compute.v1.IGetGuestAttributesInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IGuestAttributes, + protos.google.cloud.compute.v1.IGetGuestAttributesInstanceRequest|null|undefined, + {}|null|undefined>): void; + getGuestAttributes( + request: protos.google.cloud.compute.v1.IGetGuestAttributesInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IGuestAttributes, + protos.google.cloud.compute.v1.IGetGuestAttributesInstanceRequest|null|undefined, + {}|null|undefined>): void; + getGuestAttributes( + request?: protos.google.cloud.compute.v1.IGetGuestAttributesInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IGuestAttributes, + protos.google.cloud.compute.v1.IGetGuestAttributesInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IGuestAttributes, + protos.google.cloud.compute.v1.IGetGuestAttributesInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IGuestAttributes, + protos.google.cloud.compute.v1.IGetGuestAttributesInstanceRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.getGuestAttributes(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instances.get_iam_policy.js + * region_tag:compute_v1_generated_Instances_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyInstanceRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyInstanceRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyInstanceRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyInstanceRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Returns the screenshot from the specified instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance scoping this request. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.Screenshot | Screenshot}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instances.get_screenshot.js + * region_tag:compute_v1_generated_Instances_GetScreenshot_async + */ + getScreenshot( + request?: protos.google.cloud.compute.v1.IGetScreenshotInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IScreenshot, + protos.google.cloud.compute.v1.IGetScreenshotInstanceRequest|undefined, {}|undefined + ]>; + getScreenshot( + request: protos.google.cloud.compute.v1.IGetScreenshotInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IScreenshot, + protos.google.cloud.compute.v1.IGetScreenshotInstanceRequest|null|undefined, + {}|null|undefined>): void; + getScreenshot( + request: protos.google.cloud.compute.v1.IGetScreenshotInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IScreenshot, + protos.google.cloud.compute.v1.IGetScreenshotInstanceRequest|null|undefined, + {}|null|undefined>): void; + getScreenshot( + request?: protos.google.cloud.compute.v1.IGetScreenshotInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IScreenshot, + protos.google.cloud.compute.v1.IGetScreenshotInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IScreenshot, + protos.google.cloud.compute.v1.IGetScreenshotInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IScreenshot, + protos.google.cloud.compute.v1.IGetScreenshotInstanceRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.getScreenshot(request, options, callback); + } +/** + * Returns the last 1 MB of serial port output from the specified instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance for this request. + * @param {number} request.port + * Specifies which COM or serial port to retrieve data from. + * @param {string} request.project + * Project ID for this request. + * @param {number} request.start + * Specifies the starting byte position of the output to return. To start with the first byte of output to the specified port, omit this field or set it to `0`. If the output for that byte position is available, this field matches the `start` parameter sent with the request. If the amount of serial console output exceeds the size of the buffer (1 MB), the oldest output is discarded and is no longer available. If the requested start position refers to discarded output, the start position is adjusted to the oldest output still available, and the adjusted start position is returned as the `start` property value. You can also provide a negative start position, which translates to the most recent number of bytes written to the serial port. For example, -3 is interpreted as the most recent 3 bytes written to the serial console. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.SerialPortOutput | SerialPortOutput}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instances.get_serial_port_output.js + * region_tag:compute_v1_generated_Instances_GetSerialPortOutput_async + */ + getSerialPortOutput( + request?: protos.google.cloud.compute.v1.IGetSerialPortOutputInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISerialPortOutput, + protos.google.cloud.compute.v1.IGetSerialPortOutputInstanceRequest|undefined, {}|undefined + ]>; + getSerialPortOutput( + request: protos.google.cloud.compute.v1.IGetSerialPortOutputInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ISerialPortOutput, + protos.google.cloud.compute.v1.IGetSerialPortOutputInstanceRequest|null|undefined, + {}|null|undefined>): void; + getSerialPortOutput( + request: protos.google.cloud.compute.v1.IGetSerialPortOutputInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.ISerialPortOutput, + protos.google.cloud.compute.v1.IGetSerialPortOutputInstanceRequest|null|undefined, + {}|null|undefined>): void; + getSerialPortOutput( + request?: protos.google.cloud.compute.v1.IGetSerialPortOutputInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ISerialPortOutput, + protos.google.cloud.compute.v1.IGetSerialPortOutputInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ISerialPortOutput, + protos.google.cloud.compute.v1.IGetSerialPortOutputInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ISerialPortOutput, + protos.google.cloud.compute.v1.IGetSerialPortOutputInstanceRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.getSerialPortOutput(request, options, callback); + } +/** + * Returns the Shielded Instance Identity of an instance + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name or id of the instance scoping this request. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.ShieldedInstanceIdentity | ShieldedInstanceIdentity}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instances.get_shielded_instance_identity.js + * region_tag:compute_v1_generated_Instances_GetShieldedInstanceIdentity_async + */ + getShieldedInstanceIdentity( + request?: protos.google.cloud.compute.v1.IGetShieldedInstanceIdentityInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IShieldedInstanceIdentity, + protos.google.cloud.compute.v1.IGetShieldedInstanceIdentityInstanceRequest|undefined, {}|undefined + ]>; + getShieldedInstanceIdentity( + request: protos.google.cloud.compute.v1.IGetShieldedInstanceIdentityInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IShieldedInstanceIdentity, + protos.google.cloud.compute.v1.IGetShieldedInstanceIdentityInstanceRequest|null|undefined, + {}|null|undefined>): void; + getShieldedInstanceIdentity( + request: protos.google.cloud.compute.v1.IGetShieldedInstanceIdentityInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IShieldedInstanceIdentity, + protos.google.cloud.compute.v1.IGetShieldedInstanceIdentityInstanceRequest|null|undefined, + {}|null|undefined>): void; + getShieldedInstanceIdentity( + request?: protos.google.cloud.compute.v1.IGetShieldedInstanceIdentityInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IShieldedInstanceIdentity, + protos.google.cloud.compute.v1.IGetShieldedInstanceIdentityInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IShieldedInstanceIdentity, + protos.google.cloud.compute.v1.IGetShieldedInstanceIdentityInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IShieldedInstanceIdentity, + protos.google.cloud.compute.v1.IGetShieldedInstanceIdentityInstanceRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.getShieldedInstanceIdentity(request, options, callback); + } +/** + * Creates an instance resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.Instance} request.instanceResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.sourceInstanceTemplate + * Specifies instance template to create the instance. This field is optional. It can be a full or partial URL. For example, the following are all valid URLs to an instance template: - https://www.googleapis.com/compute/v1/projects/project /global/instanceTemplates/instanceTemplate - projects/project/global/instanceTemplates/instanceTemplate - global/instanceTemplates/instanceTemplate + * @param {string} request.sourceMachineImage + * Specifies the machine image to use to create the instance. This field is optional. It can be a full or partial URL. For example, the following are all valid URLs to a machine image: - https://www.googleapis.com/compute/v1/projects/project/global/global /machineImages/machineImage - projects/project/global/global/machineImages/machineImage - global/machineImages/machineImage + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.insert.js + * region_tag:compute_v1_generated_Instances_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInstanceRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInstanceRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Removes resource policies from an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * The instance name for this request. + * @param {google.cloud.compute.v1.InstancesRemoveResourcePoliciesRequest} request.instancesRemoveResourcePoliciesRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.remove_resource_policies.js + * region_tag:compute_v1_generated_Instances_RemoveResourcePolicies_async + */ + removeResourcePolicies( + request?: protos.google.cloud.compute.v1.IRemoveResourcePoliciesInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + removeResourcePolicies( + request: protos.google.cloud.compute.v1.IRemoveResourcePoliciesInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveResourcePoliciesInstanceRequest|null|undefined, + {}|null|undefined>): void; + removeResourcePolicies( + request: protos.google.cloud.compute.v1.IRemoveResourcePoliciesInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveResourcePoliciesInstanceRequest|null|undefined, + {}|null|undefined>): void; + removeResourcePolicies( + request?: protos.google.cloud.compute.v1.IRemoveResourcePoliciesInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveResourcePoliciesInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveResourcePoliciesInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeResourcePolicies(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more information, see Resetting an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance scoping this request. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.reset.js + * region_tag:compute_v1_generated_Instances_Reset_async + */ + reset( + request?: protos.google.cloud.compute.v1.IResetInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + reset( + request: protos.google.cloud.compute.v1.IResetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResetInstanceRequest|null|undefined, + {}|null|undefined>): void; + reset( + request: protos.google.cloud.compute.v1.IResetInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResetInstanceRequest|null|undefined, + {}|null|undefined>): void; + reset( + request?: protos.google.cloud.compute.v1.IResetInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResetInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResetInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.reset(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Resumes an instance that was suspended using the instances().suspend method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance resource to resume. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.resume.js + * region_tag:compute_v1_generated_Instances_Resume_async + */ + resume( + request?: protos.google.cloud.compute.v1.IResumeInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + resume( + request: protos.google.cloud.compute.v1.IResumeInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResumeInstanceRequest|null|undefined, + {}|null|undefined>): void; + resume( + request: protos.google.cloud.compute.v1.IResumeInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResumeInstanceRequest|null|undefined, + {}|null|undefined>): void; + resume( + request?: protos.google.cloud.compute.v1.IResumeInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResumeInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResumeInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.resume(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sends diagnostic interrupt to the instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance scoping this request. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.SendDiagnosticInterruptInstanceResponse | SendDiagnosticInterruptInstanceResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instances.send_diagnostic_interrupt.js + * region_tag:compute_v1_generated_Instances_SendDiagnosticInterrupt_async + */ + sendDiagnosticInterrupt( + request?: protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceResponse, + protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceRequest|undefined, {}|undefined + ]>; + sendDiagnosticInterrupt( + request: protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceResponse, + protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceRequest|null|undefined, + {}|null|undefined>): void; + sendDiagnosticInterrupt( + request: protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceResponse, + protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceRequest|null|undefined, + {}|null|undefined>): void; + sendDiagnosticInterrupt( + request?: protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceResponse, + protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceResponse, + protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceResponse, + protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.sendDiagnosticInterrupt(request, options, callback); + } +/** + * Sets deletion protection on the instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {boolean} request.deletionProtection + * Whether the resource should be protected against deletion. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.set_deletion_protection.js + * region_tag:compute_v1_generated_Instances_SetDeletionProtection_async + */ + setDeletionProtection( + request?: protos.google.cloud.compute.v1.ISetDeletionProtectionInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setDeletionProtection( + request: protos.google.cloud.compute.v1.ISetDeletionProtectionInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetDeletionProtectionInstanceRequest|null|undefined, + {}|null|undefined>): void; + setDeletionProtection( + request: protos.google.cloud.compute.v1.ISetDeletionProtectionInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetDeletionProtectionInstanceRequest|null|undefined, + {}|null|undefined>): void; + setDeletionProtection( + request?: protos.google.cloud.compute.v1.ISetDeletionProtectionInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetDeletionProtectionInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetDeletionProtectionInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setDeletionProtection(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the auto-delete flag for a disk attached to an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {boolean} request.autoDelete + * Whether to auto-delete the disk when the instance is deleted. + * @param {string} request.deviceName + * The device name of the disk to modify. Make a get() request on the instance to view currently attached disks and device names. + * @param {string} request.instance + * The instance name for this request. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.set_disk_auto_delete.js + * region_tag:compute_v1_generated_Instances_SetDiskAutoDelete_async + */ + setDiskAutoDelete( + request?: protos.google.cloud.compute.v1.ISetDiskAutoDeleteInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setDiskAutoDelete( + request: protos.google.cloud.compute.v1.ISetDiskAutoDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetDiskAutoDeleteInstanceRequest|null|undefined, + {}|null|undefined>): void; + setDiskAutoDelete( + request: protos.google.cloud.compute.v1.ISetDiskAutoDeleteInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetDiskAutoDeleteInstanceRequest|null|undefined, + {}|null|undefined>): void; + setDiskAutoDelete( + request?: protos.google.cloud.compute.v1.ISetDiskAutoDeleteInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetDiskAutoDeleteInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetDiskAutoDeleteInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.setDiskAutoDelete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @param {google.cloud.compute.v1.ZoneSetPolicyRequest} request.zoneSetPolicyRequestResource + * The body resource for this request + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instances.set_iam_policy.js + * region_tag:compute_v1_generated_Instances_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyInstanceRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyInstanceRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyInstanceRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyInstanceRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Sets labels on an instance. To learn more about labels, read the Labeling Resources documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance scoping this request. + * @param {google.cloud.compute.v1.InstancesSetLabelsRequest} request.instancesSetLabelsRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.set_labels.js + * region_tag:compute_v1_generated_Instances_SetLabels_async + */ + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsInstanceRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsInstanceRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.setLabels(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes the number and/or type of accelerator for a stopped instance to the values specified in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance scoping this request. + * @param {google.cloud.compute.v1.InstancesSetMachineResourcesRequest} request.instancesSetMachineResourcesRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.set_machine_resources.js + * region_tag:compute_v1_generated_Instances_SetMachineResources_async + */ + setMachineResources( + request?: protos.google.cloud.compute.v1.ISetMachineResourcesInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setMachineResources( + request: protos.google.cloud.compute.v1.ISetMachineResourcesInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetMachineResourcesInstanceRequest|null|undefined, + {}|null|undefined>): void; + setMachineResources( + request: protos.google.cloud.compute.v1.ISetMachineResourcesInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetMachineResourcesInstanceRequest|null|undefined, + {}|null|undefined>): void; + setMachineResources( + request?: protos.google.cloud.compute.v1.ISetMachineResourcesInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetMachineResourcesInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetMachineResourcesInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.setMachineResources(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes the machine type for a stopped instance to the machine type specified in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance scoping this request. + * @param {google.cloud.compute.v1.InstancesSetMachineTypeRequest} request.instancesSetMachineTypeRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.set_machine_type.js + * region_tag:compute_v1_generated_Instances_SetMachineType_async + */ + setMachineType( + request?: protos.google.cloud.compute.v1.ISetMachineTypeInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setMachineType( + request: protos.google.cloud.compute.v1.ISetMachineTypeInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetMachineTypeInstanceRequest|null|undefined, + {}|null|undefined>): void; + setMachineType( + request: protos.google.cloud.compute.v1.ISetMachineTypeInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetMachineTypeInstanceRequest|null|undefined, + {}|null|undefined>): void; + setMachineType( + request?: protos.google.cloud.compute.v1.ISetMachineTypeInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetMachineTypeInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetMachineTypeInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.setMachineType(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets metadata for the specified instance to the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance scoping this request. + * @param {google.cloud.compute.v1.Metadata} request.metadataResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.set_metadata.js + * region_tag:compute_v1_generated_Instances_SetMetadata_async + */ + setMetadata( + request?: protos.google.cloud.compute.v1.ISetMetadataInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setMetadata( + request: protos.google.cloud.compute.v1.ISetMetadataInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetMetadataInstanceRequest|null|undefined, + {}|null|undefined>): void; + setMetadata( + request: protos.google.cloud.compute.v1.ISetMetadataInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetMetadataInstanceRequest|null|undefined, + {}|null|undefined>): void; + setMetadata( + request?: protos.google.cloud.compute.v1.ISetMetadataInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetMetadataInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetMetadataInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.setMetadata(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes the minimum CPU platform that this instance should use. This method can only be called on a stopped instance. For more information, read Specifying a Minimum CPU Platform. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance scoping this request. + * @param {google.cloud.compute.v1.InstancesSetMinCpuPlatformRequest} request.instancesSetMinCpuPlatformRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.set_min_cpu_platform.js + * region_tag:compute_v1_generated_Instances_SetMinCpuPlatform_async + */ + setMinCpuPlatform( + request?: protos.google.cloud.compute.v1.ISetMinCpuPlatformInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setMinCpuPlatform( + request: protos.google.cloud.compute.v1.ISetMinCpuPlatformInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetMinCpuPlatformInstanceRequest|null|undefined, + {}|null|undefined>): void; + setMinCpuPlatform( + request: protos.google.cloud.compute.v1.ISetMinCpuPlatformInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetMinCpuPlatformInstanceRequest|null|undefined, + {}|null|undefined>): void; + setMinCpuPlatform( + request?: protos.google.cloud.compute.v1.ISetMinCpuPlatformInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetMinCpuPlatformInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetMinCpuPlatformInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.setMinCpuPlatform(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets name of an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * The instance name for this request. + * @param {google.cloud.compute.v1.InstancesSetNameRequest} request.instancesSetNameRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.set_name.js + * region_tag:compute_v1_generated_Instances_SetName_async + */ + setName( + request?: protos.google.cloud.compute.v1.ISetNameInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setName( + request: protos.google.cloud.compute.v1.ISetNameInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetNameInstanceRequest|null|undefined, + {}|null|undefined>): void; + setName( + request: protos.google.cloud.compute.v1.ISetNameInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetNameInstanceRequest|null|undefined, + {}|null|undefined>): void; + setName( + request?: protos.google.cloud.compute.v1.ISetNameInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetNameInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetNameInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.setName(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets an instance's scheduling options. You can only call this method on a stopped instance, that is, a VM instance that is in a `TERMINATED` state. See Instance Life Cycle for more information on the possible instance states. For more information about setting scheduling options for a VM, see Set VM host maintenance policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Instance name for this request. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.Scheduling} request.schedulingResource + * The body resource for this request + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.set_scheduling.js + * region_tag:compute_v1_generated_Instances_SetScheduling_async + */ + setScheduling( + request?: protos.google.cloud.compute.v1.ISetSchedulingInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setScheduling( + request: protos.google.cloud.compute.v1.ISetSchedulingInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSchedulingInstanceRequest|null|undefined, + {}|null|undefined>): void; + setScheduling( + request: protos.google.cloud.compute.v1.ISetSchedulingInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSchedulingInstanceRequest|null|undefined, + {}|null|undefined>): void; + setScheduling( + request?: protos.google.cloud.compute.v1.ISetSchedulingInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSchedulingInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSchedulingInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.setScheduling(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the service account on the instance. For more information, read Changing the service account and access scopes for an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance resource to start. + * @param {google.cloud.compute.v1.InstancesSetServiceAccountRequest} request.instancesSetServiceAccountRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.set_service_account.js + * region_tag:compute_v1_generated_Instances_SetServiceAccount_async + */ + setServiceAccount( + request?: protos.google.cloud.compute.v1.ISetServiceAccountInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setServiceAccount( + request: protos.google.cloud.compute.v1.ISetServiceAccountInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetServiceAccountInstanceRequest|null|undefined, + {}|null|undefined>): void; + setServiceAccount( + request: protos.google.cloud.compute.v1.ISetServiceAccountInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetServiceAccountInstanceRequest|null|undefined, + {}|null|undefined>): void; + setServiceAccount( + request?: protos.google.cloud.compute.v1.ISetServiceAccountInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetServiceAccountInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetServiceAccountInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.setServiceAccount(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the Shielded Instance integrity policy for an instance. You can only use this method on a running instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name or id of the instance scoping this request. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.ShieldedInstanceIntegrityPolicy} request.shieldedInstanceIntegrityPolicyResource + * The body resource for this request + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.set_shielded_instance_integrity_policy.js + * region_tag:compute_v1_generated_Instances_SetShieldedInstanceIntegrityPolicy_async + */ + setShieldedInstanceIntegrityPolicy( + request?: protos.google.cloud.compute.v1.ISetShieldedInstanceIntegrityPolicyInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setShieldedInstanceIntegrityPolicy( + request: protos.google.cloud.compute.v1.ISetShieldedInstanceIntegrityPolicyInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetShieldedInstanceIntegrityPolicyInstanceRequest|null|undefined, + {}|null|undefined>): void; + setShieldedInstanceIntegrityPolicy( + request: protos.google.cloud.compute.v1.ISetShieldedInstanceIntegrityPolicyInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetShieldedInstanceIntegrityPolicyInstanceRequest|null|undefined, + {}|null|undefined>): void; + setShieldedInstanceIntegrityPolicy( + request?: protos.google.cloud.compute.v1.ISetShieldedInstanceIntegrityPolicyInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetShieldedInstanceIntegrityPolicyInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetShieldedInstanceIntegrityPolicyInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.setShieldedInstanceIntegrityPolicy(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets network tags for the specified instance to the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance scoping this request. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.Tags} request.tagsResource + * The body resource for this request + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.set_tags.js + * region_tag:compute_v1_generated_Instances_SetTags_async + */ + setTags( + request?: protos.google.cloud.compute.v1.ISetTagsInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setTags( + request: protos.google.cloud.compute.v1.ISetTagsInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTagsInstanceRequest|null|undefined, + {}|null|undefined>): void; + setTags( + request: protos.google.cloud.compute.v1.ISetTagsInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTagsInstanceRequest|null|undefined, + {}|null|undefined>): void; + setTags( + request?: protos.google.cloud.compute.v1.ISetTagsInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTagsInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTagsInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.setTags(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Simulates a host maintenance event on a VM. For more information, see Simulate a host maintenance event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance scoping this request. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.simulate_maintenance_event.js + * region_tag:compute_v1_generated_Instances_SimulateMaintenanceEvent_async + */ + simulateMaintenanceEvent( + request?: protos.google.cloud.compute.v1.ISimulateMaintenanceEventInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + simulateMaintenanceEvent( + request: protos.google.cloud.compute.v1.ISimulateMaintenanceEventInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISimulateMaintenanceEventInstanceRequest|null|undefined, + {}|null|undefined>): void; + simulateMaintenanceEvent( + request: protos.google.cloud.compute.v1.ISimulateMaintenanceEventInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISimulateMaintenanceEventInstanceRequest|null|undefined, + {}|null|undefined>): void; + simulateMaintenanceEvent( + request?: protos.google.cloud.compute.v1.ISimulateMaintenanceEventInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISimulateMaintenanceEventInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISimulateMaintenanceEventInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.simulateMaintenanceEvent(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance resource to start. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.start.js + * region_tag:compute_v1_generated_Instances_Start_async + */ + start( + request?: protos.google.cloud.compute.v1.IStartInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + start( + request: protos.google.cloud.compute.v1.IStartInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IStartInstanceRequest|null|undefined, + {}|null|undefined>): void; + start( + request: protos.google.cloud.compute.v1.IStartInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IStartInstanceRequest|null|undefined, + {}|null|undefined>): void; + start( + request?: protos.google.cloud.compute.v1.IStartInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IStartInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IStartInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.start(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance resource to start. + * @param {google.cloud.compute.v1.InstancesStartWithEncryptionKeyRequest} request.instancesStartWithEncryptionKeyRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.start_with_encryption_key.js + * region_tag:compute_v1_generated_Instances_StartWithEncryptionKey_async + */ + startWithEncryptionKey( + request?: protos.google.cloud.compute.v1.IStartWithEncryptionKeyInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + startWithEncryptionKey( + request: protos.google.cloud.compute.v1.IStartWithEncryptionKeyInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IStartWithEncryptionKeyInstanceRequest|null|undefined, + {}|null|undefined>): void; + startWithEncryptionKey( + request: protos.google.cloud.compute.v1.IStartWithEncryptionKeyInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IStartWithEncryptionKeyInstanceRequest|null|undefined, + {}|null|undefined>): void; + startWithEncryptionKey( + request?: protos.google.cloud.compute.v1.IStartWithEncryptionKeyInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IStartWithEncryptionKeyInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IStartWithEncryptionKeyInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.startWithEncryptionKey(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. Stopped instances do not incur VM usage charges while they are stopped. However, resources that the VM is using, such as persistent disks and static IP addresses, will continue to be charged until they are deleted. For more information, see Stopping an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {boolean} request.discardLocalSsd + * If true, discard the contents of any attached localSSD partitions. Default value is false. + * @param {string} request.instance + * Name of the instance resource to stop. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.stop.js + * region_tag:compute_v1_generated_Instances_Stop_async + */ + stop( + request?: protos.google.cloud.compute.v1.IStopInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + stop( + request: protos.google.cloud.compute.v1.IStopInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IStopInstanceRequest|null|undefined, + {}|null|undefined>): void; + stop( + request: protos.google.cloud.compute.v1.IStopInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IStopInstanceRequest|null|undefined, + {}|null|undefined>): void; + stop( + request?: protos.google.cloud.compute.v1.IStopInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IStopInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IStopInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.stop(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * This method suspends a running instance, saving its state to persistent storage, and allows you to resume the instance at a later time. Suspended instances have no compute costs (cores or RAM), and incur only storage charges for the saved VM memory and localSSD data. Any charged resources the virtual machine was using, such as persistent disks and static IP addresses, will continue to be charged while the instance is suspended. For more information, see Suspending and resuming an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {boolean} request.discardLocalSsd + * If true, discard the contents of any attached localSSD partitions. Default value is false. + * @param {string} request.instance + * Name of the instance resource to suspend. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.suspend.js + * region_tag:compute_v1_generated_Instances_Suspend_async + */ + suspend( + request?: protos.google.cloud.compute.v1.ISuspendInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + suspend( + request: protos.google.cloud.compute.v1.ISuspendInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISuspendInstanceRequest|null|undefined, + {}|null|undefined>): void; + suspend( + request: protos.google.cloud.compute.v1.ISuspendInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISuspendInstanceRequest|null|undefined, + {}|null|undefined>): void; + suspend( + request?: protos.google.cloud.compute.v1.ISuspendInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISuspendInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISuspendInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.suspend(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/instances.test_iam_permissions.js + * region_tag:compute_v1_generated_Instances_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsInstanceRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsInstanceRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsInstanceRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsInstanceRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } +/** + * Updates an instance only if the necessary resources are available. This method can update only a specific set of instance properties. See Updating a running instance for a list of updatable instance properties. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name of the instance resource to update. + * @param {google.cloud.compute.v1.Instance} request.instanceResource + * The body resource for this request + * @param {string} request.minimalAction + * Specifies the action to take when updating an instance even if the updated properties do not require it. If not specified, then Compute Engine acts based on the minimum action that the updated properties require. + * Check the MinimalAction enum for the list of possible values. + * @param {string} request.mostDisruptiveAllowedAction + * Specifies the most disruptive action that can be taken on the instance as part of the update. Compute Engine returns an error if the instance properties require a more disruptive action as part of the instance update. Valid options from lowest to highest are NO_EFFECT, REFRESH, and RESTART. + * Check the MostDisruptiveAllowedAction enum for the list of possible values. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.update.js + * region_tag:compute_v1_generated_Instances_Update_async + */ + update( + request?: protos.google.cloud.compute.v1.IUpdateInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + update( + request: protos.google.cloud.compute.v1.IUpdateInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateInstanceRequest|null|undefined, + {}|null|undefined>): void; + update( + request: protos.google.cloud.compute.v1.IUpdateInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateInstanceRequest|null|undefined, + {}|null|undefined>): void; + update( + request?: protos.google.cloud.compute.v1.IUpdateInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.update(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified access config from an instance's network interface with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.AccessConfig} request.accessConfigResource + * The body resource for this request + * @param {string} request.instance + * The instance name for this request. + * @param {string} request.networkInterface + * The name of the network interface where the access config is attached. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.update_access_config.js + * region_tag:compute_v1_generated_Instances_UpdateAccessConfig_async + */ + updateAccessConfig( + request?: protos.google.cloud.compute.v1.IUpdateAccessConfigInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + updateAccessConfig( + request: protos.google.cloud.compute.v1.IUpdateAccessConfigInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateAccessConfigInstanceRequest|null|undefined, + {}|null|undefined>): void; + updateAccessConfig( + request: protos.google.cloud.compute.v1.IUpdateAccessConfigInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateAccessConfigInstanceRequest|null|undefined, + {}|null|undefined>): void; + updateAccessConfig( + request?: protos.google.cloud.compute.v1.IUpdateAccessConfigInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateAccessConfigInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateAccessConfigInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateAccessConfig(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the Display config for a VM instance. You can only use this method on a stopped VM instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.DisplayDevice} request.displayDeviceResource + * The body resource for this request + * @param {string} request.instance + * Name of the instance scoping this request. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.update_display_device.js + * region_tag:compute_v1_generated_Instances_UpdateDisplayDevice_async + */ + updateDisplayDevice( + request?: protos.google.cloud.compute.v1.IUpdateDisplayDeviceInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + updateDisplayDevice( + request: protos.google.cloud.compute.v1.IUpdateDisplayDeviceInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateDisplayDeviceInstanceRequest|null|undefined, + {}|null|undefined>): void; + updateDisplayDevice( + request: protos.google.cloud.compute.v1.IUpdateDisplayDeviceInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateDisplayDeviceInstanceRequest|null|undefined, + {}|null|undefined>): void; + updateDisplayDevice( + request?: protos.google.cloud.compute.v1.IUpdateDisplayDeviceInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateDisplayDeviceInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateDisplayDeviceInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateDisplayDevice(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates an instance's network interface. This method can only update an interface's alias IP range and attached network. See Modifying alias IP ranges for an existing instance for instructions on changing alias IP ranges. See Migrating a VM between networks for instructions on migrating an interface. This method follows PATCH semantics. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * The instance name for this request. + * @param {string} request.networkInterface + * The name of the network interface to update. + * @param {google.cloud.compute.v1.NetworkInterface} request.networkInterfaceResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.update_network_interface.js + * region_tag:compute_v1_generated_Instances_UpdateNetworkInterface_async + */ + updateNetworkInterface( + request?: protos.google.cloud.compute.v1.IUpdateNetworkInterfaceInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + updateNetworkInterface( + request: protos.google.cloud.compute.v1.IUpdateNetworkInterfaceInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateNetworkInterfaceInstanceRequest|null|undefined, + {}|null|undefined>): void; + updateNetworkInterface( + request: protos.google.cloud.compute.v1.IUpdateNetworkInterfaceInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateNetworkInterfaceInstanceRequest|null|undefined, + {}|null|undefined>): void; + updateNetworkInterface( + request?: protos.google.cloud.compute.v1.IUpdateNetworkInterfaceInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateNetworkInterfaceInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateNetworkInterfaceInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateNetworkInterface(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the Shielded Instance config for an instance. You can only use this method on a stopped instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Name or id of the instance scoping this request. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.ShieldedInstanceConfig} request.shieldedInstanceConfigResource + * The body resource for this request + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/instances.update_shielded_instance_config.js + * region_tag:compute_v1_generated_Instances_UpdateShieldedInstanceConfig_async + */ + updateShieldedInstanceConfig( + request?: protos.google.cloud.compute.v1.IUpdateShieldedInstanceConfigInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + updateShieldedInstanceConfig( + request: protos.google.cloud.compute.v1.IUpdateShieldedInstanceConfigInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateShieldedInstanceConfigInstanceRequest|null|undefined, + {}|null|undefined>): void; + updateShieldedInstanceConfig( + request: protos.google.cloud.compute.v1.IUpdateShieldedInstanceConfigInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateShieldedInstanceConfigInstanceRequest|null|undefined, + {}|null|undefined>): void; + updateShieldedInstanceConfig( + request?: protos.google.cloud.compute.v1.IUpdateShieldedInstanceConfigInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateShieldedInstanceConfigInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateShieldedInstanceConfigInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateShieldedInstanceConfig(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves an aggregated list of all of the instances in your project across all regions and zones. The performance of this method degrades when a filter is specified on a project that has a very large number of instances. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.InstancesScopedList | InstancesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/instances.aggregated_list.js + * region_tag:compute_v1_generated_Instances_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListInstancesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IInstancesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IInstancesScopedList]>; + } + /** + * Retrieves the list of instances contained within the specified zone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListInstancesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstance[], + protos.google.cloud.compute.v1.IListInstancesRequest|null, + protos.google.cloud.compute.v1.IInstanceList + ]>; + list( + request: protos.google.cloud.compute.v1.IListInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInstancesRequest, + protos.google.cloud.compute.v1.IInstanceList|null|undefined, + protos.google.cloud.compute.v1.IInstance>): void; + list( + request: protos.google.cloud.compute.v1.IListInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInstancesRequest, + protos.google.cloud.compute.v1.IInstanceList|null|undefined, + protos.google.cloud.compute.v1.IInstance>): void; + list( + request?: protos.google.cloud.compute.v1.IListInstancesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListInstancesRequest, + protos.google.cloud.compute.v1.IInstanceList|null|undefined, + protos.google.cloud.compute.v1.IInstance>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListInstancesRequest, + protos.google.cloud.compute.v1.IInstanceList|null|undefined, + protos.google.cloud.compute.v1.IInstance>): + Promise<[ + protos.google.cloud.compute.v1.IInstance[], + protos.google.cloud.compute.v1.IListInstancesRequest|null, + protos.google.cloud.compute.v1.IInstanceList + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListInstancesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.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 + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/instances.list.js + * region_tag:compute_v1_generated_Instances_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListInstancesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Retrieves a list of resources that refer to the VM instance specified in the request. For example, if the VM instance is part of a managed or unmanaged instance group, the referrers list includes the instance group. For more information, read Viewing referrers to VM instances. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instance + * Name of the target instance scoping this request, or '-' if the request should span over all instances in the container. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.Reference | Reference}. + * 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 `listReferrersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listReferrers( + request?: protos.google.cloud.compute.v1.IListReferrersInstancesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IReference[], + protos.google.cloud.compute.v1.IListReferrersInstancesRequest|null, + protos.google.cloud.compute.v1.IInstanceListReferrers + ]>; + listReferrers( + request: protos.google.cloud.compute.v1.IListReferrersInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListReferrersInstancesRequest, + protos.google.cloud.compute.v1.IInstanceListReferrers|null|undefined, + protos.google.cloud.compute.v1.IReference>): void; + listReferrers( + request: protos.google.cloud.compute.v1.IListReferrersInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListReferrersInstancesRequest, + protos.google.cloud.compute.v1.IInstanceListReferrers|null|undefined, + protos.google.cloud.compute.v1.IReference>): void; + listReferrers( + request?: protos.google.cloud.compute.v1.IListReferrersInstancesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListReferrersInstancesRequest, + protos.google.cloud.compute.v1.IInstanceListReferrers|null|undefined, + protos.google.cloud.compute.v1.IReference>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListReferrersInstancesRequest, + protos.google.cloud.compute.v1.IInstanceListReferrers|null|undefined, + protos.google.cloud.compute.v1.IReference>): + Promise<[ + protos.google.cloud.compute.v1.IReference[], + protos.google.cloud.compute.v1.IListReferrersInstancesRequest|null, + protos.google.cloud.compute.v1.IInstanceListReferrers + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + this.initialize(); + return this.innerApiCalls.listReferrers(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instance + * Name of the target instance scoping this request, or '-' if the request should span over all instances in the container. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.Reference | Reference} 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 `listReferrersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listReferrersStream( + request?: protos.google.cloud.compute.v1.IListReferrersInstancesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + const defaultCallSettings = this._defaults['listReferrers']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferrers.createStream( + this.innerApiCalls.listReferrers as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listReferrers`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instance + * Name of the target instance scoping this request, or '-' if the request should span over all instances in the container. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Reference | Reference}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/instances.list_referrers.js + * region_tag:compute_v1_generated_Instances_ListReferrers_async + */ + listReferrersAsync( + request?: protos.google.cloud.compute.v1.IListReferrersInstancesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'instance': request.instance ?? '', + }); + const defaultCallSettings = this._defaults['listReferrers']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferrers.asyncIterate( + this.innerApiCalls['listReferrers'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/instances_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/instances_client_config.json new file mode 100644 index 00000000000..c02f2609fec --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/instances_client_config.json @@ -0,0 +1,210 @@ +{ + "interfaces": { + "google.cloud.compute.v1.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": { + "AddAccessConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AddResourcePolicies": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AttachDisk": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "BulkInsert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteAccessConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DetachDisk": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetEffectiveFirewalls": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetGuestAttributes": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetScreenshot": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetSerialPortOutput": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetShieldedInstanceIdentity": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListReferrers": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveResourcePolicies": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Reset": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Resume": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SendDiagnosticInterrupt": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetDeletionProtection": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetDiskAutoDelete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetLabels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetMachineResources": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetMachineType": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetMetadata": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetMinCpuPlatform": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetName": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetScheduling": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetServiceAccount": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetShieldedInstanceIntegrityPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetTags": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SimulateMaintenanceEvent": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Start": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StartWithEncryptionKey": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Stop": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Suspend": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Update": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateAccessConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateDisplayDevice": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateNetworkInterface": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateShieldedInstanceConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/instances_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/instances_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/instances_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_attachments_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_attachments_client.ts new file mode 100644 index 00000000000..56c8c9aacde --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_attachments_client.ts @@ -0,0 +1,1021 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/interconnect_attachments_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './interconnect_attachments_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The InterconnectAttachments API. + * @class + * @memberof v1 + */ +export class InterconnectAttachmentsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + interconnectAttachmentsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of InterconnectAttachmentsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new InterconnectAttachmentsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof InterconnectAttachmentsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.InterconnectAttachments', 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.interconnectAttachmentsStub) { + return this.interconnectAttachmentsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.InterconnectAttachments. + this.interconnectAttachmentsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.InterconnectAttachments') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.InterconnectAttachments, + 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 interconnectAttachmentsStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'list', 'patch', 'setLabels']; + for (const methodName of interconnectAttachmentsStubMethods) { + const callPromise = this.interconnectAttachmentsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.interconnectAttachmentsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified interconnect attachment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.interconnectAttachment + * Name of the interconnect attachment to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/interconnect_attachments.delete.js + * region_tag:compute_v1_generated_InterconnectAttachments_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteInterconnectAttachmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteInterconnectAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteInterconnectAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteInterconnectAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'interconnect_attachment': request.interconnectAttachment ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified interconnect attachment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.interconnectAttachment + * Name of the interconnect attachment to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @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.compute.v1.InterconnectAttachment | InterconnectAttachment}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/interconnect_attachments.get.js + * region_tag:compute_v1_generated_InterconnectAttachments_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetInterconnectAttachmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInterconnectAttachment, + protos.google.cloud.compute.v1.IGetInterconnectAttachmentRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetInterconnectAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IInterconnectAttachment, + protos.google.cloud.compute.v1.IGetInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetInterconnectAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IInterconnectAttachment, + protos.google.cloud.compute.v1.IGetInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetInterconnectAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IInterconnectAttachment, + protos.google.cloud.compute.v1.IGetInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IInterconnectAttachment, + protos.google.cloud.compute.v1.IGetInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IInterconnectAttachment, + protos.google.cloud.compute.v1.IGetInterconnectAttachmentRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'interconnect_attachment': request.interconnectAttachment ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates an InterconnectAttachment in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.InterconnectAttachment} request.interconnectAttachmentResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {boolean} request.validateOnly + * If true, the request will not be committed. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/interconnect_attachments.insert.js + * region_tag:compute_v1_generated_InterconnectAttachments_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertInterconnectAttachmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertInterconnectAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertInterconnectAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertInterconnectAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified interconnect attachment with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.interconnectAttachment + * Name of the interconnect attachment to patch. + * @param {google.cloud.compute.v1.InterconnectAttachment} request.interconnectAttachmentResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/interconnect_attachments.patch.js + * region_tag:compute_v1_generated_InterconnectAttachments_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchInterconnectAttachmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchInterconnectAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchInterconnectAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchInterconnectAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'interconnect_attachment': request.interconnectAttachment ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the labels on an InterconnectAttachment. To learn more about labels, read the Labeling Resources documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The region for this request. + * @param {google.cloud.compute.v1.RegionSetLabelsRequest} request.regionSetLabelsRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.resource + * Name or id of the resource for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/interconnect_attachments.set_labels.js + * region_tag:compute_v1_generated_InterconnectAttachments_SetLabels_async + */ + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsInterconnectAttachmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsInterconnectAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsInterconnectAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsInterconnectAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsInterconnectAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setLabels(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves an aggregated list of interconnect attachments. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.InterconnectAttachmentsScopedList | InterconnectAttachmentsScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/interconnect_attachments.aggregated_list.js + * region_tag:compute_v1_generated_InterconnectAttachments_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListInterconnectAttachmentsRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IInterconnectAttachmentsScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IInterconnectAttachmentsScopedList]>; + } + /** + * Retrieves the list of interconnect attachments contained within the specified region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.InterconnectAttachment | InterconnectAttachment}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListInterconnectAttachmentsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInterconnectAttachment[], + protos.google.cloud.compute.v1.IListInterconnectAttachmentsRequest|null, + protos.google.cloud.compute.v1.IInterconnectAttachmentList + ]>; + list( + request: protos.google.cloud.compute.v1.IListInterconnectAttachmentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInterconnectAttachmentsRequest, + protos.google.cloud.compute.v1.IInterconnectAttachmentList|null|undefined, + protos.google.cloud.compute.v1.IInterconnectAttachment>): void; + list( + request: protos.google.cloud.compute.v1.IListInterconnectAttachmentsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInterconnectAttachmentsRequest, + protos.google.cloud.compute.v1.IInterconnectAttachmentList|null|undefined, + protos.google.cloud.compute.v1.IInterconnectAttachment>): void; + list( + request?: protos.google.cloud.compute.v1.IListInterconnectAttachmentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListInterconnectAttachmentsRequest, + protos.google.cloud.compute.v1.IInterconnectAttachmentList|null|undefined, + protos.google.cloud.compute.v1.IInterconnectAttachment>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListInterconnectAttachmentsRequest, + protos.google.cloud.compute.v1.IInterconnectAttachmentList|null|undefined, + protos.google.cloud.compute.v1.IInterconnectAttachment>): + Promise<[ + protos.google.cloud.compute.v1.IInterconnectAttachment[], + protos.google.cloud.compute.v1.IListInterconnectAttachmentsRequest|null, + protos.google.cloud.compute.v1.IInterconnectAttachmentList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.InterconnectAttachment | InterconnectAttachment} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListInterconnectAttachmentsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.InterconnectAttachment | InterconnectAttachment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/interconnect_attachments.list.js + * region_tag:compute_v1_generated_InterconnectAttachments_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListInterconnectAttachmentsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.interconnectAttachmentsStub && !this._terminated) { + return this.interconnectAttachmentsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_attachments_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_attachments_client_config.json new file mode 100644 index 00000000000..1a7ef9708f3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_attachments_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.compute.v1.InterconnectAttachments": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetLabels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_attachments_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_attachments_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_attachments_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_locations_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_locations_client.ts new file mode 100644 index 00000000000..8e1dea2ad7c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_locations_client.ts @@ -0,0 +1,583 @@ +// Copyright 2023 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/interconnect_locations_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './interconnect_locations_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The InterconnectLocations API. + * @class + * @memberof v1 + */ +export class InterconnectLocationsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + interconnectLocationsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of InterconnectLocationsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new InterconnectLocationsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof InterconnectLocationsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.InterconnectLocations', 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.interconnectLocationsStub) { + return this.interconnectLocationsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.InterconnectLocations. + this.interconnectLocationsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.InterconnectLocations') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.InterconnectLocations, + 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 interconnectLocationsStubMethods = + ['get', 'list']; + for (const methodName of interconnectLocationsStubMethods) { + const callPromise = this.interconnectLocationsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.interconnectLocationsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute.readonly', + 'https://www.googleapis.com/auth/compute', + '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 -- + // ------------------- +/** + * Returns the details for the specified interconnect location. Gets a list of available interconnect locations by making a list() request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.interconnectLocation + * Name of the interconnect location to return. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.InterconnectLocation | InterconnectLocation}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/interconnect_locations.get.js + * region_tag:compute_v1_generated_InterconnectLocations_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetInterconnectLocationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInterconnectLocation, + protos.google.cloud.compute.v1.IGetInterconnectLocationRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetInterconnectLocationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IInterconnectLocation, + protos.google.cloud.compute.v1.IGetInterconnectLocationRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetInterconnectLocationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IInterconnectLocation, + protos.google.cloud.compute.v1.IGetInterconnectLocationRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetInterconnectLocationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IInterconnectLocation, + protos.google.cloud.compute.v1.IGetInterconnectLocationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IInterconnectLocation, + protos.google.cloud.compute.v1.IGetInterconnectLocationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IInterconnectLocation, + protos.google.cloud.compute.v1.IGetInterconnectLocationRequest|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({ + 'project': request.project ?? '', + 'interconnect_location': request.interconnectLocation ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } + + /** + * Retrieves the list of interconnect locations available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.InterconnectLocation | InterconnectLocation}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListInterconnectLocationsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInterconnectLocation[], + protos.google.cloud.compute.v1.IListInterconnectLocationsRequest|null, + protos.google.cloud.compute.v1.IInterconnectLocationList + ]>; + list( + request: protos.google.cloud.compute.v1.IListInterconnectLocationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInterconnectLocationsRequest, + protos.google.cloud.compute.v1.IInterconnectLocationList|null|undefined, + protos.google.cloud.compute.v1.IInterconnectLocation>): void; + list( + request: protos.google.cloud.compute.v1.IListInterconnectLocationsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInterconnectLocationsRequest, + protos.google.cloud.compute.v1.IInterconnectLocationList|null|undefined, + protos.google.cloud.compute.v1.IInterconnectLocation>): void; + list( + request?: protos.google.cloud.compute.v1.IListInterconnectLocationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListInterconnectLocationsRequest, + protos.google.cloud.compute.v1.IInterconnectLocationList|null|undefined, + protos.google.cloud.compute.v1.IInterconnectLocation>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListInterconnectLocationsRequest, + protos.google.cloud.compute.v1.IInterconnectLocationList|null|undefined, + protos.google.cloud.compute.v1.IInterconnectLocation>): + Promise<[ + protos.google.cloud.compute.v1.IInterconnectLocation[], + protos.google.cloud.compute.v1.IListInterconnectLocationsRequest|null, + protos.google.cloud.compute.v1.IInterconnectLocationList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.InterconnectLocation | InterconnectLocation} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListInterconnectLocationsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.InterconnectLocation | InterconnectLocation}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/interconnect_locations.list.js + * region_tag:compute_v1_generated_InterconnectLocations_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListInterconnectLocationsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.interconnectLocationsStub && !this._terminated) { + return this.interconnectLocationsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_locations_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_locations_client_config.json new file mode 100644 index 00000000000..c9772ce335d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_locations_client_config.json @@ -0,0 +1,34 @@ +{ + "interfaces": { + "google.cloud.compute.v1.InterconnectLocations": { + "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": { + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_locations_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_locations_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnect_locations_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnects_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnects_client.ts new file mode 100644 index 00000000000..b818b56d7d6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnects_client.ts @@ -0,0 +1,1009 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/interconnects_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './interconnects_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Interconnects API. + * @class + * @memberof v1 + */ +export class InterconnectsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + interconnectsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of InterconnectsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new InterconnectsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof InterconnectsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.Interconnects', 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.interconnectsStub) { + return this.interconnectsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.Interconnects. + this.interconnectsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Interconnects') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.Interconnects, + 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 interconnectsStubMethods = + ['delete', 'get', 'getDiagnostics', 'insert', 'list', 'patch', 'setLabels']; + for (const methodName of interconnectsStubMethods) { + const callPromise = this.interconnectsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.interconnectsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified Interconnect. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.interconnect + * Name of the interconnect to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/interconnects.delete.js + * region_tag:compute_v1_generated_Interconnects_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteInterconnectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteInterconnectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInterconnectRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteInterconnectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInterconnectRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteInterconnectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInterconnectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInterconnectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'interconnect': request.interconnect ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified Interconnect. Get a list of available Interconnects by making a list() request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.interconnect + * Name of the interconnect to return. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.Interconnect | Interconnect}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/interconnects.get.js + * region_tag:compute_v1_generated_Interconnects_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetInterconnectRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInterconnect, + protos.google.cloud.compute.v1.IGetInterconnectRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetInterconnectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IInterconnect, + protos.google.cloud.compute.v1.IGetInterconnectRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetInterconnectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IInterconnect, + protos.google.cloud.compute.v1.IGetInterconnectRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetInterconnectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IInterconnect, + protos.google.cloud.compute.v1.IGetInterconnectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IInterconnect, + protos.google.cloud.compute.v1.IGetInterconnectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IInterconnect, + protos.google.cloud.compute.v1.IGetInterconnectRequest|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({ + 'project': request.project ?? '', + 'interconnect': request.interconnect ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Returns the interconnectDiagnostics for the specified Interconnect. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.interconnect + * Name of the interconnect resource to query. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.InterconnectsGetDiagnosticsResponse | InterconnectsGetDiagnosticsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/interconnects.get_diagnostics.js + * region_tag:compute_v1_generated_Interconnects_GetDiagnostics_async + */ + getDiagnostics( + request?: protos.google.cloud.compute.v1.IGetDiagnosticsInterconnectRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInterconnectsGetDiagnosticsResponse, + protos.google.cloud.compute.v1.IGetDiagnosticsInterconnectRequest|undefined, {}|undefined + ]>; + getDiagnostics( + request: protos.google.cloud.compute.v1.IGetDiagnosticsInterconnectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IInterconnectsGetDiagnosticsResponse, + protos.google.cloud.compute.v1.IGetDiagnosticsInterconnectRequest|null|undefined, + {}|null|undefined>): void; + getDiagnostics( + request: protos.google.cloud.compute.v1.IGetDiagnosticsInterconnectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IInterconnectsGetDiagnosticsResponse, + protos.google.cloud.compute.v1.IGetDiagnosticsInterconnectRequest|null|undefined, + {}|null|undefined>): void; + getDiagnostics( + request?: protos.google.cloud.compute.v1.IGetDiagnosticsInterconnectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IInterconnectsGetDiagnosticsResponse, + protos.google.cloud.compute.v1.IGetDiagnosticsInterconnectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IInterconnectsGetDiagnosticsResponse, + protos.google.cloud.compute.v1.IGetDiagnosticsInterconnectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IInterconnectsGetDiagnosticsResponse, + protos.google.cloud.compute.v1.IGetDiagnosticsInterconnectRequest|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({ + 'project': request.project ?? '', + 'interconnect': request.interconnect ?? '', + }); + this.initialize(); + return this.innerApiCalls.getDiagnostics(request, options, callback); + } +/** + * Creates an Interconnect in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.Interconnect} request.interconnectResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/interconnects.insert.js + * region_tag:compute_v1_generated_Interconnects_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertInterconnectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertInterconnectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInterconnectRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertInterconnectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInterconnectRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertInterconnectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInterconnectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertInterconnectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified Interconnect with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.interconnect + * Name of the interconnect to update. + * @param {google.cloud.compute.v1.Interconnect} request.interconnectResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/interconnects.patch.js + * region_tag:compute_v1_generated_Interconnects_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchInterconnectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchInterconnectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchInterconnectRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchInterconnectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchInterconnectRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchInterconnectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchInterconnectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchInterconnectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'interconnect': request.interconnect ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the labels on an Interconnect. To learn more about labels, read the Labeling Resources documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalSetLabelsRequest} request.globalSetLabelsRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/interconnects.set_labels.js + * region_tag:compute_v1_generated_Interconnects_SetLabels_async + */ + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsInterconnectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsInterconnectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsInterconnectRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsInterconnectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsInterconnectRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsInterconnectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsInterconnectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsInterconnectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setLabels(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves the list of Interconnects available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Interconnect | Interconnect}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListInterconnectsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInterconnect[], + protos.google.cloud.compute.v1.IListInterconnectsRequest|null, + protos.google.cloud.compute.v1.IInterconnectList + ]>; + list( + request: protos.google.cloud.compute.v1.IListInterconnectsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInterconnectsRequest, + protos.google.cloud.compute.v1.IInterconnectList|null|undefined, + protos.google.cloud.compute.v1.IInterconnect>): void; + list( + request: protos.google.cloud.compute.v1.IListInterconnectsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInterconnectsRequest, + protos.google.cloud.compute.v1.IInterconnectList|null|undefined, + protos.google.cloud.compute.v1.IInterconnect>): void; + list( + request?: protos.google.cloud.compute.v1.IListInterconnectsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListInterconnectsRequest, + protos.google.cloud.compute.v1.IInterconnectList|null|undefined, + protos.google.cloud.compute.v1.IInterconnect>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListInterconnectsRequest, + protos.google.cloud.compute.v1.IInterconnectList|null|undefined, + protos.google.cloud.compute.v1.IInterconnect>): + Promise<[ + protos.google.cloud.compute.v1.IInterconnect[], + protos.google.cloud.compute.v1.IListInterconnectsRequest|null, + protos.google.cloud.compute.v1.IInterconnectList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Interconnect | Interconnect} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListInterconnectsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Interconnect | Interconnect}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/interconnects.list.js + * region_tag:compute_v1_generated_Interconnects_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListInterconnectsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.interconnectsStub && !this._terminated) { + return this.interconnectsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnects_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnects_client_config.json new file mode 100644 index 00000000000..ba6f716007b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnects_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.compute.v1.Interconnects": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetDiagnostics": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetLabels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnects_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnects_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/interconnects_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/license_codes_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/license_codes_client.ts new file mode 100644 index 00000000000..b61bcc92744 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/license_codes_client.ts @@ -0,0 +1,459 @@ +// Copyright 2023 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} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/license_codes_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './license_codes_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The LicenseCodes API. + * @class + * @memberof v1 + */ +export class LicenseCodesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + licenseCodesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of LicenseCodesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new LicenseCodesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof LicenseCodesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.LicenseCodes', 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.licenseCodesStub) { + return this.licenseCodesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.LicenseCodes. + this.licenseCodesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.LicenseCodes') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.LicenseCodes, + 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 licenseCodesStubMethods = + ['get', 'testIamPermissions']; + for (const methodName of licenseCodesStubMethods) { + const callPromise = this.licenseCodesStub.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 = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.licenseCodesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute.readonly', + 'https://www.googleapis.com/auth/compute', + '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 -- + // ------------------- +/** + * Return a specified license code. License codes are mirrored across all projects that have permissions to read the License Code. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.licenseCode + * Number corresponding to the License code resource to return. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.LicenseCode | LicenseCode}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/license_codes.get.js + * region_tag:compute_v1_generated_LicenseCodes_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetLicenseCodeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ILicenseCode, + protos.google.cloud.compute.v1.IGetLicenseCodeRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetLicenseCodeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ILicenseCode, + protos.google.cloud.compute.v1.IGetLicenseCodeRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetLicenseCodeRequest, + callback: Callback< + protos.google.cloud.compute.v1.ILicenseCode, + protos.google.cloud.compute.v1.IGetLicenseCodeRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetLicenseCodeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ILicenseCode, + protos.google.cloud.compute.v1.IGetLicenseCodeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ILicenseCode, + protos.google.cloud.compute.v1.IGetLicenseCodeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ILicenseCode, + protos.google.cloud.compute.v1.IGetLicenseCodeRequest|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({ + 'project': request.project ?? '', + 'license_code': request.licenseCode ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/license_codes.test_iam_permissions.js + * region_tag:compute_v1_generated_LicenseCodes_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsLicenseCodeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsLicenseCodeRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsLicenseCodeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsLicenseCodeRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsLicenseCodeRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsLicenseCodeRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsLicenseCodeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsLicenseCodeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsLicenseCodeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsLicenseCodeRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + + /** + * 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.licenseCodesStub && !this._terminated) { + return this.licenseCodesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/license_codes_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/license_codes_client_config.json new file mode 100644 index 00000000000..ba42ff9d357 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/license_codes_client_config.json @@ -0,0 +1,34 @@ +{ + "interfaces": { + "google.cloud.compute.v1.LicenseCodes": { + "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": { + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/license_codes_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/license_codes_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/license_codes_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/licenses_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/licenses_client.ts new file mode 100644 index 00000000000..1a209ef65e3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/licenses_client.ts @@ -0,0 +1,985 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/licenses_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './licenses_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Licenses API. + * @class + * @memberof v1 + */ +export class LicensesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + licensesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of LicensesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new LicensesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof LicensesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.Licenses', 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.licensesStub) { + return this.licensesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.Licenses. + this.licensesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Licenses') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.Licenses, + 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 licensesStubMethods = + ['delete', 'get', 'getIamPolicy', 'insert', 'list', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of licensesStubMethods) { + const callPromise = this.licensesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.licensesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified license. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.license + * Name of the license resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/licenses.delete.js + * region_tag:compute_v1_generated_Licenses_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteLicenseRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteLicenseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteLicenseRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteLicenseRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteLicenseRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteLicenseRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteLicenseRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteLicenseRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'license': request.license ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified License resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.license + * Name of the License resource to return. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.License | License}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/licenses.get.js + * region_tag:compute_v1_generated_Licenses_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetLicenseRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ILicense, + protos.google.cloud.compute.v1.IGetLicenseRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetLicenseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ILicense, + protos.google.cloud.compute.v1.IGetLicenseRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetLicenseRequest, + callback: Callback< + protos.google.cloud.compute.v1.ILicense, + protos.google.cloud.compute.v1.IGetLicenseRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetLicenseRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ILicense, + protos.google.cloud.compute.v1.IGetLicenseRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ILicense, + protos.google.cloud.compute.v1.IGetLicenseRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ILicense, + protos.google.cloud.compute.v1.IGetLicenseRequest|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({ + 'project': request.project ?? '', + 'license': request.license ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/licenses.get_iam_policy.js + * region_tag:compute_v1_generated_Licenses_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyLicenseRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyLicenseRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyLicenseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyLicenseRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyLicenseRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyLicenseRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyLicenseRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyLicenseRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyLicenseRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyLicenseRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Create a License resource in the specified project. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.License} request.licenseResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/licenses.insert.js + * region_tag:compute_v1_generated_Licenses_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertLicenseRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertLicenseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertLicenseRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertLicenseRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertLicenseRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertLicenseRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertLicenseRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertLicenseRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalSetPolicyRequest} request.globalSetPolicyRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/licenses.set_iam_policy.js + * region_tag:compute_v1_generated_Licenses_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyLicenseRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyLicenseRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyLicenseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyLicenseRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyLicenseRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyLicenseRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyLicenseRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyLicenseRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyLicenseRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyLicenseRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/licenses.test_iam_permissions.js + * region_tag:compute_v1_generated_Licenses_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsLicenseRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsLicenseRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsLicenseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsLicenseRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsLicenseRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsLicenseRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsLicenseRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsLicenseRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsLicenseRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsLicenseRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + /** + * Retrieves the list of licenses available in the specified project. This method does not get any licenses that belong to other projects, including licenses attached to publicly-available images, like Debian 9. If you want to get a list of publicly-available licenses, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.License | License}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListLicensesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ILicense[], + protos.google.cloud.compute.v1.IListLicensesRequest|null, + protos.google.cloud.compute.v1.ILicensesListResponse + ]>; + list( + request: protos.google.cloud.compute.v1.IListLicensesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListLicensesRequest, + protos.google.cloud.compute.v1.ILicensesListResponse|null|undefined, + protos.google.cloud.compute.v1.ILicense>): void; + list( + request: protos.google.cloud.compute.v1.IListLicensesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListLicensesRequest, + protos.google.cloud.compute.v1.ILicensesListResponse|null|undefined, + protos.google.cloud.compute.v1.ILicense>): void; + list( + request?: protos.google.cloud.compute.v1.IListLicensesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListLicensesRequest, + protos.google.cloud.compute.v1.ILicensesListResponse|null|undefined, + protos.google.cloud.compute.v1.ILicense>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListLicensesRequest, + protos.google.cloud.compute.v1.ILicensesListResponse|null|undefined, + protos.google.cloud.compute.v1.ILicense>): + Promise<[ + protos.google.cloud.compute.v1.ILicense[], + protos.google.cloud.compute.v1.IListLicensesRequest|null, + protos.google.cloud.compute.v1.ILicensesListResponse + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.License | License} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListLicensesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.License | License}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/licenses.list.js + * region_tag:compute_v1_generated_Licenses_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListLicensesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.licensesStub && !this._terminated) { + return this.licensesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/licenses_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/licenses_client_config.json new file mode 100644 index 00000000000..61162120ec2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/licenses_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.compute.v1.Licenses": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/licenses_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/licenses_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/licenses_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_images_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_images_client.ts new file mode 100644 index 00000000000..2291b78598a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_images_client.ts @@ -0,0 +1,987 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/machine_images_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './machine_images_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The MachineImages API. + * @class + * @memberof v1 + */ +export class MachineImagesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + machineImagesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of MachineImagesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new MachineImagesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof MachineImagesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.MachineImages', 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.machineImagesStub) { + return this.machineImagesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.MachineImages. + this.machineImagesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.MachineImages') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.MachineImages, + 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 machineImagesStubMethods = + ['delete', 'get', 'getIamPolicy', 'insert', 'list', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of machineImagesStubMethods) { + const callPromise = this.machineImagesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.machineImagesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified machine image. Deleting a machine image is permanent and cannot be undone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.machineImage + * The name of the machine image to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/machine_images.delete.js + * region_tag:compute_v1_generated_MachineImages_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteMachineImageRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteMachineImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteMachineImageRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteMachineImageRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteMachineImageRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteMachineImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteMachineImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteMachineImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'machine_image': request.machineImage ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified machine image. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.machineImage + * The name of the machine image. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.MachineImage | MachineImage}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/machine_images.get.js + * region_tag:compute_v1_generated_MachineImages_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetMachineImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IMachineImage, + protos.google.cloud.compute.v1.IGetMachineImageRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetMachineImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IMachineImage, + protos.google.cloud.compute.v1.IGetMachineImageRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetMachineImageRequest, + callback: Callback< + protos.google.cloud.compute.v1.IMachineImage, + protos.google.cloud.compute.v1.IGetMachineImageRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetMachineImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IMachineImage, + protos.google.cloud.compute.v1.IGetMachineImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IMachineImage, + protos.google.cloud.compute.v1.IGetMachineImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IMachineImage, + protos.google.cloud.compute.v1.IGetMachineImageRequest|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({ + 'project': request.project ?? '', + 'machine_image': request.machineImage ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/machine_images.get_iam_policy.js + * region_tag:compute_v1_generated_MachineImages_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyMachineImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyMachineImageRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyMachineImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyMachineImageRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyMachineImageRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyMachineImageRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyMachineImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyMachineImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyMachineImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyMachineImageRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Creates a machine image in the specified project using the data that is included in the request. If you are creating a new machine image to update an existing instance, your new machine image should use the same network or, if applicable, the same subnetwork as the original instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.MachineImage} request.machineImageResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.sourceInstance + * Required. Source instance that is used to create the machine image from. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/machine_images.insert.js + * region_tag:compute_v1_generated_MachineImages_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertMachineImageRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertMachineImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertMachineImageRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertMachineImageRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertMachineImageRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertMachineImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertMachineImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertMachineImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalSetPolicyRequest} request.globalSetPolicyRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/machine_images.set_iam_policy.js + * region_tag:compute_v1_generated_MachineImages_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyMachineImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyMachineImageRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyMachineImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyMachineImageRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyMachineImageRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyMachineImageRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyMachineImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyMachineImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyMachineImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyMachineImageRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/machine_images.test_iam_permissions.js + * region_tag:compute_v1_generated_MachineImages_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsMachineImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsMachineImageRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsMachineImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsMachineImageRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsMachineImageRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsMachineImageRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsMachineImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsMachineImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsMachineImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsMachineImageRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + /** + * Retrieves a list of machine images that are contained within the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.MachineImage | MachineImage}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListMachineImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IMachineImage[], + protos.google.cloud.compute.v1.IListMachineImagesRequest|null, + protos.google.cloud.compute.v1.IMachineImageList + ]>; + list( + request: protos.google.cloud.compute.v1.IListMachineImagesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListMachineImagesRequest, + protos.google.cloud.compute.v1.IMachineImageList|null|undefined, + protos.google.cloud.compute.v1.IMachineImage>): void; + list( + request: protos.google.cloud.compute.v1.IListMachineImagesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListMachineImagesRequest, + protos.google.cloud.compute.v1.IMachineImageList|null|undefined, + protos.google.cloud.compute.v1.IMachineImage>): void; + list( + request?: protos.google.cloud.compute.v1.IListMachineImagesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListMachineImagesRequest, + protos.google.cloud.compute.v1.IMachineImageList|null|undefined, + protos.google.cloud.compute.v1.IMachineImage>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListMachineImagesRequest, + protos.google.cloud.compute.v1.IMachineImageList|null|undefined, + protos.google.cloud.compute.v1.IMachineImage>): + Promise<[ + protos.google.cloud.compute.v1.IMachineImage[], + protos.google.cloud.compute.v1.IListMachineImagesRequest|null, + protos.google.cloud.compute.v1.IMachineImageList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.MachineImage | MachineImage} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListMachineImagesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.MachineImage | MachineImage}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/machine_images.list.js + * region_tag:compute_v1_generated_MachineImages_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListMachineImagesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.machineImagesStub && !this._terminated) { + return this.machineImagesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_images_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_images_client_config.json new file mode 100644 index 00000000000..5af5fa92f33 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_images_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.compute.v1.MachineImages": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_images_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_images_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_images_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_types_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_types_client.ts new file mode 100644 index 00000000000..66d1f3bf16e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_types_client.ts @@ -0,0 +1,653 @@ +// Copyright 2023 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/machine_types_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './machine_types_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The MachineTypes API. + * @class + * @memberof v1 + */ +export class MachineTypesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + machineTypesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of MachineTypesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new MachineTypesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof MachineTypesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.MachineTypes', 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.machineTypesStub) { + return this.machineTypesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.MachineTypes. + this.machineTypesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.MachineTypes') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.MachineTypes, + 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 machineTypesStubMethods = + ['aggregatedList', 'get', 'list']; + for (const methodName of machineTypesStubMethods) { + const callPromise = this.machineTypesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.machineTypesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute.readonly', + 'https://www.googleapis.com/auth/compute', + '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 -- + // ------------------- +/** + * Returns the specified machine type. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.machineType + * Name of the machine type to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.MachineType | MachineType}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/machine_types.get.js + * region_tag:compute_v1_generated_MachineTypes_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetMachineTypeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IMachineType, + protos.google.cloud.compute.v1.IGetMachineTypeRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetMachineTypeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IMachineType, + protos.google.cloud.compute.v1.IGetMachineTypeRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetMachineTypeRequest, + callback: Callback< + protos.google.cloud.compute.v1.IMachineType, + protos.google.cloud.compute.v1.IGetMachineTypeRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetMachineTypeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IMachineType, + protos.google.cloud.compute.v1.IGetMachineTypeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IMachineType, + protos.google.cloud.compute.v1.IGetMachineTypeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IMachineType, + protos.google.cloud.compute.v1.IGetMachineTypeRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'machine_type': request.machineType ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } + + +/** + * Retrieves an aggregated list of machine types. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.MachineTypesScopedList | MachineTypesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/machine_types.aggregated_list.js + * region_tag:compute_v1_generated_MachineTypes_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListMachineTypesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IMachineTypesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IMachineTypesScopedList]>; + } + /** + * Retrieves a list of machine types available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.MachineType | MachineType}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListMachineTypesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IMachineType[], + protos.google.cloud.compute.v1.IListMachineTypesRequest|null, + protos.google.cloud.compute.v1.IMachineTypeList + ]>; + list( + request: protos.google.cloud.compute.v1.IListMachineTypesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListMachineTypesRequest, + protos.google.cloud.compute.v1.IMachineTypeList|null|undefined, + protos.google.cloud.compute.v1.IMachineType>): void; + list( + request: protos.google.cloud.compute.v1.IListMachineTypesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListMachineTypesRequest, + protos.google.cloud.compute.v1.IMachineTypeList|null|undefined, + protos.google.cloud.compute.v1.IMachineType>): void; + list( + request?: protos.google.cloud.compute.v1.IListMachineTypesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListMachineTypesRequest, + protos.google.cloud.compute.v1.IMachineTypeList|null|undefined, + protos.google.cloud.compute.v1.IMachineType>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListMachineTypesRequest, + protos.google.cloud.compute.v1.IMachineTypeList|null|undefined, + protos.google.cloud.compute.v1.IMachineType>): + Promise<[ + protos.google.cloud.compute.v1.IMachineType[], + protos.google.cloud.compute.v1.IListMachineTypesRequest|null, + protos.google.cloud.compute.v1.IMachineTypeList + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.MachineType | MachineType} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListMachineTypesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.MachineType | MachineType}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/machine_types.list.js + * region_tag:compute_v1_generated_MachineTypes_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListMachineTypesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.machineTypesStub && !this._terminated) { + return this.machineTypesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_types_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_types_client_config.json new file mode 100644 index 00000000000..d741c0b99a2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_types_client_config.json @@ -0,0 +1,38 @@ +{ + "interfaces": { + "google.cloud.compute.v1.MachineTypes": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_types_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_types_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/machine_types_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/network_attachments_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_attachments_client.ts new file mode 100644 index 00000000000..3dc6774ac59 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_attachments_client.ts @@ -0,0 +1,1070 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/network_attachments_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './network_attachments_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The NetworkAttachments API. + * @class + * @memberof v1 + */ +export class NetworkAttachmentsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + networkAttachmentsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of NetworkAttachmentsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new NetworkAttachmentsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof NetworkAttachmentsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.NetworkAttachments', 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.networkAttachmentsStub) { + return this.networkAttachmentsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.NetworkAttachments. + this.networkAttachmentsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.NetworkAttachments') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.NetworkAttachments, + 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 networkAttachmentsStubMethods = + ['aggregatedList', 'delete', 'get', 'getIamPolicy', 'insert', 'list', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of networkAttachmentsStubMethods) { + const callPromise = this.networkAttachmentsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.networkAttachmentsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified NetworkAttachment in the given scope + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.networkAttachment + * Name of the NetworkAttachment resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region of this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). end_interface: MixerMutationRequestBuilder + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_attachments.delete.js + * region_tag:compute_v1_generated_NetworkAttachments_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteNetworkAttachmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteNetworkAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteNetworkAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteNetworkAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'network_attachment': request.networkAttachment ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified NetworkAttachment resource in the given scope. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.networkAttachment + * Name of the NetworkAttachment resource to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region of this request. + * @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.compute.v1.NetworkAttachment | NetworkAttachment}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/network_attachments.get.js + * region_tag:compute_v1_generated_NetworkAttachments_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetNetworkAttachmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INetworkAttachment, + protos.google.cloud.compute.v1.IGetNetworkAttachmentRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetNetworkAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.INetworkAttachment, + protos.google.cloud.compute.v1.IGetNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetNetworkAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.INetworkAttachment, + protos.google.cloud.compute.v1.IGetNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetNetworkAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.INetworkAttachment, + protos.google.cloud.compute.v1.IGetNetworkAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.INetworkAttachment, + protos.google.cloud.compute.v1.IGetNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.INetworkAttachment, + protos.google.cloud.compute.v1.IGetNetworkAttachmentRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'network_attachment': request.networkAttachment ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/network_attachments.get_iam_policy.js + * region_tag:compute_v1_generated_NetworkAttachments_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyNetworkAttachmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNetworkAttachmentRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyNetworkAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyNetworkAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyNetworkAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNetworkAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNetworkAttachmentRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Creates a NetworkAttachment in the specified project in the given scope using the parameters that are included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.NetworkAttachment} request.networkAttachmentResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region of this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). end_interface: MixerMutationRequestBuilder + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_attachments.insert.js + * region_tag:compute_v1_generated_NetworkAttachments_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertNetworkAttachmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertNetworkAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertNetworkAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertNetworkAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {google.cloud.compute.v1.RegionSetPolicyRequest} request.regionSetPolicyRequestResource + * The body resource for this request + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/network_attachments.set_iam_policy.js + * region_tag:compute_v1_generated_NetworkAttachments_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyNetworkAttachmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNetworkAttachmentRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyNetworkAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyNetworkAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyNetworkAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNetworkAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNetworkAttachmentRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/network_attachments.test_iam_permissions.js + * region_tag:compute_v1_generated_NetworkAttachments_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsNetworkAttachmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkAttachmentRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsNetworkAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsNetworkAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsNetworkAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkAttachmentRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + +/** + * Retrieves the list of all NetworkAttachment resources, regional and global, available to the specified project. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.NetworkAttachmentsScopedList | NetworkAttachmentsScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/network_attachments.aggregated_list.js + * region_tag:compute_v1_generated_NetworkAttachments_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListNetworkAttachmentsRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.INetworkAttachmentsScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.INetworkAttachmentsScopedList]>; + } + /** + * Lists the NetworkAttachments for a project in the given scope. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region of this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.NetworkAttachment | NetworkAttachment}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListNetworkAttachmentsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INetworkAttachment[], + protos.google.cloud.compute.v1.IListNetworkAttachmentsRequest|null, + protos.google.cloud.compute.v1.INetworkAttachmentList + ]>; + list( + request: protos.google.cloud.compute.v1.IListNetworkAttachmentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkAttachmentsRequest, + protos.google.cloud.compute.v1.INetworkAttachmentList|null|undefined, + protos.google.cloud.compute.v1.INetworkAttachment>): void; + list( + request: protos.google.cloud.compute.v1.IListNetworkAttachmentsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkAttachmentsRequest, + protos.google.cloud.compute.v1.INetworkAttachmentList|null|undefined, + protos.google.cloud.compute.v1.INetworkAttachment>): void; + list( + request?: protos.google.cloud.compute.v1.IListNetworkAttachmentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkAttachmentsRequest, + protos.google.cloud.compute.v1.INetworkAttachmentList|null|undefined, + protos.google.cloud.compute.v1.INetworkAttachment>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkAttachmentsRequest, + protos.google.cloud.compute.v1.INetworkAttachmentList|null|undefined, + protos.google.cloud.compute.v1.INetworkAttachment>): + Promise<[ + protos.google.cloud.compute.v1.INetworkAttachment[], + protos.google.cloud.compute.v1.IListNetworkAttachmentsRequest|null, + protos.google.cloud.compute.v1.INetworkAttachmentList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region of this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.NetworkAttachment | NetworkAttachment} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListNetworkAttachmentsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region of this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.NetworkAttachment | NetworkAttachment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/network_attachments.list.js + * region_tag:compute_v1_generated_NetworkAttachments_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListNetworkAttachmentsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.networkAttachmentsStub && !this._terminated) { + return this.networkAttachmentsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/network_attachments_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_attachments_client_config.json new file mode 100644 index 00000000000..755fe197862 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_attachments_client_config.json @@ -0,0 +1,58 @@ +{ + "interfaces": { + "google.cloud.compute.v1.NetworkAttachments": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/network_attachments_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_attachments_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_attachments_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/network_edge_security_services_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_edge_security_services_client.ts new file mode 100644 index 00000000000..3b358d4f63c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_edge_security_services_client.ts @@ -0,0 +1,729 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/network_edge_security_services_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './network_edge_security_services_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The NetworkEdgeSecurityServices API. + * @class + * @memberof v1 + */ +export class NetworkEdgeSecurityServicesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + networkEdgeSecurityServicesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of NetworkEdgeSecurityServicesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new NetworkEdgeSecurityServicesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof NetworkEdgeSecurityServicesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.NetworkEdgeSecurityServices', 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.networkEdgeSecurityServicesStub) { + return this.networkEdgeSecurityServicesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.NetworkEdgeSecurityServices. + this.networkEdgeSecurityServicesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.NetworkEdgeSecurityServices') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.NetworkEdgeSecurityServices, + 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 networkEdgeSecurityServicesStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'patch']; + for (const methodName of networkEdgeSecurityServicesStubMethods) { + const callPromise = this.networkEdgeSecurityServicesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.networkEdgeSecurityServicesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.networkEdgeSecurityService + * Name of the network edge security service to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_edge_security_services.delete.js + * region_tag:compute_v1_generated_NetworkEdgeSecurityServices_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteNetworkEdgeSecurityServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteNetworkEdgeSecurityServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkEdgeSecurityServiceRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteNetworkEdgeSecurityServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkEdgeSecurityServiceRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteNetworkEdgeSecurityServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkEdgeSecurityServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkEdgeSecurityServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'network_edge_security_service': request.networkEdgeSecurityService ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Gets a specified NetworkEdgeSecurityService. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.networkEdgeSecurityService + * Name of the network edge security service to get. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @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.compute.v1.NetworkEdgeSecurityService | NetworkEdgeSecurityService}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/network_edge_security_services.get.js + * region_tag:compute_v1_generated_NetworkEdgeSecurityServices_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetNetworkEdgeSecurityServiceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INetworkEdgeSecurityService, + protos.google.cloud.compute.v1.IGetNetworkEdgeSecurityServiceRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetNetworkEdgeSecurityServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.INetworkEdgeSecurityService, + protos.google.cloud.compute.v1.IGetNetworkEdgeSecurityServiceRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetNetworkEdgeSecurityServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.INetworkEdgeSecurityService, + protos.google.cloud.compute.v1.IGetNetworkEdgeSecurityServiceRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetNetworkEdgeSecurityServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.INetworkEdgeSecurityService, + protos.google.cloud.compute.v1.IGetNetworkEdgeSecurityServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.INetworkEdgeSecurityService, + protos.google.cloud.compute.v1.IGetNetworkEdgeSecurityServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.INetworkEdgeSecurityService, + protos.google.cloud.compute.v1.IGetNetworkEdgeSecurityServiceRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'network_edge_security_service': request.networkEdgeSecurityService ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a new service in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.NetworkEdgeSecurityService} request.networkEdgeSecurityServiceResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {boolean} request.validateOnly + * If true, the request will not be committed. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_edge_security_services.insert.js + * region_tag:compute_v1_generated_NetworkEdgeSecurityServices_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertNetworkEdgeSecurityServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertNetworkEdgeSecurityServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkEdgeSecurityServiceRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertNetworkEdgeSecurityServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkEdgeSecurityServiceRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertNetworkEdgeSecurityServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkEdgeSecurityServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkEdgeSecurityServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified policy with the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.networkEdgeSecurityService + * Name of the network edge security service to update. + * @param {google.cloud.compute.v1.NetworkEdgeSecurityService} request.networkEdgeSecurityServiceResource + * The body resource for this request + * @param {string} request.paths + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.updateMask + * Indicates fields to be updated as part of this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_edge_security_services.patch.js + * region_tag:compute_v1_generated_NetworkEdgeSecurityServices_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchNetworkEdgeSecurityServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchNetworkEdgeSecurityServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchNetworkEdgeSecurityServiceRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchNetworkEdgeSecurityServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchNetworkEdgeSecurityServiceRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchNetworkEdgeSecurityServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchNetworkEdgeSecurityServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchNetworkEdgeSecurityServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'network_edge_security_service': request.networkEdgeSecurityService ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves the list of all NetworkEdgeSecurityService resources available to the specified project. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Name of the project scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.NetworkEdgeSecurityServicesScopedList | NetworkEdgeSecurityServicesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/network_edge_security_services.aggregated_list.js + * region_tag:compute_v1_generated_NetworkEdgeSecurityServices_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListNetworkEdgeSecurityServicesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.INetworkEdgeSecurityServicesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.INetworkEdgeSecurityServicesScopedList]>; + } + + /** + * 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.networkEdgeSecurityServicesStub && !this._terminated) { + return this.networkEdgeSecurityServicesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/network_edge_security_services_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_edge_security_services_client_config.json new file mode 100644 index 00000000000..962ad7bf444 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_edge_security_services_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.compute.v1.NetworkEdgeSecurityServices": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/network_edge_security_services_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_edge_security_services_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_edge_security_services_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/network_endpoint_groups_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_endpoint_groups_client.ts new file mode 100644 index 00000000000..c98d8ace8f2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_endpoint_groups_client.ts @@ -0,0 +1,1315 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/network_endpoint_groups_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './network_endpoint_groups_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The NetworkEndpointGroups API. + * @class + * @memberof v1 + */ +export class NetworkEndpointGroupsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + networkEndpointGroupsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of NetworkEndpointGroupsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new NetworkEndpointGroupsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof NetworkEndpointGroupsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + listNetworkEndpoints: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.NetworkEndpointGroups', 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.networkEndpointGroupsStub) { + return this.networkEndpointGroupsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.NetworkEndpointGroups. + this.networkEndpointGroupsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.NetworkEndpointGroups') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.NetworkEndpointGroups, + 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 networkEndpointGroupsStubMethods = + ['aggregatedList', 'attachNetworkEndpoints', 'delete', 'detachNetworkEndpoints', 'get', 'insert', 'list', 'listNetworkEndpoints', 'testIamPermissions']; + for (const methodName of networkEndpointGroupsStubMethods) { + const callPromise = this.networkEndpointGroupsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.networkEndpointGroupsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Attach a list of network endpoints to the specified network endpoint group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.networkEndpointGroup + * The name of the network endpoint group where you are attaching network endpoints to. It should comply with RFC1035. + * @param {google.cloud.compute.v1.NetworkEndpointGroupsAttachEndpointsRequest} request.networkEndpointGroupsAttachEndpointsRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where the network endpoint group is located. It should comply with RFC1035. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_endpoint_groups.attach_network_endpoints.js + * region_tag:compute_v1_generated_NetworkEndpointGroups_AttachNetworkEndpoints_async + */ + attachNetworkEndpoints( + request?: protos.google.cloud.compute.v1.IAttachNetworkEndpointsNetworkEndpointGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + attachNetworkEndpoints( + request: protos.google.cloud.compute.v1.IAttachNetworkEndpointsNetworkEndpointGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAttachNetworkEndpointsNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + attachNetworkEndpoints( + request: protos.google.cloud.compute.v1.IAttachNetworkEndpointsNetworkEndpointGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAttachNetworkEndpointsNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + attachNetworkEndpoints( + request?: protos.google.cloud.compute.v1.IAttachNetworkEndpointsNetworkEndpointGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAttachNetworkEndpointsNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAttachNetworkEndpointsNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'network_endpoint_group': request.networkEndpointGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.attachNetworkEndpoints(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified network endpoint group. The network endpoints in the NEG and the VM instances they belong to are not terminated when the NEG is deleted. Note that the NEG cannot be deleted if there are backend services referencing it. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.networkEndpointGroup + * The name of the network endpoint group to delete. It should comply with RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where the network endpoint group is located. It should comply with RFC1035. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_endpoint_groups.delete.js + * region_tag:compute_v1_generated_NetworkEndpointGroups_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteNetworkEndpointGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteNetworkEndpointGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteNetworkEndpointGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteNetworkEndpointGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'network_endpoint_group': request.networkEndpointGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Detach a list of network endpoints from the specified network endpoint group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.networkEndpointGroup + * The name of the network endpoint group where you are removing network endpoints. It should comply with RFC1035. + * @param {google.cloud.compute.v1.NetworkEndpointGroupsDetachEndpointsRequest} request.networkEndpointGroupsDetachEndpointsRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where the network endpoint group is located. It should comply with RFC1035. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_endpoint_groups.detach_network_endpoints.js + * region_tag:compute_v1_generated_NetworkEndpointGroups_DetachNetworkEndpoints_async + */ + detachNetworkEndpoints( + request?: protos.google.cloud.compute.v1.IDetachNetworkEndpointsNetworkEndpointGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + detachNetworkEndpoints( + request: protos.google.cloud.compute.v1.IDetachNetworkEndpointsNetworkEndpointGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDetachNetworkEndpointsNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + detachNetworkEndpoints( + request: protos.google.cloud.compute.v1.IDetachNetworkEndpointsNetworkEndpointGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDetachNetworkEndpointsNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + detachNetworkEndpoints( + request?: protos.google.cloud.compute.v1.IDetachNetworkEndpointsNetworkEndpointGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDetachNetworkEndpointsNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDetachNetworkEndpointsNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'network_endpoint_group': request.networkEndpointGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.detachNetworkEndpoints(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified network endpoint group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.networkEndpointGroup + * The name of the network endpoint group. It should comply with RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone where the network endpoint group is located. It should comply with RFC1035. + * @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.compute.v1.NetworkEndpointGroup | NetworkEndpointGroup}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/network_endpoint_groups.get.js + * region_tag:compute_v1_generated_NetworkEndpointGroups_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetNetworkEndpointGroupRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetNetworkEndpointGroupRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetNetworkEndpointGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetNetworkEndpointGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetNetworkEndpointGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetNetworkEndpointGroupRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'network_endpoint_group': request.networkEndpointGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a network endpoint group in the specified project using the parameters that are included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.NetworkEndpointGroup} request.networkEndpointGroupResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone where you want to create the network endpoint group. It should comply with RFC1035. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_endpoint_groups.insert.js + * region_tag:compute_v1_generated_NetworkEndpointGroups_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertNetworkEndpointGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertNetworkEndpointGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertNetworkEndpointGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertNetworkEndpointGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/network_endpoint_groups.test_iam_permissions.js + * region_tag:compute_v1_generated_NetworkEndpointGroups_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsNetworkEndpointGroupRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkEndpointGroupRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsNetworkEndpointGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsNetworkEndpointGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsNetworkEndpointGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkEndpointGroupRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + +/** + * Retrieves the list of network endpoint groups and sorts them by zone. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.NetworkEndpointGroupsScopedList | NetworkEndpointGroupsScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/network_endpoint_groups.aggregated_list.js + * region_tag:compute_v1_generated_NetworkEndpointGroups_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListNetworkEndpointGroupsRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.INetworkEndpointGroupsScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.INetworkEndpointGroupsScopedList]>; + } + /** + * Retrieves the list of network endpoint groups that are located in the specified project and zone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the network endpoint group is located. It should comply with RFC1035. + * @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 google.cloud.compute.v1.NetworkEndpointGroup | NetworkEndpointGroup}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListNetworkEndpointGroupsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INetworkEndpointGroup[], + protos.google.cloud.compute.v1.IListNetworkEndpointGroupsRequest|null, + protos.google.cloud.compute.v1.INetworkEndpointGroupList + ]>; + list( + request: protos.google.cloud.compute.v1.IListNetworkEndpointGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupList|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointGroup>): void; + list( + request: protos.google.cloud.compute.v1.IListNetworkEndpointGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupList|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointGroup>): void; + list( + request?: protos.google.cloud.compute.v1.IListNetworkEndpointGroupsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupList|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointGroup>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupList|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointGroup>): + Promise<[ + protos.google.cloud.compute.v1.INetworkEndpointGroup[], + protos.google.cloud.compute.v1.IListNetworkEndpointGroupsRequest|null, + protos.google.cloud.compute.v1.INetworkEndpointGroupList + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the network endpoint group is located. It should comply with RFC1035. + * @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 google.cloud.compute.v1.NetworkEndpointGroup | NetworkEndpointGroup} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListNetworkEndpointGroupsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the network endpoint group is located. It should comply with RFC1035. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.NetworkEndpointGroup | NetworkEndpointGroup}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/network_endpoint_groups.list.js + * region_tag:compute_v1_generated_NetworkEndpointGroups_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListNetworkEndpointGroupsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the network endpoints in the specified network endpoint group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.networkEndpointGroup + * The name of the network endpoint group from which you want to generate a list of included network endpoints. It should comply with RFC1035. + * @param {google.cloud.compute.v1.NetworkEndpointGroupsListEndpointsRequest} request.networkEndpointGroupsListEndpointsRequestResource + * The body resource for this request + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the network endpoint group is located. It should comply with RFC1035. + * @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 google.cloud.compute.v1.NetworkEndpointWithHealthStatus | NetworkEndpointWithHealthStatus}. + * 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 `listNetworkEndpointsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listNetworkEndpoints( + request?: protos.google.cloud.compute.v1.IListNetworkEndpointsNetworkEndpointGroupsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus[], + protos.google.cloud.compute.v1.IListNetworkEndpointsNetworkEndpointGroupsRequest|null, + protos.google.cloud.compute.v1.INetworkEndpointGroupsListNetworkEndpoints + ]>; + listNetworkEndpoints( + request: protos.google.cloud.compute.v1.IListNetworkEndpointsNetworkEndpointGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkEndpointsNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupsListNetworkEndpoints|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus>): void; + listNetworkEndpoints( + request: protos.google.cloud.compute.v1.IListNetworkEndpointsNetworkEndpointGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkEndpointsNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupsListNetworkEndpoints|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus>): void; + listNetworkEndpoints( + request?: protos.google.cloud.compute.v1.IListNetworkEndpointsNetworkEndpointGroupsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkEndpointsNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupsListNetworkEndpoints|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkEndpointsNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupsListNetworkEndpoints|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus>): + Promise<[ + protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus[], + protos.google.cloud.compute.v1.IListNetworkEndpointsNetworkEndpointGroupsRequest|null, + protos.google.cloud.compute.v1.INetworkEndpointGroupsListNetworkEndpoints + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'network_endpoint_group': request.networkEndpointGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.listNetworkEndpoints(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.networkEndpointGroup + * The name of the network endpoint group from which you want to generate a list of included network endpoints. It should comply with RFC1035. + * @param {google.cloud.compute.v1.NetworkEndpointGroupsListEndpointsRequest} request.networkEndpointGroupsListEndpointsRequestResource + * The body resource for this request + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the network endpoint group is located. It should comply with RFC1035. + * @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 google.cloud.compute.v1.NetworkEndpointWithHealthStatus | NetworkEndpointWithHealthStatus} 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 `listNetworkEndpointsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listNetworkEndpointsStream( + request?: protos.google.cloud.compute.v1.IListNetworkEndpointsNetworkEndpointGroupsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'network_endpoint_group': request.networkEndpointGroup ?? '', + }); + const defaultCallSettings = this._defaults['listNetworkEndpoints']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listNetworkEndpoints.createStream( + this.innerApiCalls.listNetworkEndpoints as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listNetworkEndpoints`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.networkEndpointGroup + * The name of the network endpoint group from which you want to generate a list of included network endpoints. It should comply with RFC1035. + * @param {google.cloud.compute.v1.NetworkEndpointGroupsListEndpointsRequest} request.networkEndpointGroupsListEndpointsRequestResource + * The body resource for this request + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone where the network endpoint group is located. It should comply with RFC1035. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.NetworkEndpointWithHealthStatus | NetworkEndpointWithHealthStatus}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/network_endpoint_groups.list_network_endpoints.js + * region_tag:compute_v1_generated_NetworkEndpointGroups_ListNetworkEndpoints_async + */ + listNetworkEndpointsAsync( + request?: protos.google.cloud.compute.v1.IListNetworkEndpointsNetworkEndpointGroupsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'network_endpoint_group': request.networkEndpointGroup ?? '', + }); + const defaultCallSettings = this._defaults['listNetworkEndpoints']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listNetworkEndpoints.asyncIterate( + this.innerApiCalls['listNetworkEndpoints'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.networkEndpointGroupsStub && !this._terminated) { + return this.networkEndpointGroupsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/network_endpoint_groups_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_endpoint_groups_client_config.json new file mode 100644 index 00000000000..66b746a1744 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_endpoint_groups_client_config.json @@ -0,0 +1,62 @@ +{ + "interfaces": { + "google.cloud.compute.v1.NetworkEndpointGroups": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AttachNetworkEndpoints": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DetachNetworkEndpoints": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListNetworkEndpoints": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/network_endpoint_groups_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_endpoint_groups_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_endpoint_groups_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/network_firewall_policies_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_firewall_policies_client.ts new file mode 100644 index 00000000000..50d755c64a7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_firewall_policies_client.ts @@ -0,0 +1,1775 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/network_firewall_policies_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './network_firewall_policies_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The NetworkFirewallPolicies API. + * @class + * @memberof v1 + */ +export class NetworkFirewallPoliciesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + networkFirewallPoliciesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of NetworkFirewallPoliciesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new NetworkFirewallPoliciesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof NetworkFirewallPoliciesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.NetworkFirewallPolicies', 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.networkFirewallPoliciesStub) { + return this.networkFirewallPoliciesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.NetworkFirewallPolicies. + this.networkFirewallPoliciesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.NetworkFirewallPolicies') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.NetworkFirewallPolicies, + 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 networkFirewallPoliciesStubMethods = + ['addAssociation', 'addRule', 'cloneRules', 'delete', 'get', 'getAssociation', 'getIamPolicy', 'getRule', 'insert', 'list', 'patch', 'patchRule', 'removeAssociation', 'removeRule', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of networkFirewallPoliciesStubMethods) { + const callPromise = this.networkFirewallPoliciesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.networkFirewallPoliciesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Inserts an association for the specified firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {google.cloud.compute.v1.FirewallPolicyAssociation} request.firewallPolicyAssociationResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.replaceExistingAssociation + * Indicates whether or not to replace it if an association of the attachment already exists. This is false by default, in which case an error will be returned if an association already exists. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_firewall_policies.add_association.js + * region_tag:compute_v1_generated_NetworkFirewallPolicies_AddAssociation_async + */ + addAssociation( + request?: protos.google.cloud.compute.v1.IAddAssociationNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addAssociation( + request: protos.google.cloud.compute.v1.IAddAssociationNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddAssociationNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + addAssociation( + request: protos.google.cloud.compute.v1.IAddAssociationNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddAssociationNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + addAssociation( + request?: protos.google.cloud.compute.v1.IAddAssociationNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddAssociationNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddAssociationNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.addAssociation(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Inserts a rule into a firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {google.cloud.compute.v1.FirewallPolicyRule} request.firewallPolicyRuleResource + * The body resource for this request + * @param {number} request.maxPriority + * When rule.priority is not specified, auto choose a unused priority between minPriority and maxPriority>. This field is exclusive with rule.priority. + * @param {number} request.minPriority + * When rule.priority is not specified, auto choose a unused priority between minPriority and maxPriority>. This field is exclusive with rule.priority. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_firewall_policies.add_rule.js + * region_tag:compute_v1_generated_NetworkFirewallPolicies_AddRule_async + */ + addRule( + request?: protos.google.cloud.compute.v1.IAddRuleNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addRule( + request: protos.google.cloud.compute.v1.IAddRuleNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddRuleNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + addRule( + request: protos.google.cloud.compute.v1.IAddRuleNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddRuleNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + addRule( + request?: protos.google.cloud.compute.v1.IAddRuleNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddRuleNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddRuleNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.addRule(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Copies rules to the specified firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.sourceFirewallPolicy + * The firewall policy from which to copy rules. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_firewall_policies.clone_rules.js + * region_tag:compute_v1_generated_NetworkFirewallPolicies_CloneRules_async + */ + cloneRules( + request?: protos.google.cloud.compute.v1.ICloneRulesNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + cloneRules( + request: protos.google.cloud.compute.v1.ICloneRulesNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICloneRulesNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + cloneRules( + request: protos.google.cloud.compute.v1.ICloneRulesNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICloneRulesNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + cloneRules( + request?: protos.google.cloud.compute.v1.ICloneRulesNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICloneRulesNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICloneRulesNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.cloneRules(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_firewall_policies.delete.js + * region_tag:compute_v1_generated_NetworkFirewallPolicies_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified network firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to get. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.FirewallPolicy | FirewallPolicy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/network_firewall_policies.get.js + * region_tag:compute_v1_generated_NetworkFirewallPolicies_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetNetworkFirewallPolicyRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetNetworkFirewallPolicyRequest|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({ + 'project': request.project ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets an association with the specified name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to which the queried association belongs. + * @param {string} request.name + * The name of the association to get from the firewall policy. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.FirewallPolicyAssociation | FirewallPolicyAssociation}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/network_firewall_policies.get_association.js + * region_tag:compute_v1_generated_NetworkFirewallPolicies_GetAssociation_async + */ + getAssociation( + request?: protos.google.cloud.compute.v1.IGetAssociationNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationNetworkFirewallPolicyRequest|undefined, {}|undefined + ]>; + getAssociation( + request: protos.google.cloud.compute.v1.IGetAssociationNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getAssociation( + request: protos.google.cloud.compute.v1.IGetAssociationNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getAssociation( + request?: protos.google.cloud.compute.v1.IGetAssociationNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationNetworkFirewallPolicyRequest|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({ + 'project': request.project ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.getAssociation(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/network_firewall_policies.get_iam_policy.js + * region_tag:compute_v1_generated_NetworkFirewallPolicies_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNetworkFirewallPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNetworkFirewallPolicyRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Gets a rule of the specified priority. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to which the queried rule belongs. + * @param {number} request.priority + * The priority of the rule to get from the firewall policy. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.FirewallPolicyRule | FirewallPolicyRule}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/network_firewall_policies.get_rule.js + * region_tag:compute_v1_generated_NetworkFirewallPolicies_GetRule_async + */ + getRule( + request?: protos.google.cloud.compute.v1.IGetRuleNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleNetworkFirewallPolicyRequest|undefined, {}|undefined + ]>; + getRule( + request: protos.google.cloud.compute.v1.IGetRuleNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getRule( + request: protos.google.cloud.compute.v1.IGetRuleNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getRule( + request?: protos.google.cloud.compute.v1.IGetRuleNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleNetworkFirewallPolicyRequest|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({ + 'project': request.project ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.getRule(request, options, callback); + } +/** + * Creates a new policy in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.FirewallPolicy} request.firewallPolicyResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_firewall_policies.insert.js + * region_tag:compute_v1_generated_NetworkFirewallPolicies_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified policy with the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {google.cloud.compute.v1.FirewallPolicy} request.firewallPolicyResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_firewall_policies.patch.js + * region_tag:compute_v1_generated_NetworkFirewallPolicies_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches a rule of the specified priority. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {google.cloud.compute.v1.FirewallPolicyRule} request.firewallPolicyRuleResource + * The body resource for this request + * @param {number} request.priority + * The priority of the rule to patch. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_firewall_policies.patch_rule.js + * region_tag:compute_v1_generated_NetworkFirewallPolicies_PatchRule_async + */ + patchRule( + request?: protos.google.cloud.compute.v1.IPatchRuleNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patchRule( + request: protos.google.cloud.compute.v1.IPatchRuleNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRuleNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + patchRule( + request: protos.google.cloud.compute.v1.IPatchRuleNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRuleNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + patchRule( + request?: protos.google.cloud.compute.v1.IPatchRuleNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRuleNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRuleNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.patchRule(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Removes an association for the specified firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {string} request.name + * Name for the attachment that will be removed. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_firewall_policies.remove_association.js + * region_tag:compute_v1_generated_NetworkFirewallPolicies_RemoveAssociation_async + */ + removeAssociation( + request?: protos.google.cloud.compute.v1.IRemoveAssociationNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + removeAssociation( + request: protos.google.cloud.compute.v1.IRemoveAssociationNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveAssociationNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + removeAssociation( + request: protos.google.cloud.compute.v1.IRemoveAssociationNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveAssociationNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + removeAssociation( + request?: protos.google.cloud.compute.v1.IRemoveAssociationNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveAssociationNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveAssociationNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeAssociation(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes a rule of the specified priority. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {number} request.priority + * The priority of the rule to remove from the firewall policy. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/network_firewall_policies.remove_rule.js + * region_tag:compute_v1_generated_NetworkFirewallPolicies_RemoveRule_async + */ + removeRule( + request?: protos.google.cloud.compute.v1.IRemoveRuleNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + removeRule( + request: protos.google.cloud.compute.v1.IRemoveRuleNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveRuleNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + removeRule( + request: protos.google.cloud.compute.v1.IRemoveRuleNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveRuleNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + removeRule( + request?: protos.google.cloud.compute.v1.IRemoveRuleNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveRuleNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveRuleNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeRule(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalSetPolicyRequest} request.globalSetPolicyRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/network_firewall_policies.set_iam_policy.js + * region_tag:compute_v1_generated_NetworkFirewallPolicies_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNetworkFirewallPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNetworkFirewallPolicyRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/network_firewall_policies.test_iam_permissions.js + * region_tag:compute_v1_generated_NetworkFirewallPolicies_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkFirewallPolicyRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNetworkFirewallPolicyRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + /** + * Lists all the policies that have been configured for the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.FirewallPolicy | FirewallPolicy}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListNetworkFirewallPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicy[], + protos.google.cloud.compute.v1.IListNetworkFirewallPoliciesRequest|null, + protos.google.cloud.compute.v1.IFirewallPolicyList + ]>; + list( + request: protos.google.cloud.compute.v1.IListNetworkFirewallPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkFirewallPoliciesRequest, + protos.google.cloud.compute.v1.IFirewallPolicyList|null|undefined, + protos.google.cloud.compute.v1.IFirewallPolicy>): void; + list( + request: protos.google.cloud.compute.v1.IListNetworkFirewallPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkFirewallPoliciesRequest, + protos.google.cloud.compute.v1.IFirewallPolicyList|null|undefined, + protos.google.cloud.compute.v1.IFirewallPolicy>): void; + list( + request?: protos.google.cloud.compute.v1.IListNetworkFirewallPoliciesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkFirewallPoliciesRequest, + protos.google.cloud.compute.v1.IFirewallPolicyList|null|undefined, + protos.google.cloud.compute.v1.IFirewallPolicy>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworkFirewallPoliciesRequest, + protos.google.cloud.compute.v1.IFirewallPolicyList|null|undefined, + protos.google.cloud.compute.v1.IFirewallPolicy>): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicy[], + protos.google.cloud.compute.v1.IListNetworkFirewallPoliciesRequest|null, + protos.google.cloud.compute.v1.IFirewallPolicyList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.FirewallPolicy | FirewallPolicy} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListNetworkFirewallPoliciesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.FirewallPolicy | FirewallPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/network_firewall_policies.list.js + * region_tag:compute_v1_generated_NetworkFirewallPolicies_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListNetworkFirewallPoliciesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.networkFirewallPoliciesStub && !this._terminated) { + return this.networkFirewallPoliciesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/network_firewall_policies_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_firewall_policies_client_config.json new file mode 100644 index 00000000000..e71d72dac78 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_firewall_policies_client_config.json @@ -0,0 +1,90 @@ +{ + "interfaces": { + "google.cloud.compute.v1.NetworkFirewallPolicies": { + "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": { + "AddAssociation": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AddRule": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CloneRules": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetAssociation": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetRule": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PatchRule": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveAssociation": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveRule": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/network_firewall_policies_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_firewall_policies_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/network_firewall_policies_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/networks_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/networks_client.ts new file mode 100644 index 00000000000..93c88b6c34a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/networks_client.ts @@ -0,0 +1,1502 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/networks_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './networks_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Networks API. + * @class + * @memberof v1 + */ +export class NetworksClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + networksStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of NetworksClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new NetworksClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof NetworksClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + listPeeringRoutes: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.Networks', 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.networksStub) { + return this.networksStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.Networks. + this.networksStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Networks') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.Networks, + 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 networksStubMethods = + ['addPeering', 'delete', 'get', 'getEffectiveFirewalls', 'insert', 'list', 'listPeeringRoutes', 'patch', 'removePeering', 'switchToCustomMode', 'updatePeering']; + for (const methodName of networksStubMethods) { + const callPromise = this.networksStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.networksStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Adds a peering to the specified network. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.network + * Name of the network resource to add peering to. + * @param {google.cloud.compute.v1.NetworksAddPeeringRequest} request.networksAddPeeringRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/networks.add_peering.js + * region_tag:compute_v1_generated_Networks_AddPeering_async + */ + addPeering( + request?: protos.google.cloud.compute.v1.IAddPeeringNetworkRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addPeering( + request: protos.google.cloud.compute.v1.IAddPeeringNetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddPeeringNetworkRequest|null|undefined, + {}|null|undefined>): void; + addPeering( + request: protos.google.cloud.compute.v1.IAddPeeringNetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddPeeringNetworkRequest|null|undefined, + {}|null|undefined>): void; + addPeering( + request?: protos.google.cloud.compute.v1.IAddPeeringNetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddPeeringNetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddPeeringNetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'network': request.network ?? '', + }); + this.initialize(); + return this.innerApiCalls.addPeering(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified network. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.network + * Name of the network to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/networks.delete.js + * region_tag:compute_v1_generated_Networks_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteNetworkRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteNetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteNetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteNetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'network': request.network ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified network. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.network + * Name of the network to return. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.Network | Network}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/networks.get.js + * region_tag:compute_v1_generated_Networks_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetNetworkRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INetwork, + protos.google.cloud.compute.v1.IGetNetworkRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetNetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.INetwork, + protos.google.cloud.compute.v1.IGetNetworkRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetNetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.INetwork, + protos.google.cloud.compute.v1.IGetNetworkRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetNetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.INetwork, + protos.google.cloud.compute.v1.IGetNetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.INetwork, + protos.google.cloud.compute.v1.IGetNetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.INetwork, + protos.google.cloud.compute.v1.IGetNetworkRequest|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({ + 'project': request.project ?? '', + 'network': request.network ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Returns the effective firewalls on a given network. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.network + * Name of the network for this request. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.NetworksGetEffectiveFirewallsResponse | NetworksGetEffectiveFirewallsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/networks.get_effective_firewalls.js + * region_tag:compute_v1_generated_Networks_GetEffectiveFirewalls_async + */ + getEffectiveFirewalls( + request?: protos.google.cloud.compute.v1.IGetEffectiveFirewallsNetworkRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INetworksGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsNetworkRequest|undefined, {}|undefined + ]>; + getEffectiveFirewalls( + request: protos.google.cloud.compute.v1.IGetEffectiveFirewallsNetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.INetworksGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsNetworkRequest|null|undefined, + {}|null|undefined>): void; + getEffectiveFirewalls( + request: protos.google.cloud.compute.v1.IGetEffectiveFirewallsNetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.INetworksGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsNetworkRequest|null|undefined, + {}|null|undefined>): void; + getEffectiveFirewalls( + request?: protos.google.cloud.compute.v1.IGetEffectiveFirewallsNetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.INetworksGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsNetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.INetworksGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsNetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.INetworksGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsNetworkRequest|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({ + 'project': request.project ?? '', + 'network': request.network ?? '', + }); + this.initialize(); + return this.innerApiCalls.getEffectiveFirewalls(request, options, callback); + } +/** + * Creates a network in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.Network} request.networkResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/networks.insert.js + * region_tag:compute_v1_generated_Networks_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertNetworkRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertNetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertNetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertNetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified network with the data included in the request. Only the following fields can be modified: routingConfig.routingMode. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.network + * Name of the network to update. + * @param {google.cloud.compute.v1.Network} request.networkResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/networks.patch.js + * region_tag:compute_v1_generated_Networks_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchNetworkRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchNetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchNetworkRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchNetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchNetworkRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchNetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchNetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchNetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'network': request.network ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Removes a peering from the specified network. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.network + * Name of the network resource to remove peering from. + * @param {google.cloud.compute.v1.NetworksRemovePeeringRequest} request.networksRemovePeeringRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/networks.remove_peering.js + * region_tag:compute_v1_generated_Networks_RemovePeering_async + */ + removePeering( + request?: protos.google.cloud.compute.v1.IRemovePeeringNetworkRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + removePeering( + request: protos.google.cloud.compute.v1.IRemovePeeringNetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemovePeeringNetworkRequest|null|undefined, + {}|null|undefined>): void; + removePeering( + request: protos.google.cloud.compute.v1.IRemovePeeringNetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemovePeeringNetworkRequest|null|undefined, + {}|null|undefined>): void; + removePeering( + request?: protos.google.cloud.compute.v1.IRemovePeeringNetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemovePeeringNetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemovePeeringNetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'network': request.network ?? '', + }); + this.initialize(); + return this.innerApiCalls.removePeering(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Switches the network mode from auto subnet mode to custom subnet mode. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.network + * Name of the network to be updated. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/networks.switch_to_custom_mode.js + * region_tag:compute_v1_generated_Networks_SwitchToCustomMode_async + */ + switchToCustomMode( + request?: protos.google.cloud.compute.v1.ISwitchToCustomModeNetworkRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + switchToCustomMode( + request: protos.google.cloud.compute.v1.ISwitchToCustomModeNetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISwitchToCustomModeNetworkRequest|null|undefined, + {}|null|undefined>): void; + switchToCustomMode( + request: protos.google.cloud.compute.v1.ISwitchToCustomModeNetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISwitchToCustomModeNetworkRequest|null|undefined, + {}|null|undefined>): void; + switchToCustomMode( + request?: protos.google.cloud.compute.v1.ISwitchToCustomModeNetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISwitchToCustomModeNetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISwitchToCustomModeNetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'network': request.network ?? '', + }); + this.initialize(); + return this.innerApiCalls.switchToCustomMode(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified network peering with the data included in the request. You can only modify the NetworkPeering.export_custom_routes field and the NetworkPeering.import_custom_routes field. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.network + * Name of the network resource which the updated peering is belonging to. + * @param {google.cloud.compute.v1.NetworksUpdatePeeringRequest} request.networksUpdatePeeringRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/networks.update_peering.js + * region_tag:compute_v1_generated_Networks_UpdatePeering_async + */ + updatePeering( + request?: protos.google.cloud.compute.v1.IUpdatePeeringNetworkRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + updatePeering( + request: protos.google.cloud.compute.v1.IUpdatePeeringNetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdatePeeringNetworkRequest|null|undefined, + {}|null|undefined>): void; + updatePeering( + request: protos.google.cloud.compute.v1.IUpdatePeeringNetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdatePeeringNetworkRequest|null|undefined, + {}|null|undefined>): void; + updatePeering( + request?: protos.google.cloud.compute.v1.IUpdatePeeringNetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdatePeeringNetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdatePeeringNetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'network': request.network ?? '', + }); + this.initialize(); + return this.innerApiCalls.updatePeering(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves the list of networks available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Network | Network}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListNetworksRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INetwork[], + protos.google.cloud.compute.v1.IListNetworksRequest|null, + protos.google.cloud.compute.v1.INetworkList + ]>; + list( + request: protos.google.cloud.compute.v1.IListNetworksRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworksRequest, + protos.google.cloud.compute.v1.INetworkList|null|undefined, + protos.google.cloud.compute.v1.INetwork>): void; + list( + request: protos.google.cloud.compute.v1.IListNetworksRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworksRequest, + protos.google.cloud.compute.v1.INetworkList|null|undefined, + protos.google.cloud.compute.v1.INetwork>): void; + list( + request?: protos.google.cloud.compute.v1.IListNetworksRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListNetworksRequest, + protos.google.cloud.compute.v1.INetworkList|null|undefined, + protos.google.cloud.compute.v1.INetwork>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListNetworksRequest, + protos.google.cloud.compute.v1.INetworkList|null|undefined, + protos.google.cloud.compute.v1.INetwork>): + Promise<[ + protos.google.cloud.compute.v1.INetwork[], + protos.google.cloud.compute.v1.IListNetworksRequest|null, + protos.google.cloud.compute.v1.INetworkList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Network | Network} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListNetworksRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Network | Network}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/networks.list.js + * region_tag:compute_v1_generated_Networks_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListNetworksRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the peering routes exchanged over peering connection. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.direction + * The direction of the exchanged routes. + * Check the Direction enum for the list of possible values. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.network + * Name of the network for this request. + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.peeringName + * The response will show routes exchanged over the given peering connection. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The region of the request. The response will include all subnet routes, static routes and dynamic routes in the region. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.ExchangedPeeringRoute | ExchangedPeeringRoute}. + * 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 `listPeeringRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listPeeringRoutes( + request?: protos.google.cloud.compute.v1.IListPeeringRoutesNetworksRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IExchangedPeeringRoute[], + protos.google.cloud.compute.v1.IListPeeringRoutesNetworksRequest|null, + protos.google.cloud.compute.v1.IExchangedPeeringRoutesList + ]>; + listPeeringRoutes( + request: protos.google.cloud.compute.v1.IListPeeringRoutesNetworksRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListPeeringRoutesNetworksRequest, + protos.google.cloud.compute.v1.IExchangedPeeringRoutesList|null|undefined, + protos.google.cloud.compute.v1.IExchangedPeeringRoute>): void; + listPeeringRoutes( + request: protos.google.cloud.compute.v1.IListPeeringRoutesNetworksRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListPeeringRoutesNetworksRequest, + protos.google.cloud.compute.v1.IExchangedPeeringRoutesList|null|undefined, + protos.google.cloud.compute.v1.IExchangedPeeringRoute>): void; + listPeeringRoutes( + request?: protos.google.cloud.compute.v1.IListPeeringRoutesNetworksRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListPeeringRoutesNetworksRequest, + protos.google.cloud.compute.v1.IExchangedPeeringRoutesList|null|undefined, + protos.google.cloud.compute.v1.IExchangedPeeringRoute>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListPeeringRoutesNetworksRequest, + protos.google.cloud.compute.v1.IExchangedPeeringRoutesList|null|undefined, + protos.google.cloud.compute.v1.IExchangedPeeringRoute>): + Promise<[ + protos.google.cloud.compute.v1.IExchangedPeeringRoute[], + protos.google.cloud.compute.v1.IListPeeringRoutesNetworksRequest|null, + protos.google.cloud.compute.v1.IExchangedPeeringRoutesList + ]>|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({ + 'project': request.project ?? '', + 'network': request.network ?? '', + }); + this.initialize(); + return this.innerApiCalls.listPeeringRoutes(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.direction + * The direction of the exchanged routes. + * Check the Direction enum for the list of possible values. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.network + * Name of the network for this request. + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.peeringName + * The response will show routes exchanged over the given peering connection. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The region of the request. The response will include all subnet routes, static routes and dynamic routes in the region. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.ExchangedPeeringRoute | ExchangedPeeringRoute} 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 `listPeeringRoutesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listPeeringRoutesStream( + request?: protos.google.cloud.compute.v1.IListPeeringRoutesNetworksRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'network': request.network ?? '', + }); + const defaultCallSettings = this._defaults['listPeeringRoutes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPeeringRoutes.createStream( + this.innerApiCalls.listPeeringRoutes as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listPeeringRoutes`, 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.direction + * The direction of the exchanged routes. + * Check the Direction enum for the list of possible values. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.network + * Name of the network for this request. + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.peeringName + * The response will show routes exchanged over the given peering connection. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The region of the request. The response will include all subnet routes, static routes and dynamic routes in the region. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.ExchangedPeeringRoute | ExchangedPeeringRoute}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/networks.list_peering_routes.js + * region_tag:compute_v1_generated_Networks_ListPeeringRoutes_async + */ + listPeeringRoutesAsync( + request?: protos.google.cloud.compute.v1.IListPeeringRoutesNetworksRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'network': request.network ?? '', + }); + const defaultCallSettings = this._defaults['listPeeringRoutes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPeeringRoutes.asyncIterate( + this.innerApiCalls['listPeeringRoutes'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.networksStub && !this._terminated) { + return this.networksStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/networks_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/networks_client_config.json new file mode 100644 index 00000000000..c26bf30d926 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/networks_client_config.json @@ -0,0 +1,70 @@ +{ + "interfaces": { + "google.cloud.compute.v1.Networks": { + "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": { + "AddPeering": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetEffectiveFirewalls": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListPeeringRoutes": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemovePeering": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SwitchToCustomMode": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdatePeering": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/networks_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/networks_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/networks_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/node_groups_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_groups_client.ts new file mode 100644 index 00000000000..800fff27e29 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_groups_client.ts @@ -0,0 +1,1748 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/node_groups_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './node_groups_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The NodeGroups API. + * @class + * @memberof v1 + */ +export class NodeGroupsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + nodeGroupsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of NodeGroupsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new NodeGroupsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof NodeGroupsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + listNodes: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.NodeGroups', 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.nodeGroupsStub) { + return this.nodeGroupsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.NodeGroups. + this.nodeGroupsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.NodeGroups') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.NodeGroups, + 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 nodeGroupsStubMethods = + ['addNodes', 'aggregatedList', 'delete', 'deleteNodes', 'get', 'getIamPolicy', 'insert', 'list', 'listNodes', 'patch', 'setIamPolicy', 'setNodeTemplate', 'simulateMaintenanceEvent', 'testIamPermissions']; + for (const methodName of nodeGroupsStubMethods) { + const callPromise = this.nodeGroupsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.nodeGroupsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Adds specified number of nodes to the node group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.nodeGroup + * Name of the NodeGroup resource. + * @param {google.cloud.compute.v1.NodeGroupsAddNodesRequest} request.nodeGroupsAddNodesRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/node_groups.add_nodes.js + * region_tag:compute_v1_generated_NodeGroups_AddNodes_async + */ + addNodes( + request?: protos.google.cloud.compute.v1.IAddNodesNodeGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addNodes( + request: protos.google.cloud.compute.v1.IAddNodesNodeGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddNodesNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + addNodes( + request: protos.google.cloud.compute.v1.IAddNodesNodeGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddNodesNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + addNodes( + request?: protos.google.cloud.compute.v1.IAddNodesNodeGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddNodesNodeGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddNodesNodeGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'node_group': request.nodeGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.addNodes(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified NodeGroup resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.nodeGroup + * Name of the NodeGroup resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/node_groups.delete.js + * region_tag:compute_v1_generated_NodeGroups_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteNodeGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteNodeGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteNodeGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteNodeGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNodeGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNodeGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'node_group': request.nodeGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes specified nodes from the node group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.nodeGroup + * Name of the NodeGroup resource whose nodes will be deleted. + * @param {google.cloud.compute.v1.NodeGroupsDeleteNodesRequest} request.nodeGroupsDeleteNodesRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/node_groups.delete_nodes.js + * region_tag:compute_v1_generated_NodeGroups_DeleteNodes_async + */ + deleteNodes( + request?: protos.google.cloud.compute.v1.IDeleteNodesNodeGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + deleteNodes( + request: protos.google.cloud.compute.v1.IDeleteNodesNodeGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNodesNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + deleteNodes( + request: protos.google.cloud.compute.v1.IDeleteNodesNodeGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNodesNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + deleteNodes( + request?: protos.google.cloud.compute.v1.IDeleteNodesNodeGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNodesNodeGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNodesNodeGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'node_group': request.nodeGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteNodes(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified NodeGroup. Get a list of available NodeGroups by making a list() request. Note: the "nodes" field should not be used. Use nodeGroups.listNodes instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.nodeGroup + * Name of the node group to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.NodeGroup | NodeGroup}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/node_groups.get.js + * region_tag:compute_v1_generated_NodeGroups_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetNodeGroupRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INodeGroup, + protos.google.cloud.compute.v1.IGetNodeGroupRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetNodeGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.INodeGroup, + protos.google.cloud.compute.v1.IGetNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetNodeGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.INodeGroup, + protos.google.cloud.compute.v1.IGetNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetNodeGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.INodeGroup, + protos.google.cloud.compute.v1.IGetNodeGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.INodeGroup, + protos.google.cloud.compute.v1.IGetNodeGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.INodeGroup, + protos.google.cloud.compute.v1.IGetNodeGroupRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'node_group': request.nodeGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/node_groups.get_iam_policy.js + * region_tag:compute_v1_generated_NodeGroups_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyNodeGroupRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNodeGroupRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyNodeGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyNodeGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyNodeGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNodeGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNodeGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNodeGroupRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Creates a NodeGroup resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.initialNodeCount + * Initial count of nodes in the node group. + * @param {google.cloud.compute.v1.NodeGroup} request.nodeGroupResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/node_groups.insert.js + * region_tag:compute_v1_generated_NodeGroups_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertNodeGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertNodeGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertNodeGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertNodeGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNodeGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNodeGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified node group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.nodeGroup + * Name of the NodeGroup resource to update. + * @param {google.cloud.compute.v1.NodeGroup} request.nodeGroupResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/node_groups.patch.js + * region_tag:compute_v1_generated_NodeGroups_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchNodeGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchNodeGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchNodeGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchNodeGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchNodeGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchNodeGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'node_group': request.nodeGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @param {google.cloud.compute.v1.ZoneSetPolicyRequest} request.zoneSetPolicyRequestResource + * The body resource for this request + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/node_groups.set_iam_policy.js + * region_tag:compute_v1_generated_NodeGroups_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyNodeGroupRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNodeGroupRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyNodeGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyNodeGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyNodeGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNodeGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNodeGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNodeGroupRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Updates the node template of the node group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.nodeGroup + * Name of the NodeGroup resource to update. + * @param {google.cloud.compute.v1.NodeGroupsSetNodeTemplateRequest} request.nodeGroupsSetNodeTemplateRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/node_groups.set_node_template.js + * region_tag:compute_v1_generated_NodeGroups_SetNodeTemplate_async + */ + setNodeTemplate( + request?: protos.google.cloud.compute.v1.ISetNodeTemplateNodeGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setNodeTemplate( + request: protos.google.cloud.compute.v1.ISetNodeTemplateNodeGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetNodeTemplateNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + setNodeTemplate( + request: protos.google.cloud.compute.v1.ISetNodeTemplateNodeGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetNodeTemplateNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + setNodeTemplate( + request?: protos.google.cloud.compute.v1.ISetNodeTemplateNodeGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetNodeTemplateNodeGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetNodeTemplateNodeGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'node_group': request.nodeGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.setNodeTemplate(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Simulates maintenance event on specified nodes from the node group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.nodeGroup + * Name of the NodeGroup resource whose nodes will go under maintenance simulation. + * @param {google.cloud.compute.v1.NodeGroupsSimulateMaintenanceEventRequest} request.nodeGroupsSimulateMaintenanceEventRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.zone + * The name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/node_groups.simulate_maintenance_event.js + * region_tag:compute_v1_generated_NodeGroups_SimulateMaintenanceEvent_async + */ + simulateMaintenanceEvent( + request?: protos.google.cloud.compute.v1.ISimulateMaintenanceEventNodeGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + simulateMaintenanceEvent( + request: protos.google.cloud.compute.v1.ISimulateMaintenanceEventNodeGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISimulateMaintenanceEventNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + simulateMaintenanceEvent( + request: protos.google.cloud.compute.v1.ISimulateMaintenanceEventNodeGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISimulateMaintenanceEventNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + simulateMaintenanceEvent( + request?: protos.google.cloud.compute.v1.ISimulateMaintenanceEventNodeGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISimulateMaintenanceEventNodeGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISimulateMaintenanceEventNodeGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'node_group': request.nodeGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.simulateMaintenanceEvent(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/node_groups.test_iam_permissions.js + * region_tag:compute_v1_generated_NodeGroups_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsNodeGroupRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNodeGroupRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsNodeGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsNodeGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNodeGroupRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsNodeGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNodeGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNodeGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNodeGroupRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + +/** + * Retrieves an aggregated list of node groups. Note: use nodeGroups.listNodes for more details about each group. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.NodeGroupsScopedList | NodeGroupsScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/node_groups.aggregated_list.js + * region_tag:compute_v1_generated_NodeGroups_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListNodeGroupsRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.INodeGroupsScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.INodeGroupsScopedList]>; + } + /** + * Retrieves a list of node groups available to the specified project. Note: use nodeGroups.listNodes for more details about each group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.NodeGroup | NodeGroup}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListNodeGroupsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INodeGroup[], + protos.google.cloud.compute.v1.IListNodeGroupsRequest|null, + protos.google.cloud.compute.v1.INodeGroupList + ]>; + list( + request: protos.google.cloud.compute.v1.IListNodeGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNodeGroupsRequest, + protos.google.cloud.compute.v1.INodeGroupList|null|undefined, + protos.google.cloud.compute.v1.INodeGroup>): void; + list( + request: protos.google.cloud.compute.v1.IListNodeGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNodeGroupsRequest, + protos.google.cloud.compute.v1.INodeGroupList|null|undefined, + protos.google.cloud.compute.v1.INodeGroup>): void; + list( + request?: protos.google.cloud.compute.v1.IListNodeGroupsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListNodeGroupsRequest, + protos.google.cloud.compute.v1.INodeGroupList|null|undefined, + protos.google.cloud.compute.v1.INodeGroup>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListNodeGroupsRequest, + protos.google.cloud.compute.v1.INodeGroupList|null|undefined, + protos.google.cloud.compute.v1.INodeGroup>): + Promise<[ + protos.google.cloud.compute.v1.INodeGroup[], + protos.google.cloud.compute.v1.IListNodeGroupsRequest|null, + protos.google.cloud.compute.v1.INodeGroupList + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.NodeGroup | NodeGroup} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListNodeGroupsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.NodeGroup | NodeGroup}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/node_groups.list.js + * region_tag:compute_v1_generated_NodeGroups_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListNodeGroupsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists nodes in the node group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.nodeGroup + * Name of the NodeGroup resource whose nodes you want to list. + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.NodeGroupNode | NodeGroupNode}. + * 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 `listNodesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listNodes( + request?: protos.google.cloud.compute.v1.IListNodesNodeGroupsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INodeGroupNode[], + protos.google.cloud.compute.v1.IListNodesNodeGroupsRequest|null, + protos.google.cloud.compute.v1.INodeGroupsListNodes + ]>; + listNodes( + request: protos.google.cloud.compute.v1.IListNodesNodeGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNodesNodeGroupsRequest, + protos.google.cloud.compute.v1.INodeGroupsListNodes|null|undefined, + protos.google.cloud.compute.v1.INodeGroupNode>): void; + listNodes( + request: protos.google.cloud.compute.v1.IListNodesNodeGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNodesNodeGroupsRequest, + protos.google.cloud.compute.v1.INodeGroupsListNodes|null|undefined, + protos.google.cloud.compute.v1.INodeGroupNode>): void; + listNodes( + request?: protos.google.cloud.compute.v1.IListNodesNodeGroupsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListNodesNodeGroupsRequest, + protos.google.cloud.compute.v1.INodeGroupsListNodes|null|undefined, + protos.google.cloud.compute.v1.INodeGroupNode>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListNodesNodeGroupsRequest, + protos.google.cloud.compute.v1.INodeGroupsListNodes|null|undefined, + protos.google.cloud.compute.v1.INodeGroupNode>): + Promise<[ + protos.google.cloud.compute.v1.INodeGroupNode[], + protos.google.cloud.compute.v1.IListNodesNodeGroupsRequest|null, + protos.google.cloud.compute.v1.INodeGroupsListNodes + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'node_group': request.nodeGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.listNodes(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.nodeGroup + * Name of the NodeGroup resource whose nodes you want to list. + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.NodeGroupNode | NodeGroupNode} 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 `listNodesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listNodesStream( + request?: protos.google.cloud.compute.v1.IListNodesNodeGroupsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'node_group': request.nodeGroup ?? '', + }); + const defaultCallSettings = this._defaults['listNodes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listNodes.createStream( + this.innerApiCalls.listNodes as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listNodes`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.nodeGroup + * Name of the NodeGroup resource whose nodes you want to list. + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.NodeGroupNode | NodeGroupNode}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/node_groups.list_nodes.js + * region_tag:compute_v1_generated_NodeGroups_ListNodes_async + */ + listNodesAsync( + request?: protos.google.cloud.compute.v1.IListNodesNodeGroupsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'node_group': request.nodeGroup ?? '', + }); + const defaultCallSettings = this._defaults['listNodes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listNodes.asyncIterate( + this.innerApiCalls['listNodes'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.nodeGroupsStub && !this._terminated) { + return this.nodeGroupsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/node_groups_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_groups_client_config.json new file mode 100644 index 00000000000..2116a1c8fc1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_groups_client_config.json @@ -0,0 +1,82 @@ +{ + "interfaces": { + "google.cloud.compute.v1.NodeGroups": { + "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": { + "AddNodes": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteNodes": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListNodes": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetNodeTemplate": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SimulateMaintenanceEvent": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/node_groups_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_groups_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_groups_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/node_templates_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_templates_client.ts new file mode 100644 index 00000000000..d0948d7f2ef --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_templates_client.ts @@ -0,0 +1,1070 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/node_templates_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './node_templates_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The NodeTemplates API. + * @class + * @memberof v1 + */ +export class NodeTemplatesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + nodeTemplatesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of NodeTemplatesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new NodeTemplatesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof NodeTemplatesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.NodeTemplates', 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.nodeTemplatesStub) { + return this.nodeTemplatesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.NodeTemplates. + this.nodeTemplatesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.NodeTemplates') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.NodeTemplates, + 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 nodeTemplatesStubMethods = + ['aggregatedList', 'delete', 'get', 'getIamPolicy', 'insert', 'list', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of nodeTemplatesStubMethods) { + const callPromise = this.nodeTemplatesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.nodeTemplatesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified NodeTemplate resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.nodeTemplate + * Name of the NodeTemplate resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/node_templates.delete.js + * region_tag:compute_v1_generated_NodeTemplates_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteNodeTemplateRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteNodeTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNodeTemplateRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteNodeTemplateRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNodeTemplateRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteNodeTemplateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNodeTemplateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteNodeTemplateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'node_template': request.nodeTemplate ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified node template. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.nodeTemplate + * Name of the node template to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @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.compute.v1.NodeTemplate | NodeTemplate}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/node_templates.get.js + * region_tag:compute_v1_generated_NodeTemplates_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetNodeTemplateRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INodeTemplate, + protos.google.cloud.compute.v1.IGetNodeTemplateRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetNodeTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.INodeTemplate, + protos.google.cloud.compute.v1.IGetNodeTemplateRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetNodeTemplateRequest, + callback: Callback< + protos.google.cloud.compute.v1.INodeTemplate, + protos.google.cloud.compute.v1.IGetNodeTemplateRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetNodeTemplateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.INodeTemplate, + protos.google.cloud.compute.v1.IGetNodeTemplateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.INodeTemplate, + protos.google.cloud.compute.v1.IGetNodeTemplateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.INodeTemplate, + protos.google.cloud.compute.v1.IGetNodeTemplateRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'node_template': request.nodeTemplate ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/node_templates.get_iam_policy.js + * region_tag:compute_v1_generated_NodeTemplates_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyNodeTemplateRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNodeTemplateRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyNodeTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNodeTemplateRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyNodeTemplateRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNodeTemplateRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyNodeTemplateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNodeTemplateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNodeTemplateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyNodeTemplateRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Creates a NodeTemplate resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.NodeTemplate} request.nodeTemplateResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/node_templates.insert.js + * region_tag:compute_v1_generated_NodeTemplates_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertNodeTemplateRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertNodeTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNodeTemplateRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertNodeTemplateRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNodeTemplateRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertNodeTemplateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNodeTemplateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertNodeTemplateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {google.cloud.compute.v1.RegionSetPolicyRequest} request.regionSetPolicyRequestResource + * The body resource for this request + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/node_templates.set_iam_policy.js + * region_tag:compute_v1_generated_NodeTemplates_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyNodeTemplateRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNodeTemplateRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyNodeTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNodeTemplateRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyNodeTemplateRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNodeTemplateRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyNodeTemplateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNodeTemplateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNodeTemplateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyNodeTemplateRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/node_templates.test_iam_permissions.js + * region_tag:compute_v1_generated_NodeTemplates_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsNodeTemplateRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNodeTemplateRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsNodeTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNodeTemplateRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsNodeTemplateRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNodeTemplateRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsNodeTemplateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNodeTemplateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNodeTemplateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsNodeTemplateRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + +/** + * Retrieves an aggregated list of node templates. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.NodeTemplatesScopedList | NodeTemplatesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/node_templates.aggregated_list.js + * region_tag:compute_v1_generated_NodeTemplates_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListNodeTemplatesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.INodeTemplatesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.INodeTemplatesScopedList]>; + } + /** + * Retrieves a list of node templates available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.NodeTemplate | NodeTemplate}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListNodeTemplatesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INodeTemplate[], + protos.google.cloud.compute.v1.IListNodeTemplatesRequest|null, + protos.google.cloud.compute.v1.INodeTemplateList + ]>; + list( + request: protos.google.cloud.compute.v1.IListNodeTemplatesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNodeTemplatesRequest, + protos.google.cloud.compute.v1.INodeTemplateList|null|undefined, + protos.google.cloud.compute.v1.INodeTemplate>): void; + list( + request: protos.google.cloud.compute.v1.IListNodeTemplatesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNodeTemplatesRequest, + protos.google.cloud.compute.v1.INodeTemplateList|null|undefined, + protos.google.cloud.compute.v1.INodeTemplate>): void; + list( + request?: protos.google.cloud.compute.v1.IListNodeTemplatesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListNodeTemplatesRequest, + protos.google.cloud.compute.v1.INodeTemplateList|null|undefined, + protos.google.cloud.compute.v1.INodeTemplate>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListNodeTemplatesRequest, + protos.google.cloud.compute.v1.INodeTemplateList|null|undefined, + protos.google.cloud.compute.v1.INodeTemplate>): + Promise<[ + protos.google.cloud.compute.v1.INodeTemplate[], + protos.google.cloud.compute.v1.IListNodeTemplatesRequest|null, + protos.google.cloud.compute.v1.INodeTemplateList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.NodeTemplate | NodeTemplate} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListNodeTemplatesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.NodeTemplate | NodeTemplate}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/node_templates.list.js + * region_tag:compute_v1_generated_NodeTemplates_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListNodeTemplatesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.nodeTemplatesStub && !this._terminated) { + return this.nodeTemplatesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/node_templates_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_templates_client_config.json new file mode 100644 index 00000000000..59375d22506 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_templates_client_config.json @@ -0,0 +1,58 @@ +{ + "interfaces": { + "google.cloud.compute.v1.NodeTemplates": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/node_templates_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_templates_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_templates_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/node_types_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_types_client.ts new file mode 100644 index 00000000000..1fdc5298277 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_types_client.ts @@ -0,0 +1,653 @@ +// Copyright 2023 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/node_types_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './node_types_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The NodeTypes API. + * @class + * @memberof v1 + */ +export class NodeTypesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + nodeTypesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of NodeTypesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new NodeTypesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof NodeTypesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.NodeTypes', 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.nodeTypesStub) { + return this.nodeTypesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.NodeTypes. + this.nodeTypesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.NodeTypes') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.NodeTypes, + 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 nodeTypesStubMethods = + ['aggregatedList', 'get', 'list']; + for (const methodName of nodeTypesStubMethods) { + const callPromise = this.nodeTypesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.nodeTypesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute.readonly', + 'https://www.googleapis.com/auth/compute', + '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 -- + // ------------------- +/** + * Returns the specified node type. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.nodeType + * Name of the node type to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.NodeType | NodeType}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/node_types.get.js + * region_tag:compute_v1_generated_NodeTypes_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetNodeTypeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INodeType, + protos.google.cloud.compute.v1.IGetNodeTypeRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetNodeTypeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.INodeType, + protos.google.cloud.compute.v1.IGetNodeTypeRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetNodeTypeRequest, + callback: Callback< + protos.google.cloud.compute.v1.INodeType, + protos.google.cloud.compute.v1.IGetNodeTypeRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetNodeTypeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.INodeType, + protos.google.cloud.compute.v1.IGetNodeTypeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.INodeType, + protos.google.cloud.compute.v1.IGetNodeTypeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.INodeType, + protos.google.cloud.compute.v1.IGetNodeTypeRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'node_type': request.nodeType ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } + + +/** + * Retrieves an aggregated list of node types. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.NodeTypesScopedList | NodeTypesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/node_types.aggregated_list.js + * region_tag:compute_v1_generated_NodeTypes_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListNodeTypesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.INodeTypesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.INodeTypesScopedList]>; + } + /** + * Retrieves a list of node types available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.NodeType | NodeType}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListNodeTypesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INodeType[], + protos.google.cloud.compute.v1.IListNodeTypesRequest|null, + protos.google.cloud.compute.v1.INodeTypeList + ]>; + list( + request: protos.google.cloud.compute.v1.IListNodeTypesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNodeTypesRequest, + protos.google.cloud.compute.v1.INodeTypeList|null|undefined, + protos.google.cloud.compute.v1.INodeType>): void; + list( + request: protos.google.cloud.compute.v1.IListNodeTypesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListNodeTypesRequest, + protos.google.cloud.compute.v1.INodeTypeList|null|undefined, + protos.google.cloud.compute.v1.INodeType>): void; + list( + request?: protos.google.cloud.compute.v1.IListNodeTypesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListNodeTypesRequest, + protos.google.cloud.compute.v1.INodeTypeList|null|undefined, + protos.google.cloud.compute.v1.INodeType>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListNodeTypesRequest, + protos.google.cloud.compute.v1.INodeTypeList|null|undefined, + protos.google.cloud.compute.v1.INodeType>): + Promise<[ + protos.google.cloud.compute.v1.INodeType[], + protos.google.cloud.compute.v1.IListNodeTypesRequest|null, + protos.google.cloud.compute.v1.INodeTypeList + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @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 google.cloud.compute.v1.NodeType | NodeType} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListNodeTypesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * The name of the zone for this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.NodeType | NodeType}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/node_types.list.js + * region_tag:compute_v1_generated_NodeTypes_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListNodeTypesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.nodeTypesStub && !this._terminated) { + return this.nodeTypesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/node_types_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_types_client_config.json new file mode 100644 index 00000000000..47c4adace17 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_types_client_config.json @@ -0,0 +1,38 @@ +{ + "interfaces": { + "google.cloud.compute.v1.NodeTypes": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/node_types_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_types_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/node_types_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/packet_mirrorings_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/packet_mirrorings_client.ts new file mode 100644 index 00000000000..e3f05137ff2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/packet_mirrorings_client.ts @@ -0,0 +1,1005 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/packet_mirrorings_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './packet_mirrorings_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The PacketMirrorings API. + * @class + * @memberof v1 + */ +export class PacketMirroringsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + packetMirroringsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of PacketMirroringsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new PacketMirroringsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof PacketMirroringsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.PacketMirrorings', 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.packetMirroringsStub) { + return this.packetMirroringsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.PacketMirrorings. + this.packetMirroringsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.PacketMirrorings') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.PacketMirrorings, + 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 packetMirroringsStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'list', 'patch', 'testIamPermissions']; + for (const methodName of packetMirroringsStubMethods) { + const callPromise = this.packetMirroringsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.packetMirroringsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified PacketMirroring resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.packetMirroring + * Name of the PacketMirroring resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/packet_mirrorings.delete.js + * region_tag:compute_v1_generated_PacketMirrorings_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeletePacketMirroringRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeletePacketMirroringRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePacketMirroringRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeletePacketMirroringRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePacketMirroringRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeletePacketMirroringRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePacketMirroringRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePacketMirroringRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'packet_mirroring': request.packetMirroring ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified PacketMirroring resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.packetMirroring + * Name of the PacketMirroring resource to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @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.compute.v1.PacketMirroring | PacketMirroring}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/packet_mirrorings.get.js + * region_tag:compute_v1_generated_PacketMirrorings_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetPacketMirroringRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPacketMirroring, + protos.google.cloud.compute.v1.IGetPacketMirroringRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetPacketMirroringRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPacketMirroring, + protos.google.cloud.compute.v1.IGetPacketMirroringRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetPacketMirroringRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPacketMirroring, + protos.google.cloud.compute.v1.IGetPacketMirroringRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetPacketMirroringRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPacketMirroring, + protos.google.cloud.compute.v1.IGetPacketMirroringRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPacketMirroring, + protos.google.cloud.compute.v1.IGetPacketMirroringRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPacketMirroring, + protos.google.cloud.compute.v1.IGetPacketMirroringRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'packet_mirroring': request.packetMirroring ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a PacketMirroring resource in the specified project and region using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.PacketMirroring} request.packetMirroringResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/packet_mirrorings.insert.js + * region_tag:compute_v1_generated_PacketMirrorings_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertPacketMirroringRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertPacketMirroringRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertPacketMirroringRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertPacketMirroringRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertPacketMirroringRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertPacketMirroringRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertPacketMirroringRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertPacketMirroringRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified PacketMirroring resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.packetMirroring + * Name of the PacketMirroring resource to patch. + * @param {google.cloud.compute.v1.PacketMirroring} request.packetMirroringResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/packet_mirrorings.patch.js + * region_tag:compute_v1_generated_PacketMirrorings_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchPacketMirroringRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchPacketMirroringRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPacketMirroringRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchPacketMirroringRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPacketMirroringRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchPacketMirroringRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPacketMirroringRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPacketMirroringRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'packet_mirroring': request.packetMirroring ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/packet_mirrorings.test_iam_permissions.js + * region_tag:compute_v1_generated_PacketMirrorings_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsPacketMirroringRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsPacketMirroringRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsPacketMirroringRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsPacketMirroringRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsPacketMirroringRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsPacketMirroringRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsPacketMirroringRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsPacketMirroringRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsPacketMirroringRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsPacketMirroringRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + +/** + * Retrieves an aggregated list of packetMirrorings. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.PacketMirroringsScopedList | PacketMirroringsScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/packet_mirrorings.aggregated_list.js + * region_tag:compute_v1_generated_PacketMirrorings_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListPacketMirroringsRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IPacketMirroringsScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IPacketMirroringsScopedList]>; + } + /** + * Retrieves a list of PacketMirroring resources available to the specified project and region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.PacketMirroring | PacketMirroring}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListPacketMirroringsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPacketMirroring[], + protos.google.cloud.compute.v1.IListPacketMirroringsRequest|null, + protos.google.cloud.compute.v1.IPacketMirroringList + ]>; + list( + request: protos.google.cloud.compute.v1.IListPacketMirroringsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListPacketMirroringsRequest, + protos.google.cloud.compute.v1.IPacketMirroringList|null|undefined, + protos.google.cloud.compute.v1.IPacketMirroring>): void; + list( + request: protos.google.cloud.compute.v1.IListPacketMirroringsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListPacketMirroringsRequest, + protos.google.cloud.compute.v1.IPacketMirroringList|null|undefined, + protos.google.cloud.compute.v1.IPacketMirroring>): void; + list( + request?: protos.google.cloud.compute.v1.IListPacketMirroringsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListPacketMirroringsRequest, + protos.google.cloud.compute.v1.IPacketMirroringList|null|undefined, + protos.google.cloud.compute.v1.IPacketMirroring>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListPacketMirroringsRequest, + protos.google.cloud.compute.v1.IPacketMirroringList|null|undefined, + protos.google.cloud.compute.v1.IPacketMirroring>): + Promise<[ + protos.google.cloud.compute.v1.IPacketMirroring[], + protos.google.cloud.compute.v1.IListPacketMirroringsRequest|null, + protos.google.cloud.compute.v1.IPacketMirroringList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.PacketMirroring | PacketMirroring} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListPacketMirroringsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.PacketMirroring | PacketMirroring}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/packet_mirrorings.list.js + * region_tag:compute_v1_generated_PacketMirrorings_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListPacketMirroringsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.packetMirroringsStub && !this._terminated) { + return this.packetMirroringsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/packet_mirrorings_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/packet_mirrorings_client_config.json new file mode 100644 index 00000000000..2783552910b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/packet_mirrorings_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.compute.v1.PacketMirrorings": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/packet_mirrorings_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/packet_mirrorings_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/packet_mirrorings_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/projects_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/projects_client.ts new file mode 100644 index 00000000000..93d5aef0973 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/projects_client.ts @@ -0,0 +1,1628 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/projects_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './projects_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Projects API. + * @class + * @memberof v1 + */ +export class ProjectsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + projectsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProjectsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ProjectsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ProjectsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + getXpnResources: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'resources'), + listXpnHosts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.Projects', 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.projectsStub) { + return this.projectsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.Projects. + this.projectsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Projects') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.Projects, + 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 projectsStubMethods = + ['disableXpnHost', 'disableXpnResource', 'enableXpnHost', 'enableXpnResource', 'get', 'getXpnHost', 'getXpnResources', 'listXpnHosts', 'moveDisk', 'moveInstance', 'setCommonInstanceMetadata', 'setDefaultNetworkTier', 'setUsageExportBucket']; + for (const methodName of projectsStubMethods) { + const callPromise = this.projectsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.projectsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Disable this project as a shared VPC host project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/projects.disable_xpn_host.js + * region_tag:compute_v1_generated_Projects_DisableXpnHost_async + */ + disableXpnHost( + request?: protos.google.cloud.compute.v1.IDisableXpnHostProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + disableXpnHost( + request: protos.google.cloud.compute.v1.IDisableXpnHostProjectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDisableXpnHostProjectRequest|null|undefined, + {}|null|undefined>): void; + disableXpnHost( + request: protos.google.cloud.compute.v1.IDisableXpnHostProjectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDisableXpnHostProjectRequest|null|undefined, + {}|null|undefined>): void; + disableXpnHost( + request?: protos.google.cloud.compute.v1.IDisableXpnHostProjectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDisableXpnHostProjectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDisableXpnHostProjectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.disableXpnHost(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Disable a service resource (also known as service project) associated with this host project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {google.cloud.compute.v1.ProjectsDisableXpnResourceRequest} request.projectsDisableXpnResourceRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/projects.disable_xpn_resource.js + * region_tag:compute_v1_generated_Projects_DisableXpnResource_async + */ + disableXpnResource( + request?: protos.google.cloud.compute.v1.IDisableXpnResourceProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + disableXpnResource( + request: protos.google.cloud.compute.v1.IDisableXpnResourceProjectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDisableXpnResourceProjectRequest|null|undefined, + {}|null|undefined>): void; + disableXpnResource( + request: protos.google.cloud.compute.v1.IDisableXpnResourceProjectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDisableXpnResourceProjectRequest|null|undefined, + {}|null|undefined>): void; + disableXpnResource( + request?: protos.google.cloud.compute.v1.IDisableXpnResourceProjectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDisableXpnResourceProjectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDisableXpnResourceProjectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.disableXpnResource(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Enable this project as a shared VPC host project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/projects.enable_xpn_host.js + * region_tag:compute_v1_generated_Projects_EnableXpnHost_async + */ + enableXpnHost( + request?: protos.google.cloud.compute.v1.IEnableXpnHostProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + enableXpnHost( + request: protos.google.cloud.compute.v1.IEnableXpnHostProjectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IEnableXpnHostProjectRequest|null|undefined, + {}|null|undefined>): void; + enableXpnHost( + request: protos.google.cloud.compute.v1.IEnableXpnHostProjectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IEnableXpnHostProjectRequest|null|undefined, + {}|null|undefined>): void; + enableXpnHost( + request?: protos.google.cloud.compute.v1.IEnableXpnHostProjectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IEnableXpnHostProjectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IEnableXpnHostProjectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.enableXpnHost(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Enable service resource (a.k.a service project) for a host project, so that subnets in the host project can be used by instances in the service project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {google.cloud.compute.v1.ProjectsEnableXpnResourceRequest} request.projectsEnableXpnResourceRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/projects.enable_xpn_resource.js + * region_tag:compute_v1_generated_Projects_EnableXpnResource_async + */ + enableXpnResource( + request?: protos.google.cloud.compute.v1.IEnableXpnResourceProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + enableXpnResource( + request: protos.google.cloud.compute.v1.IEnableXpnResourceProjectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IEnableXpnResourceProjectRequest|null|undefined, + {}|null|undefined>): void; + enableXpnResource( + request: protos.google.cloud.compute.v1.IEnableXpnResourceProjectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IEnableXpnResourceProjectRequest|null|undefined, + {}|null|undefined>): void; + enableXpnResource( + request?: protos.google.cloud.compute.v1.IEnableXpnResourceProjectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IEnableXpnResourceProjectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IEnableXpnResourceProjectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.enableXpnResource(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified Project resource. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.Project | Project}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/projects.get.js + * region_tag:compute_v1_generated_Projects_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetProjectRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IProject, + protos.google.cloud.compute.v1.IGetProjectRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetProjectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IProject, + protos.google.cloud.compute.v1.IGetProjectRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetProjectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IProject, + protos.google.cloud.compute.v1.IGetProjectRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetProjectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IProject, + protos.google.cloud.compute.v1.IGetProjectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IProject, + protos.google.cloud.compute.v1.IGetProjectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IProject, + protos.google.cloud.compute.v1.IGetProjectRequest|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the shared VPC host project that this project links to. May be empty if no link exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @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.compute.v1.Project | Project}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/projects.get_xpn_host.js + * region_tag:compute_v1_generated_Projects_GetXpnHost_async + */ + getXpnHost( + request?: protos.google.cloud.compute.v1.IGetXpnHostProjectRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IProject, + protos.google.cloud.compute.v1.IGetXpnHostProjectRequest|undefined, {}|undefined + ]>; + getXpnHost( + request: protos.google.cloud.compute.v1.IGetXpnHostProjectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IProject, + protos.google.cloud.compute.v1.IGetXpnHostProjectRequest|null|undefined, + {}|null|undefined>): void; + getXpnHost( + request: protos.google.cloud.compute.v1.IGetXpnHostProjectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IProject, + protos.google.cloud.compute.v1.IGetXpnHostProjectRequest|null|undefined, + {}|null|undefined>): void; + getXpnHost( + request?: protos.google.cloud.compute.v1.IGetXpnHostProjectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IProject, + protos.google.cloud.compute.v1.IGetXpnHostProjectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IProject, + protos.google.cloud.compute.v1.IGetXpnHostProjectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IProject, + protos.google.cloud.compute.v1.IGetXpnHostProjectRequest|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.getXpnHost(request, options, callback); + } +/** + * Moves a persistent disk from one zone to another. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.DiskMoveRequest} request.diskMoveRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/projects.move_disk.js + * region_tag:compute_v1_generated_Projects_MoveDisk_async + */ + moveDisk( + request?: protos.google.cloud.compute.v1.IMoveDiskProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + moveDisk( + request: protos.google.cloud.compute.v1.IMoveDiskProjectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IMoveDiskProjectRequest|null|undefined, + {}|null|undefined>): void; + moveDisk( + request: protos.google.cloud.compute.v1.IMoveDiskProjectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IMoveDiskProjectRequest|null|undefined, + {}|null|undefined>): void; + moveDisk( + request?: protos.google.cloud.compute.v1.IMoveDiskProjectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IMoveDiskProjectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IMoveDiskProjectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.moveDisk(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Moves an instance and its attached persistent disks from one zone to another. *Note*: Moving VMs or disks by using this method might cause unexpected behavior. For more information, see the [known issue](/compute/docs/troubleshooting/known-issues#moving_vms_or_disks_using_the_moveinstance_api_or_the_causes_unexpected_behavior). + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.InstanceMoveRequest} request.instanceMoveRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/projects.move_instance.js + * region_tag:compute_v1_generated_Projects_MoveInstance_async + */ + moveInstance( + request?: protos.google.cloud.compute.v1.IMoveInstanceProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + moveInstance( + request: protos.google.cloud.compute.v1.IMoveInstanceProjectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IMoveInstanceProjectRequest|null|undefined, + {}|null|undefined>): void; + moveInstance( + request: protos.google.cloud.compute.v1.IMoveInstanceProjectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IMoveInstanceProjectRequest|null|undefined, + {}|null|undefined>): void; + moveInstance( + request?: protos.google.cloud.compute.v1.IMoveInstanceProjectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IMoveInstanceProjectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IMoveInstanceProjectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.moveInstance(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets metadata common to all instances within the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.Metadata} request.metadataResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/projects.set_common_instance_metadata.js + * region_tag:compute_v1_generated_Projects_SetCommonInstanceMetadata_async + */ + setCommonInstanceMetadata( + request?: protos.google.cloud.compute.v1.ISetCommonInstanceMetadataProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setCommonInstanceMetadata( + request: protos.google.cloud.compute.v1.ISetCommonInstanceMetadataProjectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetCommonInstanceMetadataProjectRequest|null|undefined, + {}|null|undefined>): void; + setCommonInstanceMetadata( + request: protos.google.cloud.compute.v1.ISetCommonInstanceMetadataProjectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetCommonInstanceMetadataProjectRequest|null|undefined, + {}|null|undefined>): void; + setCommonInstanceMetadata( + request?: protos.google.cloud.compute.v1.ISetCommonInstanceMetadataProjectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetCommonInstanceMetadataProjectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetCommonInstanceMetadataProjectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.setCommonInstanceMetadata(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the default network tier of the project. The default network tier is used when an address/forwardingRule/instance is created without specifying the network tier field. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {google.cloud.compute.v1.ProjectsSetDefaultNetworkTierRequest} request.projectsSetDefaultNetworkTierRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/projects.set_default_network_tier.js + * region_tag:compute_v1_generated_Projects_SetDefaultNetworkTier_async + */ + setDefaultNetworkTier( + request?: protos.google.cloud.compute.v1.ISetDefaultNetworkTierProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setDefaultNetworkTier( + request: protos.google.cloud.compute.v1.ISetDefaultNetworkTierProjectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetDefaultNetworkTierProjectRequest|null|undefined, + {}|null|undefined>): void; + setDefaultNetworkTier( + request: protos.google.cloud.compute.v1.ISetDefaultNetworkTierProjectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetDefaultNetworkTierProjectRequest|null|undefined, + {}|null|undefined>): void; + setDefaultNetworkTier( + request?: protos.google.cloud.compute.v1.ISetDefaultNetworkTierProjectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetDefaultNetworkTierProjectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetDefaultNetworkTierProjectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.setDefaultNetworkTier(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Enables the usage export feature and sets the usage export bucket where reports are stored. If you provide an empty request body using this method, the usage export feature will be disabled. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.UsageExportLocation} request.usageExportLocationResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/projects.set_usage_export_bucket.js + * region_tag:compute_v1_generated_Projects_SetUsageExportBucket_async + */ + setUsageExportBucket( + request?: protos.google.cloud.compute.v1.ISetUsageExportBucketProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setUsageExportBucket( + request: protos.google.cloud.compute.v1.ISetUsageExportBucketProjectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUsageExportBucketProjectRequest|null|undefined, + {}|null|undefined>): void; + setUsageExportBucket( + request: protos.google.cloud.compute.v1.ISetUsageExportBucketProjectRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUsageExportBucketProjectRequest|null|undefined, + {}|null|undefined>): void; + setUsageExportBucket( + request?: protos.google.cloud.compute.v1.ISetUsageExportBucketProjectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUsageExportBucketProjectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUsageExportBucketProjectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.setUsageExportBucket(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Gets service resources (a.k.a service project) associated with this host project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.XpnResourceId | XpnResourceId}. + * 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 `getXpnResourcesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + getXpnResources( + request?: protos.google.cloud.compute.v1.IGetXpnResourcesProjectsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IXpnResourceId[], + protos.google.cloud.compute.v1.IGetXpnResourcesProjectsRequest|null, + protos.google.cloud.compute.v1.IProjectsGetXpnResources + ]>; + getXpnResources( + request: protos.google.cloud.compute.v1.IGetXpnResourcesProjectsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IGetXpnResourcesProjectsRequest, + protos.google.cloud.compute.v1.IProjectsGetXpnResources|null|undefined, + protos.google.cloud.compute.v1.IXpnResourceId>): void; + getXpnResources( + request: protos.google.cloud.compute.v1.IGetXpnResourcesProjectsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IGetXpnResourcesProjectsRequest, + protos.google.cloud.compute.v1.IProjectsGetXpnResources|null|undefined, + protos.google.cloud.compute.v1.IXpnResourceId>): void; + getXpnResources( + request?: protos.google.cloud.compute.v1.IGetXpnResourcesProjectsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IGetXpnResourcesProjectsRequest, + protos.google.cloud.compute.v1.IProjectsGetXpnResources|null|undefined, + protos.google.cloud.compute.v1.IXpnResourceId>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IGetXpnResourcesProjectsRequest, + protos.google.cloud.compute.v1.IProjectsGetXpnResources|null|undefined, + protos.google.cloud.compute.v1.IXpnResourceId>): + Promise<[ + protos.google.cloud.compute.v1.IXpnResourceId[], + protos.google.cloud.compute.v1.IGetXpnResourcesProjectsRequest|null, + protos.google.cloud.compute.v1.IProjectsGetXpnResources + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.getXpnResources(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.XpnResourceId | XpnResourceId} 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 `getXpnResourcesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + getXpnResourcesStream( + request?: protos.google.cloud.compute.v1.IGetXpnResourcesProjectsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['getXpnResources']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.getXpnResources.createStream( + this.innerApiCalls.getXpnResources as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `getXpnResources`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.XpnResourceId | XpnResourceId}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/projects.get_xpn_resources.js + * region_tag:compute_v1_generated_Projects_GetXpnResources_async + */ + getXpnResourcesAsync( + request?: protos.google.cloud.compute.v1.IGetXpnResourcesProjectsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['getXpnResources']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.getXpnResources.asyncIterate( + this.innerApiCalls['getXpnResources'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists all shared VPC host projects visible to the user in an organization. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {google.cloud.compute.v1.ProjectsListXpnHostsRequest} request.projectsListXpnHostsRequestResource + * The body resource for this request + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Project | Project}. + * 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 `listXpnHostsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listXpnHosts( + request?: protos.google.cloud.compute.v1.IListXpnHostsProjectsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IProject[], + protos.google.cloud.compute.v1.IListXpnHostsProjectsRequest|null, + protos.google.cloud.compute.v1.IXpnHostList + ]>; + listXpnHosts( + request: protos.google.cloud.compute.v1.IListXpnHostsProjectsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListXpnHostsProjectsRequest, + protos.google.cloud.compute.v1.IXpnHostList|null|undefined, + protos.google.cloud.compute.v1.IProject>): void; + listXpnHosts( + request: protos.google.cloud.compute.v1.IListXpnHostsProjectsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListXpnHostsProjectsRequest, + protos.google.cloud.compute.v1.IXpnHostList|null|undefined, + protos.google.cloud.compute.v1.IProject>): void; + listXpnHosts( + request?: protos.google.cloud.compute.v1.IListXpnHostsProjectsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListXpnHostsProjectsRequest, + protos.google.cloud.compute.v1.IXpnHostList|null|undefined, + protos.google.cloud.compute.v1.IProject>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListXpnHostsProjectsRequest, + protos.google.cloud.compute.v1.IXpnHostList|null|undefined, + protos.google.cloud.compute.v1.IProject>): + Promise<[ + protos.google.cloud.compute.v1.IProject[], + protos.google.cloud.compute.v1.IListXpnHostsProjectsRequest|null, + protos.google.cloud.compute.v1.IXpnHostList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.listXpnHosts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {google.cloud.compute.v1.ProjectsListXpnHostsRequest} request.projectsListXpnHostsRequestResource + * The body resource for this request + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Project | Project} 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 `listXpnHostsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listXpnHostsStream( + request?: protos.google.cloud.compute.v1.IListXpnHostsProjectsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['listXpnHosts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listXpnHosts.createStream( + this.innerApiCalls.listXpnHosts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listXpnHosts`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {google.cloud.compute.v1.ProjectsListXpnHostsRequest} request.projectsListXpnHostsRequestResource + * The body resource for this request + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Project | Project}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/projects.list_xpn_hosts.js + * region_tag:compute_v1_generated_Projects_ListXpnHosts_async + */ + listXpnHostsAsync( + request?: protos.google.cloud.compute.v1.IListXpnHostsProjectsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['listXpnHosts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listXpnHosts.asyncIterate( + this.innerApiCalls['listXpnHosts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.projectsStub && !this._terminated) { + return this.projectsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/projects_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/projects_client_config.json new file mode 100644 index 00000000000..9863abe9f6b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/projects_client_config.json @@ -0,0 +1,78 @@ +{ + "interfaces": { + "google.cloud.compute.v1.Projects": { + "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": { + "DisableXpnHost": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DisableXpnResource": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "EnableXpnHost": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "EnableXpnResource": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetXpnHost": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetXpnResources": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListXpnHosts": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "MoveDisk": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "MoveInstance": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetCommonInstanceMetadata": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetDefaultNetworkTier": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetUsageExportBucket": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/projects_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/projects_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/projects_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/public_advertised_prefixes_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/public_advertised_prefixes_client.ts new file mode 100644 index 00000000000..fb17be12531 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/public_advertised_prefixes_client.ts @@ -0,0 +1,847 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/public_advertised_prefixes_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './public_advertised_prefixes_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The PublicAdvertisedPrefixes API. + * @class + * @memberof v1 + */ +export class PublicAdvertisedPrefixesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + publicAdvertisedPrefixesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of PublicAdvertisedPrefixesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new PublicAdvertisedPrefixesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof PublicAdvertisedPrefixesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.PublicAdvertisedPrefixes', 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.publicAdvertisedPrefixesStub) { + return this.publicAdvertisedPrefixesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.PublicAdvertisedPrefixes. + this.publicAdvertisedPrefixesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.PublicAdvertisedPrefixes') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.PublicAdvertisedPrefixes, + 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 publicAdvertisedPrefixesStubMethods = + ['delete', 'get', 'insert', 'list', 'patch']; + for (const methodName of publicAdvertisedPrefixesStubMethods) { + const callPromise = this.publicAdvertisedPrefixesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.publicAdvertisedPrefixesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified PublicAdvertisedPrefix + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.publicAdvertisedPrefix + * Name of the PublicAdvertisedPrefix resource to delete. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/public_advertised_prefixes.delete.js + * region_tag:compute_v1_generated_PublicAdvertisedPrefixes_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeletePublicAdvertisedPrefixeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeletePublicAdvertisedPrefixeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePublicAdvertisedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeletePublicAdvertisedPrefixeRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePublicAdvertisedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeletePublicAdvertisedPrefixeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePublicAdvertisedPrefixeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePublicAdvertisedPrefixeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'public_advertised_prefix': request.publicAdvertisedPrefix ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified PublicAdvertisedPrefix resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.publicAdvertisedPrefix + * Name of the PublicAdvertisedPrefix resource to return. + * @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.compute.v1.PublicAdvertisedPrefix | PublicAdvertisedPrefix}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/public_advertised_prefixes.get.js + * region_tag:compute_v1_generated_PublicAdvertisedPrefixes_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetPublicAdvertisedPrefixeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPublicAdvertisedPrefix, + protos.google.cloud.compute.v1.IGetPublicAdvertisedPrefixeRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetPublicAdvertisedPrefixeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPublicAdvertisedPrefix, + protos.google.cloud.compute.v1.IGetPublicAdvertisedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetPublicAdvertisedPrefixeRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPublicAdvertisedPrefix, + protos.google.cloud.compute.v1.IGetPublicAdvertisedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetPublicAdvertisedPrefixeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPublicAdvertisedPrefix, + protos.google.cloud.compute.v1.IGetPublicAdvertisedPrefixeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPublicAdvertisedPrefix, + protos.google.cloud.compute.v1.IGetPublicAdvertisedPrefixeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPublicAdvertisedPrefix, + protos.google.cloud.compute.v1.IGetPublicAdvertisedPrefixeRequest|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({ + 'project': request.project ?? '', + 'public_advertised_prefix': request.publicAdvertisedPrefix ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a PublicAdvertisedPrefix in the specified project using the parameters that are included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {google.cloud.compute.v1.PublicAdvertisedPrefix} request.publicAdvertisedPrefixResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/public_advertised_prefixes.insert.js + * region_tag:compute_v1_generated_PublicAdvertisedPrefixes_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertPublicAdvertisedPrefixeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertPublicAdvertisedPrefixeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertPublicAdvertisedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertPublicAdvertisedPrefixeRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertPublicAdvertisedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertPublicAdvertisedPrefixeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertPublicAdvertisedPrefixeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertPublicAdvertisedPrefixeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified Router resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.publicAdvertisedPrefix + * Name of the PublicAdvertisedPrefix resource to patch. + * @param {google.cloud.compute.v1.PublicAdvertisedPrefix} request.publicAdvertisedPrefixResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/public_advertised_prefixes.patch.js + * region_tag:compute_v1_generated_PublicAdvertisedPrefixes_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchPublicAdvertisedPrefixeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchPublicAdvertisedPrefixeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPublicAdvertisedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchPublicAdvertisedPrefixeRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPublicAdvertisedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchPublicAdvertisedPrefixeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPublicAdvertisedPrefixeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPublicAdvertisedPrefixeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'public_advertised_prefix': request.publicAdvertisedPrefix ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Lists the PublicAdvertisedPrefixes for a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.PublicAdvertisedPrefix | PublicAdvertisedPrefix}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListPublicAdvertisedPrefixesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPublicAdvertisedPrefix[], + protos.google.cloud.compute.v1.IListPublicAdvertisedPrefixesRequest|null, + protos.google.cloud.compute.v1.IPublicAdvertisedPrefixList + ]>; + list( + request: protos.google.cloud.compute.v1.IListPublicAdvertisedPrefixesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListPublicAdvertisedPrefixesRequest, + protos.google.cloud.compute.v1.IPublicAdvertisedPrefixList|null|undefined, + protos.google.cloud.compute.v1.IPublicAdvertisedPrefix>): void; + list( + request: protos.google.cloud.compute.v1.IListPublicAdvertisedPrefixesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListPublicAdvertisedPrefixesRequest, + protos.google.cloud.compute.v1.IPublicAdvertisedPrefixList|null|undefined, + protos.google.cloud.compute.v1.IPublicAdvertisedPrefix>): void; + list( + request?: protos.google.cloud.compute.v1.IListPublicAdvertisedPrefixesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListPublicAdvertisedPrefixesRequest, + protos.google.cloud.compute.v1.IPublicAdvertisedPrefixList|null|undefined, + protos.google.cloud.compute.v1.IPublicAdvertisedPrefix>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListPublicAdvertisedPrefixesRequest, + protos.google.cloud.compute.v1.IPublicAdvertisedPrefixList|null|undefined, + protos.google.cloud.compute.v1.IPublicAdvertisedPrefix>): + Promise<[ + protos.google.cloud.compute.v1.IPublicAdvertisedPrefix[], + protos.google.cloud.compute.v1.IListPublicAdvertisedPrefixesRequest|null, + protos.google.cloud.compute.v1.IPublicAdvertisedPrefixList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.PublicAdvertisedPrefix | PublicAdvertisedPrefix} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListPublicAdvertisedPrefixesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.PublicAdvertisedPrefix | PublicAdvertisedPrefix}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/public_advertised_prefixes.list.js + * region_tag:compute_v1_generated_PublicAdvertisedPrefixes_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListPublicAdvertisedPrefixesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.publicAdvertisedPrefixesStub && !this._terminated) { + return this.publicAdvertisedPrefixesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/public_advertised_prefixes_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/public_advertised_prefixes_client_config.json new file mode 100644 index 00000000000..e33e314ed63 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/public_advertised_prefixes_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.compute.v1.PublicAdvertisedPrefixes": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/public_advertised_prefixes_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/public_advertised_prefixes_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/public_advertised_prefixes_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/public_delegated_prefixes_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/public_delegated_prefixes_client.ts new file mode 100644 index 00000000000..36b57c356e2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/public_delegated_prefixes_client.ts @@ -0,0 +1,926 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/public_delegated_prefixes_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './public_delegated_prefixes_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The PublicDelegatedPrefixes API. + * @class + * @memberof v1 + */ +export class PublicDelegatedPrefixesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + publicDelegatedPrefixesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of PublicDelegatedPrefixesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new PublicDelegatedPrefixesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof PublicDelegatedPrefixesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.PublicDelegatedPrefixes', 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.publicDelegatedPrefixesStub) { + return this.publicDelegatedPrefixesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.PublicDelegatedPrefixes. + this.publicDelegatedPrefixesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.PublicDelegatedPrefixes') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.PublicDelegatedPrefixes, + 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 publicDelegatedPrefixesStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'list', 'patch']; + for (const methodName of publicDelegatedPrefixesStubMethods) { + const callPromise = this.publicDelegatedPrefixesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.publicDelegatedPrefixesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified PublicDelegatedPrefix in the given region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.publicDelegatedPrefix + * Name of the PublicDelegatedPrefix resource to delete. + * @param {string} request.region + * Name of the region of this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/public_delegated_prefixes.delete.js + * region_tag:compute_v1_generated_PublicDelegatedPrefixes_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeletePublicDelegatedPrefixeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeletePublicDelegatedPrefixeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeletePublicDelegatedPrefixeRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeletePublicDelegatedPrefixeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'public_delegated_prefix': request.publicDelegatedPrefix ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified PublicDelegatedPrefix resource in the given region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.publicDelegatedPrefix + * Name of the PublicDelegatedPrefix resource to return. + * @param {string} request.region + * Name of the region of this request. + * @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.compute.v1.PublicDelegatedPrefix | PublicDelegatedPrefix}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/public_delegated_prefixes.get.js + * region_tag:compute_v1_generated_PublicDelegatedPrefixes_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetPublicDelegatedPrefixeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPublicDelegatedPrefix, + protos.google.cloud.compute.v1.IGetPublicDelegatedPrefixeRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetPublicDelegatedPrefixeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPublicDelegatedPrefix, + protos.google.cloud.compute.v1.IGetPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetPublicDelegatedPrefixeRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPublicDelegatedPrefix, + protos.google.cloud.compute.v1.IGetPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetPublicDelegatedPrefixeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPublicDelegatedPrefix, + protos.google.cloud.compute.v1.IGetPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPublicDelegatedPrefix, + protos.google.cloud.compute.v1.IGetPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPublicDelegatedPrefix, + protos.google.cloud.compute.v1.IGetPublicDelegatedPrefixeRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'public_delegated_prefix': request.publicDelegatedPrefix ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a PublicDelegatedPrefix in the specified project in the given region using the parameters that are included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {google.cloud.compute.v1.PublicDelegatedPrefix} request.publicDelegatedPrefixResource + * The body resource for this request + * @param {string} request.region + * Name of the region of this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/public_delegated_prefixes.insert.js + * region_tag:compute_v1_generated_PublicDelegatedPrefixes_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertPublicDelegatedPrefixeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertPublicDelegatedPrefixeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertPublicDelegatedPrefixeRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertPublicDelegatedPrefixeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified PublicDelegatedPrefix resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.publicDelegatedPrefix + * Name of the PublicDelegatedPrefix resource to patch. + * @param {google.cloud.compute.v1.PublicDelegatedPrefix} request.publicDelegatedPrefixResource + * The body resource for this request + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/public_delegated_prefixes.patch.js + * region_tag:compute_v1_generated_PublicDelegatedPrefixes_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchPublicDelegatedPrefixeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchPublicDelegatedPrefixeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchPublicDelegatedPrefixeRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchPublicDelegatedPrefixeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPublicDelegatedPrefixeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'public_delegated_prefix': request.publicDelegatedPrefix ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Lists all PublicDelegatedPrefix resources owned by the specific project across all scopes. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Name of the project scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.PublicDelegatedPrefixesScopedList | PublicDelegatedPrefixesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/public_delegated_prefixes.aggregated_list.js + * region_tag:compute_v1_generated_PublicDelegatedPrefixes_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListPublicDelegatedPrefixesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IPublicDelegatedPrefixesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IPublicDelegatedPrefixesScopedList]>; + } + /** + * Lists the PublicDelegatedPrefixes for a project in the given region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region of this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.PublicDelegatedPrefix | PublicDelegatedPrefix}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListPublicDelegatedPrefixesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPublicDelegatedPrefix[], + protos.google.cloud.compute.v1.IListPublicDelegatedPrefixesRequest|null, + protos.google.cloud.compute.v1.IPublicDelegatedPrefixList + ]>; + list( + request: protos.google.cloud.compute.v1.IListPublicDelegatedPrefixesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListPublicDelegatedPrefixesRequest, + protos.google.cloud.compute.v1.IPublicDelegatedPrefixList|null|undefined, + protos.google.cloud.compute.v1.IPublicDelegatedPrefix>): void; + list( + request: protos.google.cloud.compute.v1.IListPublicDelegatedPrefixesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListPublicDelegatedPrefixesRequest, + protos.google.cloud.compute.v1.IPublicDelegatedPrefixList|null|undefined, + protos.google.cloud.compute.v1.IPublicDelegatedPrefix>): void; + list( + request?: protos.google.cloud.compute.v1.IListPublicDelegatedPrefixesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListPublicDelegatedPrefixesRequest, + protos.google.cloud.compute.v1.IPublicDelegatedPrefixList|null|undefined, + protos.google.cloud.compute.v1.IPublicDelegatedPrefix>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListPublicDelegatedPrefixesRequest, + protos.google.cloud.compute.v1.IPublicDelegatedPrefixList|null|undefined, + protos.google.cloud.compute.v1.IPublicDelegatedPrefix>): + Promise<[ + protos.google.cloud.compute.v1.IPublicDelegatedPrefix[], + protos.google.cloud.compute.v1.IListPublicDelegatedPrefixesRequest|null, + protos.google.cloud.compute.v1.IPublicDelegatedPrefixList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region of this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.PublicDelegatedPrefix | PublicDelegatedPrefix} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListPublicDelegatedPrefixesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region of this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.PublicDelegatedPrefix | PublicDelegatedPrefix}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/public_delegated_prefixes.list.js + * region_tag:compute_v1_generated_PublicDelegatedPrefixes_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListPublicDelegatedPrefixesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.publicDelegatedPrefixesStub && !this._terminated) { + return this.publicDelegatedPrefixesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/public_delegated_prefixes_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/public_delegated_prefixes_client_config.json new file mode 100644 index 00000000000..4c6f77db207 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/public_delegated_prefixes_client_config.json @@ -0,0 +1,50 @@ +{ + "interfaces": { + "google.cloud.compute.v1.PublicDelegatedPrefixes": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/public_delegated_prefixes_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/public_delegated_prefixes_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/public_delegated_prefixes_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_autoscalers_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_autoscalers_client.ts new file mode 100644 index 00000000000..585c2204e64 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_autoscalers_client.ts @@ -0,0 +1,959 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_autoscalers_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_autoscalers_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionAutoscalers API. + * @class + * @memberof v1 + */ +export class RegionAutoscalersClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionAutoscalersStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionAutoscalersClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionAutoscalersClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionAutoscalersClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionAutoscalers', 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.regionAutoscalersStub) { + return this.regionAutoscalersStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionAutoscalers. + this.regionAutoscalersStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionAutoscalers') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionAutoscalers, + 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 regionAutoscalersStubMethods = + ['delete', 'get', 'insert', 'list', 'patch', 'update']; + for (const methodName of regionAutoscalersStubMethods) { + const callPromise = this.regionAutoscalersStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionAutoscalersStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified autoscaler. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.autoscaler + * Name of the autoscaler to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_autoscalers.delete.js + * region_tag:compute_v1_generated_RegionAutoscalers_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionAutoscalerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionAutoscalerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionAutoscalerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionAutoscalerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionAutoscalerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionAutoscalerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'autoscaler': request.autoscaler ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified autoscaler. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.autoscaler + * Name of the autoscaler to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @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.compute.v1.Autoscaler | Autoscaler}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_autoscalers.get.js + * region_tag:compute_v1_generated_RegionAutoscalers_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionAutoscalerRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IAutoscaler, + protos.google.cloud.compute.v1.IGetRegionAutoscalerRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionAutoscalerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IAutoscaler, + protos.google.cloud.compute.v1.IGetRegionAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionAutoscalerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IAutoscaler, + protos.google.cloud.compute.v1.IGetRegionAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionAutoscalerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IAutoscaler, + protos.google.cloud.compute.v1.IGetRegionAutoscalerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IAutoscaler, + protos.google.cloud.compute.v1.IGetRegionAutoscalerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IAutoscaler, + protos.google.cloud.compute.v1.IGetRegionAutoscalerRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'autoscaler': request.autoscaler ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates an autoscaler in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.Autoscaler} request.autoscalerResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_autoscalers.insert.js + * region_tag:compute_v1_generated_RegionAutoscalers_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionAutoscalerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionAutoscalerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionAutoscalerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionAutoscalerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionAutoscalerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionAutoscalerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates an autoscaler in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.autoscaler + * Name of the autoscaler to patch. + * @param {google.cloud.compute.v1.Autoscaler} request.autoscalerResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_autoscalers.patch.js + * region_tag:compute_v1_generated_RegionAutoscalers_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionAutoscalerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionAutoscalerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionAutoscalerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionAutoscalerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionAutoscalerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionAutoscalerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates an autoscaler in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.autoscaler + * Name of the autoscaler to update. + * @param {google.cloud.compute.v1.Autoscaler} request.autoscalerResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_autoscalers.update.js + * region_tag:compute_v1_generated_RegionAutoscalers_Update_async + */ + update( + request?: protos.google.cloud.compute.v1.IUpdateRegionAutoscalerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + update( + request: protos.google.cloud.compute.v1.IUpdateRegionAutoscalerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + update( + request: protos.google.cloud.compute.v1.IUpdateRegionAutoscalerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionAutoscalerRequest|null|undefined, + {}|null|undefined>): void; + update( + request?: protos.google.cloud.compute.v1.IUpdateRegionAutoscalerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionAutoscalerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionAutoscalerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.update(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves a list of autoscalers contained within the specified region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Autoscaler | Autoscaler}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionAutoscalersRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IAutoscaler[], + protos.google.cloud.compute.v1.IListRegionAutoscalersRequest|null, + protos.google.cloud.compute.v1.IRegionAutoscalerList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionAutoscalersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionAutoscalersRequest, + protos.google.cloud.compute.v1.IRegionAutoscalerList|null|undefined, + protos.google.cloud.compute.v1.IAutoscaler>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionAutoscalersRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionAutoscalersRequest, + protos.google.cloud.compute.v1.IRegionAutoscalerList|null|undefined, + protos.google.cloud.compute.v1.IAutoscaler>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionAutoscalersRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionAutoscalersRequest, + protos.google.cloud.compute.v1.IRegionAutoscalerList|null|undefined, + protos.google.cloud.compute.v1.IAutoscaler>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionAutoscalersRequest, + protos.google.cloud.compute.v1.IRegionAutoscalerList|null|undefined, + protos.google.cloud.compute.v1.IAutoscaler>): + Promise<[ + protos.google.cloud.compute.v1.IAutoscaler[], + protos.google.cloud.compute.v1.IListRegionAutoscalersRequest|null, + protos.google.cloud.compute.v1.IRegionAutoscalerList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Autoscaler | Autoscaler} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionAutoscalersRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Autoscaler | Autoscaler}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_autoscalers.list.js + * region_tag:compute_v1_generated_RegionAutoscalers_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionAutoscalersRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionAutoscalersStub && !this._terminated) { + return this.regionAutoscalersStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_autoscalers_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_autoscalers_client_config.json new file mode 100644 index 00000000000..3497c12d086 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_autoscalers_client_config.json @@ -0,0 +1,50 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionAutoscalers": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Update": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_autoscalers_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_autoscalers_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_autoscalers_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_backend_services_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_backend_services_client.ts new file mode 100644 index 00000000000..f3adfd219d8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_backend_services_client.ts @@ -0,0 +1,1197 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_backend_services_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_backend_services_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionBackendServices API. + * @class + * @memberof v1 + */ +export class RegionBackendServicesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionBackendServicesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionBackendServicesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionBackendServicesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionBackendServicesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionBackendServices', 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.regionBackendServicesStub) { + return this.regionBackendServicesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionBackendServices. + this.regionBackendServicesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionBackendServices') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionBackendServices, + 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 regionBackendServicesStubMethods = + ['delete', 'get', 'getHealth', 'getIamPolicy', 'insert', 'list', 'patch', 'setIamPolicy', 'update']; + for (const methodName of regionBackendServicesStubMethods) { + const callPromise = this.regionBackendServicesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionBackendServicesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified regional BackendService resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendService + * Name of the BackendService resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_backend_services.delete.js + * region_tag:compute_v1_generated_RegionBackendServices_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionBackendServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'backend_service': request.backendService ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified regional BackendService resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendService + * Name of the BackendService resource to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @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.compute.v1.BackendService | BackendService}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_backend_services.get.js + * region_tag:compute_v1_generated_RegionBackendServices_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionBackendServiceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IBackendService, + protos.google.cloud.compute.v1.IGetRegionBackendServiceRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IBackendService, + protos.google.cloud.compute.v1.IGetRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IBackendService, + protos.google.cloud.compute.v1.IGetRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IBackendService, + protos.google.cloud.compute.v1.IGetRegionBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IBackendService, + protos.google.cloud.compute.v1.IGetRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IBackendService, + protos.google.cloud.compute.v1.IGetRegionBackendServiceRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'backend_service': request.backendService ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the most recent health check results for this regional BackendService. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendService + * Name of the BackendService resource for which to get health. + * @param {string} request.project + * @param {string} request.region + * Name of the region scoping this request. + * @param {google.cloud.compute.v1.ResourceGroupReference} request.resourceGroupReferenceResource + * The body resource for this request + * @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.compute.v1.BackendServiceGroupHealth | BackendServiceGroupHealth}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_backend_services.get_health.js + * region_tag:compute_v1_generated_RegionBackendServices_GetHealth_async + */ + getHealth( + request?: protos.google.cloud.compute.v1.IGetHealthRegionBackendServiceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IBackendServiceGroupHealth, + protos.google.cloud.compute.v1.IGetHealthRegionBackendServiceRequest|undefined, {}|undefined + ]>; + getHealth( + request: protos.google.cloud.compute.v1.IGetHealthRegionBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IBackendServiceGroupHealth, + protos.google.cloud.compute.v1.IGetHealthRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + getHealth( + request: protos.google.cloud.compute.v1.IGetHealthRegionBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IBackendServiceGroupHealth, + protos.google.cloud.compute.v1.IGetHealthRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + getHealth( + request?: protos.google.cloud.compute.v1.IGetHealthRegionBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IBackendServiceGroupHealth, + protos.google.cloud.compute.v1.IGetHealthRegionBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IBackendServiceGroupHealth, + protos.google.cloud.compute.v1.IGetHealthRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IBackendServiceGroupHealth, + protos.google.cloud.compute.v1.IGetHealthRegionBackendServiceRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'backend_service': request.backendService ?? '', + }); + this.initialize(); + return this.innerApiCalls.getHealth(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_backend_services.get_iam_policy.js + * region_tag:compute_v1_generated_RegionBackendServices_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyRegionBackendServiceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionBackendServiceRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyRegionBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyRegionBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyRegionBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionBackendServiceRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Creates a regional BackendService resource in the specified project using the data included in the request. For more information, see Backend services overview. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.BackendService} request.backendServiceResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_backend_services.insert.js + * region_tag:compute_v1_generated_RegionBackendServices_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionBackendServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified regional BackendService resource with the data included in the request. For more information, see Understanding backend services This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendService + * Name of the BackendService resource to patch. + * @param {google.cloud.compute.v1.BackendService} request.backendServiceResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_backend_services.patch.js + * region_tag:compute_v1_generated_RegionBackendServices_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionBackendServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'backend_service': request.backendService ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {google.cloud.compute.v1.RegionSetPolicyRequest} request.regionSetPolicyRequestResource + * The body resource for this request + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_backend_services.set_iam_policy.js + * region_tag:compute_v1_generated_RegionBackendServices_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyRegionBackendServiceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionBackendServiceRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyRegionBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyRegionBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyRegionBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionBackendServiceRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Updates the specified regional BackendService resource with the data included in the request. For more information, see Backend services overview . + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.backendService + * Name of the BackendService resource to update. + * @param {google.cloud.compute.v1.BackendService} request.backendServiceResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_backend_services.update.js + * region_tag:compute_v1_generated_RegionBackendServices_Update_async + */ + update( + request?: protos.google.cloud.compute.v1.IUpdateRegionBackendServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + update( + request: protos.google.cloud.compute.v1.IUpdateRegionBackendServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + update( + request: protos.google.cloud.compute.v1.IUpdateRegionBackendServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): void; + update( + request?: protos.google.cloud.compute.v1.IUpdateRegionBackendServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionBackendServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionBackendServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'backend_service': request.backendService ?? '', + }); + this.initialize(); + return this.innerApiCalls.update(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves the list of regional BackendService resources available to the specified project in the given region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.BackendService | BackendService}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionBackendServicesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IBackendService[], + protos.google.cloud.compute.v1.IListRegionBackendServicesRequest|null, + protos.google.cloud.compute.v1.IBackendServiceList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionBackendServicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionBackendServicesRequest, + protos.google.cloud.compute.v1.IBackendServiceList|null|undefined, + protos.google.cloud.compute.v1.IBackendService>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionBackendServicesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionBackendServicesRequest, + protos.google.cloud.compute.v1.IBackendServiceList|null|undefined, + protos.google.cloud.compute.v1.IBackendService>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionBackendServicesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionBackendServicesRequest, + protos.google.cloud.compute.v1.IBackendServiceList|null|undefined, + protos.google.cloud.compute.v1.IBackendService>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionBackendServicesRequest, + protos.google.cloud.compute.v1.IBackendServiceList|null|undefined, + protos.google.cloud.compute.v1.IBackendService>): + Promise<[ + protos.google.cloud.compute.v1.IBackendService[], + protos.google.cloud.compute.v1.IListRegionBackendServicesRequest|null, + protos.google.cloud.compute.v1.IBackendServiceList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.BackendService | BackendService} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionBackendServicesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.BackendService | BackendService}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_backend_services.list.js + * region_tag:compute_v1_generated_RegionBackendServices_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionBackendServicesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionBackendServicesStub && !this._terminated) { + return this.regionBackendServicesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_backend_services_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_backend_services_client_config.json new file mode 100644 index 00000000000..ce4903d4ad4 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_backend_services_client_config.json @@ -0,0 +1,62 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionBackendServices": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetHealth": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Update": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_backend_services_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_backend_services_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_backend_services_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_commitments_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_commitments_client.ts new file mode 100644 index 00000000000..51d5bfc501f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_commitments_client.ts @@ -0,0 +1,838 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_commitments_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_commitments_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionCommitments API. + * @class + * @memberof v1 + */ +export class RegionCommitmentsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionCommitmentsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionCommitmentsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionCommitmentsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionCommitmentsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionCommitments', 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.regionCommitmentsStub) { + return this.regionCommitmentsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionCommitments. + this.regionCommitmentsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionCommitments') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionCommitments, + 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 regionCommitmentsStubMethods = + ['aggregatedList', 'get', 'insert', 'list', 'update']; + for (const methodName of regionCommitmentsStubMethods) { + const callPromise = this.regionCommitmentsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionCommitmentsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Returns the specified commitment resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.commitment + * Name of the commitment to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @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.compute.v1.Commitment | Commitment}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_commitments.get.js + * region_tag:compute_v1_generated_RegionCommitments_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionCommitmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ICommitment, + protos.google.cloud.compute.v1.IGetRegionCommitmentRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionCommitmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ICommitment, + protos.google.cloud.compute.v1.IGetRegionCommitmentRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionCommitmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.ICommitment, + protos.google.cloud.compute.v1.IGetRegionCommitmentRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionCommitmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ICommitment, + protos.google.cloud.compute.v1.IGetRegionCommitmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ICommitment, + protos.google.cloud.compute.v1.IGetRegionCommitmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ICommitment, + protos.google.cloud.compute.v1.IGetRegionCommitmentRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'commitment': request.commitment ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a commitment in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.Commitment} request.commitmentResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_commitments.insert.js + * region_tag:compute_v1_generated_RegionCommitments_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionCommitmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionCommitmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionCommitmentRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionCommitmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionCommitmentRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionCommitmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionCommitmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionCommitmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified commitment with the data included in the request. Update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: auto_renew. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.commitment + * Name of the commitment for which auto renew is being updated. + * @param {google.cloud.compute.v1.Commitment} request.commitmentResource + * The body resource for this request + * @param {string} request.paths + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.updateMask + * update_mask indicates fields to be updated as part of this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_commitments.update.js + * region_tag:compute_v1_generated_RegionCommitments_Update_async + */ + update( + request?: protos.google.cloud.compute.v1.IUpdateRegionCommitmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + update( + request: protos.google.cloud.compute.v1.IUpdateRegionCommitmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionCommitmentRequest|null|undefined, + {}|null|undefined>): void; + update( + request: protos.google.cloud.compute.v1.IUpdateRegionCommitmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionCommitmentRequest|null|undefined, + {}|null|undefined>): void; + update( + request?: protos.google.cloud.compute.v1.IUpdateRegionCommitmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionCommitmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionCommitmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'commitment': request.commitment ?? '', + }); + this.initialize(); + return this.innerApiCalls.update(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves an aggregated list of commitments by region. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.CommitmentsScopedList | CommitmentsScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_commitments.aggregated_list.js + * region_tag:compute_v1_generated_RegionCommitments_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListRegionCommitmentsRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.ICommitmentsScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.ICommitmentsScopedList]>; + } + /** + * Retrieves a list of commitments contained within the specified region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Commitment | Commitment}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionCommitmentsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ICommitment[], + protos.google.cloud.compute.v1.IListRegionCommitmentsRequest|null, + protos.google.cloud.compute.v1.ICommitmentList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionCommitmentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionCommitmentsRequest, + protos.google.cloud.compute.v1.ICommitmentList|null|undefined, + protos.google.cloud.compute.v1.ICommitment>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionCommitmentsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionCommitmentsRequest, + protos.google.cloud.compute.v1.ICommitmentList|null|undefined, + protos.google.cloud.compute.v1.ICommitment>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionCommitmentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionCommitmentsRequest, + protos.google.cloud.compute.v1.ICommitmentList|null|undefined, + protos.google.cloud.compute.v1.ICommitment>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionCommitmentsRequest, + protos.google.cloud.compute.v1.ICommitmentList|null|undefined, + protos.google.cloud.compute.v1.ICommitment>): + Promise<[ + protos.google.cloud.compute.v1.ICommitment[], + protos.google.cloud.compute.v1.IListRegionCommitmentsRequest|null, + protos.google.cloud.compute.v1.ICommitmentList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Commitment | Commitment} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionCommitmentsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Commitment | Commitment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_commitments.list.js + * region_tag:compute_v1_generated_RegionCommitments_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionCommitmentsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionCommitmentsStub && !this._terminated) { + return this.regionCommitmentsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_commitments_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_commitments_client_config.json new file mode 100644 index 00000000000..848cd544f25 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_commitments_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionCommitments": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Update": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_commitments_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_commitments_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_commitments_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disk_types_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disk_types_client.ts new file mode 100644 index 00000000000..70f2e0cc6a5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disk_types_client.ts @@ -0,0 +1,595 @@ +// Copyright 2023 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_disk_types_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_disk_types_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionDiskTypes API. + * @class + * @memberof v1 + */ +export class RegionDiskTypesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionDiskTypesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionDiskTypesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionDiskTypesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionDiskTypesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionDiskTypes', 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.regionDiskTypesStub) { + return this.regionDiskTypesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionDiskTypes. + this.regionDiskTypesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionDiskTypes') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionDiskTypes, + 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 regionDiskTypesStubMethods = + ['get', 'list']; + for (const methodName of regionDiskTypesStubMethods) { + const callPromise = this.regionDiskTypesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionDiskTypesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute.readonly', + 'https://www.googleapis.com/auth/compute', + '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 -- + // ------------------- +/** + * Returns the specified regional disk type. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.diskType + * Name of the disk type to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @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.compute.v1.DiskType | DiskType}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_disk_types.get.js + * region_tag:compute_v1_generated_RegionDiskTypes_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionDiskTypeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IDiskType, + protos.google.cloud.compute.v1.IGetRegionDiskTypeRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionDiskTypeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IDiskType, + protos.google.cloud.compute.v1.IGetRegionDiskTypeRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionDiskTypeRequest, + callback: Callback< + protos.google.cloud.compute.v1.IDiskType, + protos.google.cloud.compute.v1.IGetRegionDiskTypeRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionDiskTypeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IDiskType, + protos.google.cloud.compute.v1.IGetRegionDiskTypeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IDiskType, + protos.google.cloud.compute.v1.IGetRegionDiskTypeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IDiskType, + protos.google.cloud.compute.v1.IGetRegionDiskTypeRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'disk_type': request.diskType ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } + + /** + * Retrieves a list of regional disk types available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.DiskType | DiskType}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionDiskTypesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IDiskType[], + protos.google.cloud.compute.v1.IListRegionDiskTypesRequest|null, + protos.google.cloud.compute.v1.IRegionDiskTypeList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionDiskTypesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionDiskTypesRequest, + protos.google.cloud.compute.v1.IRegionDiskTypeList|null|undefined, + protos.google.cloud.compute.v1.IDiskType>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionDiskTypesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionDiskTypesRequest, + protos.google.cloud.compute.v1.IRegionDiskTypeList|null|undefined, + protos.google.cloud.compute.v1.IDiskType>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionDiskTypesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionDiskTypesRequest, + protos.google.cloud.compute.v1.IRegionDiskTypeList|null|undefined, + protos.google.cloud.compute.v1.IDiskType>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionDiskTypesRequest, + protos.google.cloud.compute.v1.IRegionDiskTypeList|null|undefined, + protos.google.cloud.compute.v1.IDiskType>): + Promise<[ + protos.google.cloud.compute.v1.IDiskType[], + protos.google.cloud.compute.v1.IListRegionDiskTypesRequest|null, + protos.google.cloud.compute.v1.IRegionDiskTypeList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.DiskType | DiskType} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionDiskTypesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.DiskType | DiskType}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_disk_types.list.js + * region_tag:compute_v1_generated_RegionDiskTypes_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionDiskTypesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionDiskTypesStub && !this._terminated) { + return this.regionDiskTypesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disk_types_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disk_types_client_config.json new file mode 100644 index 00000000000..cd33b260ab2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disk_types_client_config.json @@ -0,0 +1,34 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionDiskTypes": { + "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": { + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disk_types_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disk_types_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disk_types_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disks_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disks_client.ts new file mode 100644 index 00000000000..6fcfbbeb8ee --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disks_client.ts @@ -0,0 +1,1575 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_disks_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_disks_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionDisks API. + * @class + * @memberof v1 + */ +export class RegionDisksClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionDisksStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionDisksClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionDisksClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionDisksClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionDisks', 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.regionDisksStub) { + return this.regionDisksStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionDisks. + this.regionDisksStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionDisks') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionDisks, + 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 regionDisksStubMethods = + ['addResourcePolicies', 'createSnapshot', 'delete', 'get', 'getIamPolicy', 'insert', 'list', 'removeResourcePolicies', 'resize', 'setIamPolicy', 'setLabels', 'testIamPermissions', 'update']; + for (const methodName of regionDisksStubMethods) { + const callPromise = this.regionDisksStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionDisksStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Adds existing resource policies to a regional disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.disk + * The disk name for this request. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {google.cloud.compute.v1.RegionDisksAddResourcePoliciesRequest} request.regionDisksAddResourcePoliciesRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_disks.add_resource_policies.js + * region_tag:compute_v1_generated_RegionDisks_AddResourcePolicies_async + */ + addResourcePolicies( + request?: protos.google.cloud.compute.v1.IAddResourcePoliciesRegionDiskRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addResourcePolicies( + request: protos.google.cloud.compute.v1.IAddResourcePoliciesRegionDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddResourcePoliciesRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + addResourcePolicies( + request: protos.google.cloud.compute.v1.IAddResourcePoliciesRegionDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddResourcePoliciesRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + addResourcePolicies( + request?: protos.google.cloud.compute.v1.IAddResourcePoliciesRegionDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddResourcePoliciesRegionDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddResourcePoliciesRegionDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'disk': request.disk ?? '', + }); + this.initialize(); + return this.innerApiCalls.addResourcePolicies(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.disk + * Name of the regional persistent disk to snapshot. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.Snapshot} request.snapshotResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_disks.create_snapshot.js + * region_tag:compute_v1_generated_RegionDisks_CreateSnapshot_async + */ + createSnapshot( + request?: protos.google.cloud.compute.v1.ICreateSnapshotRegionDiskRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + createSnapshot( + request: protos.google.cloud.compute.v1.ICreateSnapshotRegionDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICreateSnapshotRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + createSnapshot( + request: protos.google.cloud.compute.v1.ICreateSnapshotRegionDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICreateSnapshotRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + createSnapshot( + request?: protos.google.cloud.compute.v1.ICreateSnapshotRegionDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICreateSnapshotRegionDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICreateSnapshotRegionDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'disk': request.disk ?? '', + }); + this.initialize(); + return this.innerApiCalls.createSnapshot(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified regional persistent disk. Deleting a regional disk removes all the replicas of its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.disk + * Name of the regional persistent disk to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_disks.delete.js + * region_tag:compute_v1_generated_RegionDisks_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionDiskRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'disk': request.disk ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns a specified regional persistent disk. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.disk + * Name of the regional persistent disk to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @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.compute.v1.Disk | Disk}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_disks.get.js + * region_tag:compute_v1_generated_RegionDisks_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionDiskRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IDisk, + protos.google.cloud.compute.v1.IGetRegionDiskRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IDisk, + protos.google.cloud.compute.v1.IGetRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IDisk, + protos.google.cloud.compute.v1.IGetRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IDisk, + protos.google.cloud.compute.v1.IGetRegionDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IDisk, + protos.google.cloud.compute.v1.IGetRegionDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IDisk, + protos.google.cloud.compute.v1.IGetRegionDiskRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'disk': request.disk ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_disks.get_iam_policy.js + * region_tag:compute_v1_generated_RegionDisks_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyRegionDiskRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionDiskRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyRegionDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyRegionDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyRegionDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionDiskRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Creates a persistent regional disk in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.Disk} request.diskResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.sourceImage + * Source image to restore onto a disk. This field is optional. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_disks.insert.js + * region_tag:compute_v1_generated_RegionDisks_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionDiskRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Removes resource policies from a regional disk. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.disk + * The disk name for this request. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {google.cloud.compute.v1.RegionDisksRemoveResourcePoliciesRequest} request.regionDisksRemoveResourcePoliciesRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_disks.remove_resource_policies.js + * region_tag:compute_v1_generated_RegionDisks_RemoveResourcePolicies_async + */ + removeResourcePolicies( + request?: protos.google.cloud.compute.v1.IRemoveResourcePoliciesRegionDiskRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + removeResourcePolicies( + request: protos.google.cloud.compute.v1.IRemoveResourcePoliciesRegionDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveResourcePoliciesRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + removeResourcePolicies( + request: protos.google.cloud.compute.v1.IRemoveResourcePoliciesRegionDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveResourcePoliciesRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + removeResourcePolicies( + request?: protos.google.cloud.compute.v1.IRemoveResourcePoliciesRegionDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveResourcePoliciesRegionDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveResourcePoliciesRegionDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'disk': request.disk ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeResourcePolicies(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Resizes the specified regional persistent disk. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.disk + * Name of the regional persistent disk. + * @param {string} request.project + * The project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {google.cloud.compute.v1.RegionDisksResizeRequest} request.regionDisksResizeRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_disks.resize.js + * region_tag:compute_v1_generated_RegionDisks_Resize_async + */ + resize( + request?: protos.google.cloud.compute.v1.IResizeRegionDiskRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + resize( + request: protos.google.cloud.compute.v1.IResizeRegionDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + resize( + request: protos.google.cloud.compute.v1.IResizeRegionDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + resize( + request?: protos.google.cloud.compute.v1.IResizeRegionDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeRegionDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeRegionDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'disk': request.disk ?? '', + }); + this.initialize(); + return this.innerApiCalls.resize(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {google.cloud.compute.v1.RegionSetPolicyRequest} request.regionSetPolicyRequestResource + * The body resource for this request + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_disks.set_iam_policy.js + * region_tag:compute_v1_generated_RegionDisks_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyRegionDiskRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionDiskRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyRegionDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyRegionDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyRegionDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionDiskRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Sets the labels on the target regional disk. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The region for this request. + * @param {google.cloud.compute.v1.RegionSetLabelsRequest} request.regionSetLabelsRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.resource + * Name or id of the resource for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_disks.set_labels.js + * region_tag:compute_v1_generated_RegionDisks_SetLabels_async + */ + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsRegionDiskRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsRegionDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsRegionDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsRegionDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsRegionDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsRegionDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setLabels(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_disks.test_iam_permissions.js + * region_tag:compute_v1_generated_RegionDisks_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsRegionDiskRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsRegionDiskRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsRegionDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsRegionDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsRegionDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsRegionDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsRegionDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsRegionDiskRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } +/** + * Update the specified disk with the data included in the request. Update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: user_license. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.disk + * The disk name for this request. + * @param {google.cloud.compute.v1.Disk} request.diskResource + * The body resource for this request + * @param {string} request.paths + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.updateMask + * update_mask indicates fields to be updated as part of this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_disks.update.js + * region_tag:compute_v1_generated_RegionDisks_Update_async + */ + update( + request?: protos.google.cloud.compute.v1.IUpdateRegionDiskRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + update( + request: protos.google.cloud.compute.v1.IUpdateRegionDiskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + update( + request: protos.google.cloud.compute.v1.IUpdateRegionDiskRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionDiskRequest|null|undefined, + {}|null|undefined>): void; + update( + request?: protos.google.cloud.compute.v1.IUpdateRegionDiskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionDiskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionDiskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'disk': request.disk ?? '', + }); + this.initialize(); + return this.innerApiCalls.update(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves the list of persistent disks contained within the specified region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Disk | Disk}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionDisksRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IDisk[], + protos.google.cloud.compute.v1.IListRegionDisksRequest|null, + protos.google.cloud.compute.v1.IDiskList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionDisksRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionDisksRequest, + protos.google.cloud.compute.v1.IDiskList|null|undefined, + protos.google.cloud.compute.v1.IDisk>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionDisksRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionDisksRequest, + protos.google.cloud.compute.v1.IDiskList|null|undefined, + protos.google.cloud.compute.v1.IDisk>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionDisksRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionDisksRequest, + protos.google.cloud.compute.v1.IDiskList|null|undefined, + protos.google.cloud.compute.v1.IDisk>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionDisksRequest, + protos.google.cloud.compute.v1.IDiskList|null|undefined, + protos.google.cloud.compute.v1.IDisk>): + Promise<[ + protos.google.cloud.compute.v1.IDisk[], + protos.google.cloud.compute.v1.IListRegionDisksRequest|null, + protos.google.cloud.compute.v1.IDiskList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Disk | Disk} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionDisksRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Disk | Disk}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_disks.list.js + * region_tag:compute_v1_generated_RegionDisks_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionDisksRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionDisksStub && !this._terminated) { + return this.regionDisksStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disks_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disks_client_config.json new file mode 100644 index 00000000000..abf1fc2f267 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disks_client_config.json @@ -0,0 +1,78 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionDisks": { + "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": { + "AddResourcePolicies": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateSnapshot": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveResourcePolicies": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Resize": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetLabels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Update": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disks_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disks_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_disks_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_check_services_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_check_services_client.ts new file mode 100644 index 00000000000..b065d3871a7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_check_services_client.ts @@ -0,0 +1,868 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_health_check_services_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_health_check_services_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionHealthCheckServices API. + * @class + * @memberof v1 + */ +export class RegionHealthCheckServicesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionHealthCheckServicesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionHealthCheckServicesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionHealthCheckServicesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionHealthCheckServicesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionHealthCheckServices', 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.regionHealthCheckServicesStub) { + return this.regionHealthCheckServicesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionHealthCheckServices. + this.regionHealthCheckServicesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionHealthCheckServices') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionHealthCheckServices, + 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 regionHealthCheckServicesStubMethods = + ['delete', 'get', 'insert', 'list', 'patch']; + for (const methodName of regionHealthCheckServicesStubMethods) { + const callPromise = this.regionHealthCheckServicesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionHealthCheckServicesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified regional HealthCheckService. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.healthCheckService + * Name of the HealthCheckService to delete. The name must be 1-63 characters long, and comply with RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_health_check_services.delete.js + * region_tag:compute_v1_generated_RegionHealthCheckServices_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionHealthCheckServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionHealthCheckServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionHealthCheckServiceRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionHealthCheckServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionHealthCheckServiceRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionHealthCheckServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionHealthCheckServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionHealthCheckServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'health_check_service': request.healthCheckService ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified regional HealthCheckService resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.healthCheckService + * Name of the HealthCheckService to update. The name must be 1-63 characters long, and comply with RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @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.compute.v1.HealthCheckService | HealthCheckService}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_health_check_services.get.js + * region_tag:compute_v1_generated_RegionHealthCheckServices_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionHealthCheckServiceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IHealthCheckService, + protos.google.cloud.compute.v1.IGetRegionHealthCheckServiceRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionHealthCheckServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IHealthCheckService, + protos.google.cloud.compute.v1.IGetRegionHealthCheckServiceRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionHealthCheckServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IHealthCheckService, + protos.google.cloud.compute.v1.IGetRegionHealthCheckServiceRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionHealthCheckServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IHealthCheckService, + protos.google.cloud.compute.v1.IGetRegionHealthCheckServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IHealthCheckService, + protos.google.cloud.compute.v1.IGetRegionHealthCheckServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IHealthCheckService, + protos.google.cloud.compute.v1.IGetRegionHealthCheckServiceRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'health_check_service': request.healthCheckService ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a regional HealthCheckService resource in the specified project and region using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.HealthCheckService} request.healthCheckServiceResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_health_check_services.insert.js + * region_tag:compute_v1_generated_RegionHealthCheckServices_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionHealthCheckServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionHealthCheckServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionHealthCheckServiceRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionHealthCheckServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionHealthCheckServiceRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionHealthCheckServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionHealthCheckServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionHealthCheckServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified regional HealthCheckService resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.healthCheckService + * Name of the HealthCheckService to update. The name must be 1-63 characters long, and comply with RFC1035. + * @param {google.cloud.compute.v1.HealthCheckService} request.healthCheckServiceResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_health_check_services.patch.js + * region_tag:compute_v1_generated_RegionHealthCheckServices_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionHealthCheckServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionHealthCheckServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionHealthCheckServiceRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionHealthCheckServiceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionHealthCheckServiceRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionHealthCheckServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionHealthCheckServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionHealthCheckServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'health_check_service': request.healthCheckService ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Lists all the HealthCheckService resources that have been configured for the specified project in the given region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.HealthCheckService | HealthCheckService}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionHealthCheckServicesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IHealthCheckService[], + protos.google.cloud.compute.v1.IListRegionHealthCheckServicesRequest|null, + protos.google.cloud.compute.v1.IHealthCheckServicesList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionHealthCheckServicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionHealthCheckServicesRequest, + protos.google.cloud.compute.v1.IHealthCheckServicesList|null|undefined, + protos.google.cloud.compute.v1.IHealthCheckService>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionHealthCheckServicesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionHealthCheckServicesRequest, + protos.google.cloud.compute.v1.IHealthCheckServicesList|null|undefined, + protos.google.cloud.compute.v1.IHealthCheckService>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionHealthCheckServicesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionHealthCheckServicesRequest, + protos.google.cloud.compute.v1.IHealthCheckServicesList|null|undefined, + protos.google.cloud.compute.v1.IHealthCheckService>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionHealthCheckServicesRequest, + protos.google.cloud.compute.v1.IHealthCheckServicesList|null|undefined, + protos.google.cloud.compute.v1.IHealthCheckService>): + Promise<[ + protos.google.cloud.compute.v1.IHealthCheckService[], + protos.google.cloud.compute.v1.IListRegionHealthCheckServicesRequest|null, + protos.google.cloud.compute.v1.IHealthCheckServicesList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.HealthCheckService | HealthCheckService} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionHealthCheckServicesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.HealthCheckService | HealthCheckService}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_health_check_services.list.js + * region_tag:compute_v1_generated_RegionHealthCheckServices_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionHealthCheckServicesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionHealthCheckServicesStub && !this._terminated) { + return this.regionHealthCheckServicesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_check_services_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_check_services_client_config.json new file mode 100644 index 00000000000..e421f312aaa --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_check_services_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionHealthCheckServices": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_check_services_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_check_services_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_check_services_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_checks_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_checks_client.ts new file mode 100644 index 00000000000..65e75c805dd --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_checks_client.ts @@ -0,0 +1,961 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_health_checks_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_health_checks_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionHealthChecks API. + * @class + * @memberof v1 + */ +export class RegionHealthChecksClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionHealthChecksStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionHealthChecksClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionHealthChecksClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionHealthChecksClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionHealthChecks', 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.regionHealthChecksStub) { + return this.regionHealthChecksStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionHealthChecks. + this.regionHealthChecksStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionHealthChecks') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionHealthChecks, + 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 regionHealthChecksStubMethods = + ['delete', 'get', 'insert', 'list', 'patch', 'update']; + for (const methodName of regionHealthChecksStubMethods) { + const callPromise = this.regionHealthChecksStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionHealthChecksStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified HealthCheck resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.healthCheck + * Name of the HealthCheck resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_health_checks.delete.js + * region_tag:compute_v1_generated_RegionHealthChecks_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionHealthCheckRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionHealthCheckRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionHealthCheckRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionHealthCheckRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionHealthCheckRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionHealthCheckRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'health_check': request.healthCheck ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified HealthCheck resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.healthCheck + * Name of the HealthCheck resource to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @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.compute.v1.HealthCheck | HealthCheck}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_health_checks.get.js + * region_tag:compute_v1_generated_RegionHealthChecks_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionHealthCheckRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IHealthCheck, + protos.google.cloud.compute.v1.IGetRegionHealthCheckRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionHealthCheckRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IHealthCheck, + protos.google.cloud.compute.v1.IGetRegionHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionHealthCheckRequest, + callback: Callback< + protos.google.cloud.compute.v1.IHealthCheck, + protos.google.cloud.compute.v1.IGetRegionHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionHealthCheckRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IHealthCheck, + protos.google.cloud.compute.v1.IGetRegionHealthCheckRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IHealthCheck, + protos.google.cloud.compute.v1.IGetRegionHealthCheckRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IHealthCheck, + protos.google.cloud.compute.v1.IGetRegionHealthCheckRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'health_check': request.healthCheck ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a HealthCheck resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.HealthCheck} request.healthCheckResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_health_checks.insert.js + * region_tag:compute_v1_generated_RegionHealthChecks_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionHealthCheckRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionHealthCheckRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionHealthCheckRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionHealthCheckRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionHealthCheckRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionHealthCheckRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates a HealthCheck resource in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.healthCheck + * Name of the HealthCheck resource to patch. + * @param {google.cloud.compute.v1.HealthCheck} request.healthCheckResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_health_checks.patch.js + * region_tag:compute_v1_generated_RegionHealthChecks_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionHealthCheckRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionHealthCheckRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionHealthCheckRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionHealthCheckRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionHealthCheckRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionHealthCheckRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'health_check': request.healthCheck ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates a HealthCheck resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.healthCheck + * Name of the HealthCheck resource to update. + * @param {google.cloud.compute.v1.HealthCheck} request.healthCheckResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_health_checks.update.js + * region_tag:compute_v1_generated_RegionHealthChecks_Update_async + */ + update( + request?: protos.google.cloud.compute.v1.IUpdateRegionHealthCheckRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + update( + request: protos.google.cloud.compute.v1.IUpdateRegionHealthCheckRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + update( + request: protos.google.cloud.compute.v1.IUpdateRegionHealthCheckRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionHealthCheckRequest|null|undefined, + {}|null|undefined>): void; + update( + request?: protos.google.cloud.compute.v1.IUpdateRegionHealthCheckRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionHealthCheckRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionHealthCheckRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'health_check': request.healthCheck ?? '', + }); + this.initialize(); + return this.innerApiCalls.update(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves the list of HealthCheck resources available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.HealthCheck | HealthCheck}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionHealthChecksRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IHealthCheck[], + protos.google.cloud.compute.v1.IListRegionHealthChecksRequest|null, + protos.google.cloud.compute.v1.IHealthCheckList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionHealthChecksRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionHealthChecksRequest, + protos.google.cloud.compute.v1.IHealthCheckList|null|undefined, + protos.google.cloud.compute.v1.IHealthCheck>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionHealthChecksRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionHealthChecksRequest, + protos.google.cloud.compute.v1.IHealthCheckList|null|undefined, + protos.google.cloud.compute.v1.IHealthCheck>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionHealthChecksRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionHealthChecksRequest, + protos.google.cloud.compute.v1.IHealthCheckList|null|undefined, + protos.google.cloud.compute.v1.IHealthCheck>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionHealthChecksRequest, + protos.google.cloud.compute.v1.IHealthCheckList|null|undefined, + protos.google.cloud.compute.v1.IHealthCheck>): + Promise<[ + protos.google.cloud.compute.v1.IHealthCheck[], + protos.google.cloud.compute.v1.IListRegionHealthChecksRequest|null, + protos.google.cloud.compute.v1.IHealthCheckList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.HealthCheck | HealthCheck} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionHealthChecksRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.HealthCheck | HealthCheck}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_health_checks.list.js + * region_tag:compute_v1_generated_RegionHealthChecks_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionHealthChecksRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionHealthChecksStub && !this._terminated) { + return this.regionHealthChecksStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_checks_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_checks_client_config.json new file mode 100644 index 00000000000..4e97b15f869 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_checks_client_config.json @@ -0,0 +1,50 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionHealthChecks": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Update": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_checks_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_checks_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_health_checks_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_group_managers_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_group_managers_client.ts new file mode 100644 index 00000000000..9e6f6489edf --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_group_managers_client.ts @@ -0,0 +1,2520 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_instance_group_managers_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_instance_group_managers_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionInstanceGroupManagers API. + * @class + * @memberof v1 + */ +export class RegionInstanceGroupManagersClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionInstanceGroupManagersStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionInstanceGroupManagersClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionInstanceGroupManagersClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionInstanceGroupManagersClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + listErrors: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + listManagedInstances: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'managedInstances'), + listPerInstanceConfigs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionInstanceGroupManagers', 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.regionInstanceGroupManagersStub) { + return this.regionInstanceGroupManagersStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionInstanceGroupManagers. + this.regionInstanceGroupManagersStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionInstanceGroupManagers') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionInstanceGroupManagers, + 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 regionInstanceGroupManagersStubMethods = + ['abandonInstances', 'applyUpdatesToInstances', 'createInstances', 'delete', 'deleteInstances', 'deletePerInstanceConfigs', 'get', 'insert', 'list', 'listErrors', 'listManagedInstances', 'listPerInstanceConfigs', 'patch', 'patchPerInstanceConfigs', 'recreateInstances', 'resize', 'setInstanceTemplate', 'setTargetPools', 'updatePerInstanceConfigs']; + for (const methodName of regionInstanceGroupManagersStubMethods) { + const callPromise = this.regionInstanceGroupManagersStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionInstanceGroupManagersStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Flags the specified instances to be immediately removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * Name of the managed instance group. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {google.cloud.compute.v1.RegionInstanceGroupManagersAbandonInstancesRequest} request.regionInstanceGroupManagersAbandonInstancesRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_group_managers.abandon_instances.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_AbandonInstances_async + */ + abandonInstances( + request?: protos.google.cloud.compute.v1.IAbandonInstancesRegionInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + abandonInstances( + request: protos.google.cloud.compute.v1.IAbandonInstancesRegionInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAbandonInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + abandonInstances( + request: protos.google.cloud.compute.v1.IAbandonInstancesRegionInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAbandonInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + abandonInstances( + request?: protos.google.cloud.compute.v1.IAbandonInstancesRegionInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAbandonInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAbandonInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.abandonInstances(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Apply updates to selected instances the managed instance group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group, should conform to RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request, should conform to RFC1035. + * @param {google.cloud.compute.v1.RegionInstanceGroupManagersApplyUpdatesRequest} request.regionInstanceGroupManagersApplyUpdatesRequestResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_group_managers.apply_updates_to_instances.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_ApplyUpdatesToInstances_async + */ + applyUpdatesToInstances( + request?: protos.google.cloud.compute.v1.IApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + applyUpdatesToInstances( + request: protos.google.cloud.compute.v1.IApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IApplyUpdatesToInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + applyUpdatesToInstances( + request: protos.google.cloud.compute.v1.IApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IApplyUpdatesToInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + applyUpdatesToInstances( + request?: protos.google.cloud.compute.v1.IApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IApplyUpdatesToInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IApplyUpdatesToInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.applyUpdatesToInstances(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Creates instances with per-instance configurations in this regional managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It should conform to RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region where the managed instance group is located. It should conform to RFC1035. + * @param {google.cloud.compute.v1.RegionInstanceGroupManagersCreateInstancesRequest} request.regionInstanceGroupManagersCreateInstancesRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_group_managers.create_instances.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_CreateInstances_async + */ + createInstances( + request?: protos.google.cloud.compute.v1.ICreateInstancesRegionInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + createInstances( + request: protos.google.cloud.compute.v1.ICreateInstancesRegionInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICreateInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + createInstances( + request: protos.google.cloud.compute.v1.ICreateInstancesRegionInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICreateInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + createInstances( + request?: protos.google.cloud.compute.v1.ICreateInstancesRegionInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICreateInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICreateInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.createInstances(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified managed instance group and all of the instances in that group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * Name of the managed instance group to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_group_managers.delete.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Flags the specified instances in the managed instance group to be immediately deleted. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. The deleteInstances operation is marked DONE if the deleteInstances request is successful. The underlying actions take additional time. You must separately verify the status of the deleting action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * Name of the managed instance group. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {google.cloud.compute.v1.RegionInstanceGroupManagersDeleteInstancesRequest} request.regionInstanceGroupManagersDeleteInstancesRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_group_managers.delete_instances.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_DeleteInstances_async + */ + deleteInstances( + request?: protos.google.cloud.compute.v1.IDeleteInstancesRegionInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + deleteInstances( + request: protos.google.cloud.compute.v1.IDeleteInstancesRegionInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + deleteInstances( + request: protos.google.cloud.compute.v1.IDeleteInstancesRegionInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + deleteInstances( + request?: protos.google.cloud.compute.v1.IDeleteInstancesRegionInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteInstances(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes selected per-instance configurations for the managed instance group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It should conform to RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request, should conform to RFC1035. + * @param {google.cloud.compute.v1.RegionInstanceGroupManagerDeleteInstanceConfigReq} request.regionInstanceGroupManagerDeleteInstanceConfigReqResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_group_managers.delete_per_instance_configs.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_DeletePerInstanceConfigs_async + */ + deletePerInstanceConfigs( + request?: protos.google.cloud.compute.v1.IDeletePerInstanceConfigsRegionInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + deletePerInstanceConfigs( + request: protos.google.cloud.compute.v1.IDeletePerInstanceConfigsRegionInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePerInstanceConfigsRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + deletePerInstanceConfigs( + request: protos.google.cloud.compute.v1.IDeletePerInstanceConfigsRegionInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePerInstanceConfigsRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + deletePerInstanceConfigs( + request?: protos.google.cloud.compute.v1.IDeletePerInstanceConfigsRegionInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePerInstanceConfigsRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeletePerInstanceConfigsRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.deletePerInstanceConfigs(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns all of the details about the specified managed instance group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * Name of the managed instance group to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @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.compute.v1.InstanceGroupManager | InstanceGroupManager}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_instance_group_managers.get.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstanceGroupManager, + protos.google.cloud.compute.v1.IGetRegionInstanceGroupManagerRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IInstanceGroupManager, + protos.google.cloud.compute.v1.IGetRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IInstanceGroupManager, + protos.google.cloud.compute.v1.IGetRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IInstanceGroupManager, + protos.google.cloud.compute.v1.IGetRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IInstanceGroupManager, + protos.google.cloud.compute.v1.IGetRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IInstanceGroupManager, + protos.google.cloud.compute.v1.IGetRegionInstanceGroupManagerRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. A regional managed instance group can contain up to 2000 instances. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.InstanceGroupManager} request.instanceGroupManagerResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_group_managers.insert.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listmanagedinstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. If you update your group to specify a new template or instance configuration, it's possible that your intended specification for each VM in the group is different from the current state of that VM. To learn how to apply an updated configuration to the VMs in a MIG, see Updating instances in a MIG. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the instance group manager. + * @param {google.cloud.compute.v1.InstanceGroupManager} request.instanceGroupManagerResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_group_managers.patch.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It should conform to RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request, should conform to RFC1035. + * @param {google.cloud.compute.v1.RegionInstanceGroupManagerPatchInstanceConfigReq} request.regionInstanceGroupManagerPatchInstanceConfigReqResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_group_managers.patch_per_instance_configs.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_PatchPerInstanceConfigs_async + */ + patchPerInstanceConfigs( + request?: protos.google.cloud.compute.v1.IPatchPerInstanceConfigsRegionInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patchPerInstanceConfigs( + request: protos.google.cloud.compute.v1.IPatchPerInstanceConfigsRegionInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPerInstanceConfigsRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + patchPerInstanceConfigs( + request: protos.google.cloud.compute.v1.IPatchPerInstanceConfigsRegionInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPerInstanceConfigsRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + patchPerInstanceConfigs( + request?: protos.google.cloud.compute.v1.IPatchPerInstanceConfigsRegionInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPerInstanceConfigsRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchPerInstanceConfigsRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.patchPerInstanceConfigs(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group's current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * Name of the managed instance group. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {google.cloud.compute.v1.RegionInstanceGroupManagersRecreateRequest} request.regionInstanceGroupManagersRecreateRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_group_managers.recreate_instances.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_RecreateInstances_async + */ + recreateInstances( + request?: protos.google.cloud.compute.v1.IRecreateInstancesRegionInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + recreateInstances( + request: protos.google.cloud.compute.v1.IRecreateInstancesRegionInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRecreateInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + recreateInstances( + request: protos.google.cloud.compute.v1.IRecreateInstancesRegionInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRecreateInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + recreateInstances( + request?: protos.google.cloud.compute.v1.IRecreateInstancesRegionInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRecreateInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRecreateInstancesRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.recreateInstances(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes the intended size of the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes one or more instances. The resize operation is marked DONE if the resize request is successful. The underlying actions take additional time. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * Name of the managed instance group. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {number} request.size + * Number of instances that should exist in this instance group manager. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_group_managers.resize.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_Resize_async + */ + resize( + request?: protos.google.cloud.compute.v1.IResizeRegionInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + resize( + request: protos.google.cloud.compute.v1.IResizeRegionInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + resize( + request: protos.google.cloud.compute.v1.IResizeRegionInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + resize( + request?: protos.google.cloud.compute.v1.IResizeRegionInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.resize(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the instance template to use when creating new instances or recreating instances in this group. Existing instances are not affected. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {google.cloud.compute.v1.RegionInstanceGroupManagersSetTemplateRequest} request.regionInstanceGroupManagersSetTemplateRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_group_managers.set_instance_template.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_SetInstanceTemplate_async + */ + setInstanceTemplate( + request?: protos.google.cloud.compute.v1.ISetInstanceTemplateRegionInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setInstanceTemplate( + request: protos.google.cloud.compute.v1.ISetInstanceTemplateRegionInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetInstanceTemplateRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + setInstanceTemplate( + request: protos.google.cloud.compute.v1.ISetInstanceTemplateRegionInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetInstanceTemplateRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + setInstanceTemplate( + request?: protos.google.cloud.compute.v1.ISetInstanceTemplateRegionInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetInstanceTemplateRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetInstanceTemplateRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.setInstanceTemplate(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Modifies the target pools to which all new instances in this group are assigned. Existing instances in the group are not affected. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * Name of the managed instance group. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {google.cloud.compute.v1.RegionInstanceGroupManagersSetTargetPoolsRequest} request.regionInstanceGroupManagersSetTargetPoolsRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_group_managers.set_target_pools.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_SetTargetPools_async + */ + setTargetPools( + request?: protos.google.cloud.compute.v1.ISetTargetPoolsRegionInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setTargetPools( + request: protos.google.cloud.compute.v1.ISetTargetPoolsRegionInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTargetPoolsRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + setTargetPools( + request: protos.google.cloud.compute.v1.ISetTargetPoolsRegionInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTargetPoolsRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + setTargetPools( + request?: protos.google.cloud.compute.v1.ISetTargetPoolsRegionInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTargetPoolsRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetTargetPoolsRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.setTargetPools(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It should conform to RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request, should conform to RFC1035. + * @param {google.cloud.compute.v1.RegionInstanceGroupManagerUpdateInstanceConfigReq} request.regionInstanceGroupManagerUpdateInstanceConfigReqResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_group_managers.update_per_instance_configs.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_UpdatePerInstanceConfigs_async + */ + updatePerInstanceConfigs( + request?: protos.google.cloud.compute.v1.IUpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + updatePerInstanceConfigs( + request: protos.google.cloud.compute.v1.IUpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdatePerInstanceConfigsRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + updatePerInstanceConfigs( + request: protos.google.cloud.compute.v1.IUpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdatePerInstanceConfigsRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): void; + updatePerInstanceConfigs( + request?: protos.google.cloud.compute.v1.IUpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdatePerInstanceConfigsRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdatePerInstanceConfigsRegionInstanceGroupManagerRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.updatePerInstanceConfigs(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves the list of managed instance groups that are contained within the specified region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.InstanceGroupManager | InstanceGroupManager}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionInstanceGroupManagersRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstanceGroupManager[], + protos.google.cloud.compute.v1.IListRegionInstanceGroupManagersRequest|null, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagerList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionInstanceGroupManagersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagerList|null|undefined, + protos.google.cloud.compute.v1.IInstanceGroupManager>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionInstanceGroupManagersRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagerList|null|undefined, + protos.google.cloud.compute.v1.IInstanceGroupManager>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionInstanceGroupManagersRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagerList|null|undefined, + protos.google.cloud.compute.v1.IInstanceGroupManager>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagerList|null|undefined, + protos.google.cloud.compute.v1.IInstanceGroupManager>): + Promise<[ + protos.google.cloud.compute.v1.IInstanceGroupManager[], + protos.google.cloud.compute.v1.IListRegionInstanceGroupManagersRequest|null, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagerList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.InstanceGroupManager | InstanceGroupManager} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionInstanceGroupManagersRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.InstanceGroupManager | InstanceGroupManager}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_instance_group_managers.list.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionInstanceGroupManagersRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists all errors thrown by actions on instances for a given regional managed instance group. The filter and orderBy query parameters are not supported. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It must be a string that meets the requirements in RFC1035, or an unsigned long integer: must match regexp pattern: (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)|1-9{0,19}. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. This should conform to RFC1035. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.InstanceManagedByIgmError | InstanceManagedByIgmError}. + * 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 `listErrorsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listErrors( + request?: protos.google.cloud.compute.v1.IListErrorsRegionInstanceGroupManagersRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstanceManagedByIgmError[], + protos.google.cloud.compute.v1.IListErrorsRegionInstanceGroupManagersRequest|null, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListErrorsResponse + ]>; + listErrors( + request: protos.google.cloud.compute.v1.IListErrorsRegionInstanceGroupManagersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListErrorsRegionInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListErrorsResponse|null|undefined, + protos.google.cloud.compute.v1.IInstanceManagedByIgmError>): void; + listErrors( + request: protos.google.cloud.compute.v1.IListErrorsRegionInstanceGroupManagersRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListErrorsRegionInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListErrorsResponse|null|undefined, + protos.google.cloud.compute.v1.IInstanceManagedByIgmError>): void; + listErrors( + request?: protos.google.cloud.compute.v1.IListErrorsRegionInstanceGroupManagersRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListErrorsRegionInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListErrorsResponse|null|undefined, + protos.google.cloud.compute.v1.IInstanceManagedByIgmError>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListErrorsRegionInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListErrorsResponse|null|undefined, + protos.google.cloud.compute.v1.IInstanceManagedByIgmError>): + Promise<[ + protos.google.cloud.compute.v1.IInstanceManagedByIgmError[], + protos.google.cloud.compute.v1.IListErrorsRegionInstanceGroupManagersRequest|null, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListErrorsResponse + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.listErrors(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It must be a string that meets the requirements in RFC1035, or an unsigned long integer: must match regexp pattern: (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)|1-9{0,19}. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. This should conform to RFC1035. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.InstanceManagedByIgmError | InstanceManagedByIgmError} 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 `listErrorsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listErrorsStream( + request?: protos.google.cloud.compute.v1.IListErrorsRegionInstanceGroupManagersRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + const defaultCallSettings = this._defaults['listErrors']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listErrors.createStream( + this.innerApiCalls.listErrors as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listErrors`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It must be a string that meets the requirements in RFC1035, or an unsigned long integer: must match regexp pattern: (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)|1-9{0,19}. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. This should conform to RFC1035. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.InstanceManagedByIgmError | InstanceManagedByIgmError}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_instance_group_managers.list_errors.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_ListErrors_async + */ + listErrorsAsync( + request?: protos.google.cloud.compute.v1.IListErrorsRegionInstanceGroupManagersRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + const defaultCallSettings = this._defaults['listErrors']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listErrors.asyncIterate( + this.innerApiCalls['listErrors'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the instances in the managed instance group and instances that are scheduled to be created. The list includes any current actions that the group has scheduled for its instances. The orderBy query parameter is not supported. The `pageToken` query parameter is supported only in the alpha and beta API and only if the group's `listManagedInstancesResults` field is set to `PAGINATED`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.ManagedInstance | ManagedInstance}. + * 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 `listManagedInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listManagedInstances( + request?: protos.google.cloud.compute.v1.IListManagedInstancesRegionInstanceGroupManagersRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IManagedInstance[], + protos.google.cloud.compute.v1.IListManagedInstancesRegionInstanceGroupManagersRequest|null, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListInstancesResponse + ]>; + listManagedInstances( + request: protos.google.cloud.compute.v1.IListManagedInstancesRegionInstanceGroupManagersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListManagedInstancesRegionInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListInstancesResponse|null|undefined, + protos.google.cloud.compute.v1.IManagedInstance>): void; + listManagedInstances( + request: protos.google.cloud.compute.v1.IListManagedInstancesRegionInstanceGroupManagersRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListManagedInstancesRegionInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListInstancesResponse|null|undefined, + protos.google.cloud.compute.v1.IManagedInstance>): void; + listManagedInstances( + request?: protos.google.cloud.compute.v1.IListManagedInstancesRegionInstanceGroupManagersRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListManagedInstancesRegionInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListInstancesResponse|null|undefined, + protos.google.cloud.compute.v1.IManagedInstance>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListManagedInstancesRegionInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListInstancesResponse|null|undefined, + protos.google.cloud.compute.v1.IManagedInstance>): + Promise<[ + protos.google.cloud.compute.v1.IManagedInstance[], + protos.google.cloud.compute.v1.IListManagedInstancesRegionInstanceGroupManagersRequest|null, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListInstancesResponse + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.listManagedInstances(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.ManagedInstance | ManagedInstance} 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 `listManagedInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listManagedInstancesStream( + request?: protos.google.cloud.compute.v1.IListManagedInstancesRegionInstanceGroupManagersRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + const defaultCallSettings = this._defaults['listManagedInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listManagedInstances.createStream( + this.innerApiCalls.listManagedInstances as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listManagedInstances`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.ManagedInstance | ManagedInstance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_instance_group_managers.list_managed_instances.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_ListManagedInstances_async + */ + listManagedInstancesAsync( + request?: protos.google.cloud.compute.v1.IListManagedInstancesRegionInstanceGroupManagersRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + const defaultCallSettings = this._defaults['listManagedInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listManagedInstances.asyncIterate( + this.innerApiCalls['listManagedInstances'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists all of the per-instance configurations defined for the managed instance group. The orderBy query parameter is not supported. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It should conform to RFC1035. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request, should conform to RFC1035. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.PerInstanceConfig | PerInstanceConfig}. + * 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 `listPerInstanceConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listPerInstanceConfigs( + request?: protos.google.cloud.compute.v1.IListPerInstanceConfigsRegionInstanceGroupManagersRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPerInstanceConfig[], + protos.google.cloud.compute.v1.IListPerInstanceConfigsRegionInstanceGroupManagersRequest|null, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListInstanceConfigsResp + ]>; + listPerInstanceConfigs( + request: protos.google.cloud.compute.v1.IListPerInstanceConfigsRegionInstanceGroupManagersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListPerInstanceConfigsRegionInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListInstanceConfigsResp|null|undefined, + protos.google.cloud.compute.v1.IPerInstanceConfig>): void; + listPerInstanceConfigs( + request: protos.google.cloud.compute.v1.IListPerInstanceConfigsRegionInstanceGroupManagersRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListPerInstanceConfigsRegionInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListInstanceConfigsResp|null|undefined, + protos.google.cloud.compute.v1.IPerInstanceConfig>): void; + listPerInstanceConfigs( + request?: protos.google.cloud.compute.v1.IListPerInstanceConfigsRegionInstanceGroupManagersRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListPerInstanceConfigsRegionInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListInstanceConfigsResp|null|undefined, + protos.google.cloud.compute.v1.IPerInstanceConfig>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListPerInstanceConfigsRegionInstanceGroupManagersRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListInstanceConfigsResp|null|undefined, + protos.google.cloud.compute.v1.IPerInstanceConfig>): + Promise<[ + protos.google.cloud.compute.v1.IPerInstanceConfig[], + protos.google.cloud.compute.v1.IListPerInstanceConfigsRegionInstanceGroupManagersRequest|null, + protos.google.cloud.compute.v1.IRegionInstanceGroupManagersListInstanceConfigsResp + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + this.initialize(); + return this.innerApiCalls.listPerInstanceConfigs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It should conform to RFC1035. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request, should conform to RFC1035. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.PerInstanceConfig | PerInstanceConfig} 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 `listPerInstanceConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listPerInstanceConfigsStream( + request?: protos.google.cloud.compute.v1.IListPerInstanceConfigsRegionInstanceGroupManagersRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + const defaultCallSettings = this._defaults['listPerInstanceConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPerInstanceConfigs.createStream( + this.innerApiCalls.listPerInstanceConfigs as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listPerInstanceConfigs`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroupManager + * The name of the managed instance group. It should conform to RFC1035. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request, should conform to RFC1035. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.PerInstanceConfig | PerInstanceConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_instance_group_managers.list_per_instance_configs.js + * region_tag:compute_v1_generated_RegionInstanceGroupManagers_ListPerInstanceConfigs_async + */ + listPerInstanceConfigsAsync( + request?: protos.google.cloud.compute.v1.IListPerInstanceConfigsRegionInstanceGroupManagersRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group_manager': request.instanceGroupManager ?? '', + }); + const defaultCallSettings = this._defaults['listPerInstanceConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPerInstanceConfigs.asyncIterate( + this.innerApiCalls['listPerInstanceConfigs'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionInstanceGroupManagersStub && !this._terminated) { + return this.regionInstanceGroupManagersStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_group_managers_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_group_managers_client_config.json new file mode 100644 index 00000000000..20202b53a6d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_group_managers_client_config.json @@ -0,0 +1,102 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionInstanceGroupManagers": { + "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": { + "AbandonInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ApplyUpdatesToInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeletePerInstanceConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListErrors": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListManagedInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListPerInstanceConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PatchPerInstanceConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RecreateInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Resize": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetInstanceTemplate": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetTargetPools": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdatePerInstanceConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_group_managers_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_group_managers_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_group_managers_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_groups_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_groups_client.ts new file mode 100644 index 00000000000..508d296295b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_groups_client.ts @@ -0,0 +1,904 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_instance_groups_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_instance_groups_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionInstanceGroups API. + * @class + * @memberof v1 + */ +export class RegionInstanceGroupsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionInstanceGroupsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionInstanceGroupsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionInstanceGroupsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionInstanceGroupsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + listInstances: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionInstanceGroups', 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.regionInstanceGroupsStub) { + return this.regionInstanceGroupsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionInstanceGroups. + this.regionInstanceGroupsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionInstanceGroups') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionInstanceGroups, + 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 regionInstanceGroupsStubMethods = + ['get', 'list', 'listInstances', 'setNamedPorts']; + for (const methodName of regionInstanceGroupsStubMethods) { + const callPromise = this.regionInstanceGroupsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionInstanceGroupsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Returns the specified instance group resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroup + * Name of the instance group resource to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @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.compute.v1.InstanceGroup | InstanceGroup}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_instance_groups.get.js + * region_tag:compute_v1_generated_RegionInstanceGroups_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionInstanceGroupRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstanceGroup, + protos.google.cloud.compute.v1.IGetRegionInstanceGroupRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionInstanceGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IInstanceGroup, + protos.google.cloud.compute.v1.IGetRegionInstanceGroupRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionInstanceGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IInstanceGroup, + protos.google.cloud.compute.v1.IGetRegionInstanceGroupRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionInstanceGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IInstanceGroup, + protos.google.cloud.compute.v1.IGetRegionInstanceGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IInstanceGroup, + protos.google.cloud.compute.v1.IGetRegionInstanceGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IInstanceGroup, + protos.google.cloud.compute.v1.IGetRegionInstanceGroupRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group': request.instanceGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Sets the named ports for the specified regional instance group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceGroup + * The name of the regional instance group where the named ports are updated. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {google.cloud.compute.v1.RegionInstanceGroupsSetNamedPortsRequest} request.regionInstanceGroupsSetNamedPortsRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_groups.set_named_ports.js + * region_tag:compute_v1_generated_RegionInstanceGroups_SetNamedPorts_async + */ + setNamedPorts( + request?: protos.google.cloud.compute.v1.ISetNamedPortsRegionInstanceGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setNamedPorts( + request: protos.google.cloud.compute.v1.ISetNamedPortsRegionInstanceGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetNamedPortsRegionInstanceGroupRequest|null|undefined, + {}|null|undefined>): void; + setNamedPorts( + request: protos.google.cloud.compute.v1.ISetNamedPortsRegionInstanceGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetNamedPortsRegionInstanceGroupRequest|null|undefined, + {}|null|undefined>): void; + setNamedPorts( + request?: protos.google.cloud.compute.v1.ISetNamedPortsRegionInstanceGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetNamedPortsRegionInstanceGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetNamedPortsRegionInstanceGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group': request.instanceGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.setNamedPorts(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves the list of instance group resources contained within the specified region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.InstanceGroup | InstanceGroup}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionInstanceGroupsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstanceGroup[], + protos.google.cloud.compute.v1.IListRegionInstanceGroupsRequest|null, + protos.google.cloud.compute.v1.IRegionInstanceGroupList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionInstanceGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionInstanceGroupsRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupList|null|undefined, + protos.google.cloud.compute.v1.IInstanceGroup>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionInstanceGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionInstanceGroupsRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupList|null|undefined, + protos.google.cloud.compute.v1.IInstanceGroup>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionInstanceGroupsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionInstanceGroupsRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupList|null|undefined, + protos.google.cloud.compute.v1.IInstanceGroup>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionInstanceGroupsRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupList|null|undefined, + protos.google.cloud.compute.v1.IInstanceGroup>): + Promise<[ + protos.google.cloud.compute.v1.IInstanceGroup[], + protos.google.cloud.compute.v1.IListRegionInstanceGroupsRequest|null, + protos.google.cloud.compute.v1.IRegionInstanceGroupList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.InstanceGroup | InstanceGroup} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionInstanceGroupsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.InstanceGroup | InstanceGroup}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_instance_groups.list.js + * region_tag:compute_v1_generated_RegionInstanceGroups_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionInstanceGroupsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the instances in the specified instance group and displays information about the named ports. Depending on the specified options, this method can list all instances or only the instances that are running. The orderBy query parameter is not supported. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroup + * Name of the regional instance group for which we want to list the instances. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {google.cloud.compute.v1.RegionInstanceGroupsListInstancesRequest} request.regionInstanceGroupsListInstancesRequestResource + * The body resource for this request + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.InstanceWithNamedPorts | InstanceWithNamedPorts}. + * 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 + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listInstances( + request?: protos.google.cloud.compute.v1.IListInstancesRegionInstanceGroupsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstanceWithNamedPorts[], + protos.google.cloud.compute.v1.IListInstancesRegionInstanceGroupsRequest|null, + protos.google.cloud.compute.v1.IRegionInstanceGroupsListInstances + ]>; + listInstances( + request: protos.google.cloud.compute.v1.IListInstancesRegionInstanceGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInstancesRegionInstanceGroupsRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupsListInstances|null|undefined, + protos.google.cloud.compute.v1.IInstanceWithNamedPorts>): void; + listInstances( + request: protos.google.cloud.compute.v1.IListInstancesRegionInstanceGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListInstancesRegionInstanceGroupsRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupsListInstances|null|undefined, + protos.google.cloud.compute.v1.IInstanceWithNamedPorts>): void; + listInstances( + request?: protos.google.cloud.compute.v1.IListInstancesRegionInstanceGroupsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListInstancesRegionInstanceGroupsRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupsListInstances|null|undefined, + protos.google.cloud.compute.v1.IInstanceWithNamedPorts>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListInstancesRegionInstanceGroupsRequest, + protos.google.cloud.compute.v1.IRegionInstanceGroupsListInstances|null|undefined, + protos.google.cloud.compute.v1.IInstanceWithNamedPorts>): + Promise<[ + protos.google.cloud.compute.v1.IInstanceWithNamedPorts[], + protos.google.cloud.compute.v1.IListInstancesRegionInstanceGroupsRequest|null, + protos.google.cloud.compute.v1.IRegionInstanceGroupsListInstances + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group': request.instanceGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.listInstances(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroup + * Name of the regional instance group for which we want to list the instances. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {google.cloud.compute.v1.RegionInstanceGroupsListInstancesRequest} request.regionInstanceGroupsListInstancesRequestResource + * The body resource for this request + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.InstanceWithNamedPorts | InstanceWithNamedPorts} 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 + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listInstancesStream( + request?: protos.google.cloud.compute.v1.IListInstancesRegionInstanceGroupsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group': request.instanceGroup ?? '', + }); + const defaultCallSettings = this._defaults['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {string} request.instanceGroup + * Name of the regional instance group for which we want to list the instances. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {google.cloud.compute.v1.RegionInstanceGroupsListInstancesRequest} request.regionInstanceGroupsListInstancesRequestResource + * The body resource for this request + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.InstanceWithNamedPorts | InstanceWithNamedPorts}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_instance_groups.list_instances.js + * region_tag:compute_v1_generated_RegionInstanceGroups_ListInstances_async + */ + listInstancesAsync( + request?: protos.google.cloud.compute.v1.IListInstancesRegionInstanceGroupsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_group': request.instanceGroup ?? '', + }); + const defaultCallSettings = this._defaults['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstances.asyncIterate( + this.innerApiCalls['listInstances'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionInstanceGroupsStub && !this._terminated) { + return this.regionInstanceGroupsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_groups_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_groups_client_config.json new file mode 100644 index 00000000000..41481773ea0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_groups_client_config.json @@ -0,0 +1,42 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionInstanceGroups": { + "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": { + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListInstances": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetNamedPorts": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_groups_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_groups_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_groups_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_templates_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_templates_client.ts new file mode 100644 index 00000000000..ae146bfd201 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_templates_client.ts @@ -0,0 +1,775 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_instance_templates_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_instance_templates_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionInstanceTemplates API. + * @class + * @memberof v1 + */ +export class RegionInstanceTemplatesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionInstanceTemplatesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionInstanceTemplatesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionInstanceTemplatesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionInstanceTemplatesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionInstanceTemplates', 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.regionInstanceTemplatesStub) { + return this.regionInstanceTemplatesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionInstanceTemplates. + this.regionInstanceTemplatesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionInstanceTemplates') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionInstanceTemplates, + 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 regionInstanceTemplatesStubMethods = + ['delete', 'get', 'insert', 'list']; + for (const methodName of regionInstanceTemplatesStubMethods) { + const callPromise = this.regionInstanceTemplatesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionInstanceTemplatesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified instance template. Deleting an instance template is permanent and cannot be undone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceTemplate + * The name of the instance template to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_templates.delete.js + * region_tag:compute_v1_generated_RegionInstanceTemplates_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionInstanceTemplateRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionInstanceTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionInstanceTemplateRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionInstanceTemplateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionInstanceTemplateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionInstanceTemplateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_template': request.instanceTemplate ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified instance template. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instanceTemplate + * The name of the instance template. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @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.compute.v1.InstanceTemplate | InstanceTemplate}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_instance_templates.get.js + * region_tag:compute_v1_generated_RegionInstanceTemplates_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionInstanceTemplateRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstanceTemplate, + protos.google.cloud.compute.v1.IGetRegionInstanceTemplateRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionInstanceTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IInstanceTemplate, + protos.google.cloud.compute.v1.IGetRegionInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionInstanceTemplateRequest, + callback: Callback< + protos.google.cloud.compute.v1.IInstanceTemplate, + protos.google.cloud.compute.v1.IGetRegionInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionInstanceTemplateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IInstanceTemplate, + protos.google.cloud.compute.v1.IGetRegionInstanceTemplateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IInstanceTemplate, + protos.google.cloud.compute.v1.IGetRegionInstanceTemplateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IInstanceTemplate, + protos.google.cloud.compute.v1.IGetRegionInstanceTemplateRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'instance_template': request.instanceTemplate ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates an instance template in the specified project and region using the global instance template whose URL is included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.InstanceTemplate} request.instanceTemplateResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instance_templates.insert.js + * region_tag:compute_v1_generated_RegionInstanceTemplates_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionInstanceTemplateRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionInstanceTemplateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionInstanceTemplateRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionInstanceTemplateRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionInstanceTemplateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionInstanceTemplateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionInstanceTemplateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves a list of instance templates that are contained within the specified project and region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the regions for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.InstanceTemplate | InstanceTemplate}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionInstanceTemplatesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IInstanceTemplate[], + protos.google.cloud.compute.v1.IListRegionInstanceTemplatesRequest|null, + protos.google.cloud.compute.v1.IInstanceTemplateList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionInstanceTemplatesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionInstanceTemplatesRequest, + protos.google.cloud.compute.v1.IInstanceTemplateList|null|undefined, + protos.google.cloud.compute.v1.IInstanceTemplate>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionInstanceTemplatesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionInstanceTemplatesRequest, + protos.google.cloud.compute.v1.IInstanceTemplateList|null|undefined, + protos.google.cloud.compute.v1.IInstanceTemplate>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionInstanceTemplatesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionInstanceTemplatesRequest, + protos.google.cloud.compute.v1.IInstanceTemplateList|null|undefined, + protos.google.cloud.compute.v1.IInstanceTemplate>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionInstanceTemplatesRequest, + protos.google.cloud.compute.v1.IInstanceTemplateList|null|undefined, + protos.google.cloud.compute.v1.IInstanceTemplate>): + Promise<[ + protos.google.cloud.compute.v1.IInstanceTemplate[], + protos.google.cloud.compute.v1.IListRegionInstanceTemplatesRequest|null, + protos.google.cloud.compute.v1.IInstanceTemplateList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the regions for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.InstanceTemplate | InstanceTemplate} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionInstanceTemplatesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the regions for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.InstanceTemplate | InstanceTemplate}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_instance_templates.list.js + * region_tag:compute_v1_generated_RegionInstanceTemplates_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionInstanceTemplatesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionInstanceTemplatesStub && !this._terminated) { + return this.regionInstanceTemplatesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_templates_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_templates_client_config.json new file mode 100644 index 00000000000..2aa64fd604c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_templates_client_config.json @@ -0,0 +1,42 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionInstanceTemplates": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_templates_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_templates_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instance_templates_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instances_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instances_client.ts new file mode 100644 index 00000000000..f477154d54b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instances_client.ts @@ -0,0 +1,398 @@ +// Copyright 2023 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, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_instances_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_instances_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionInstances API. + * @class + * @memberof v1 + */ +export class RegionInstancesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionInstancesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionInstancesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionInstancesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionInstancesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionInstances', 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.regionInstancesStub) { + return this.regionInstancesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionInstances. + this.regionInstancesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionInstances') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionInstances, + 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 regionInstancesStubMethods = + ['bulkInsert']; + for (const methodName of regionInstancesStubMethods) { + const callPromise = this.regionInstancesStub.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 = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionInstancesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Creates multiple instances in a given region. Count specifies the number of instances to create. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.BulkInsertInstanceResource} request.bulkInsertInstanceResourceResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_instances.bulk_insert.js + * region_tag:compute_v1_generated_RegionInstances_BulkInsert_async + */ + bulkInsert( + request?: protos.google.cloud.compute.v1.IBulkInsertRegionInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + bulkInsert( + request: protos.google.cloud.compute.v1.IBulkInsertRegionInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IBulkInsertRegionInstanceRequest|null|undefined, + {}|null|undefined>): void; + bulkInsert( + request: protos.google.cloud.compute.v1.IBulkInsertRegionInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IBulkInsertRegionInstanceRequest|null|undefined, + {}|null|undefined>): void; + bulkInsert( + request?: protos.google.cloud.compute.v1.IBulkInsertRegionInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IBulkInsertRegionInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IBulkInsertRegionInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.bulkInsert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + + /** + * 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.regionInstancesStub && !this._terminated) { + return this.regionInstancesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instances_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instances_client_config.json new file mode 100644 index 00000000000..520a7d18eaf --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instances_client_config.json @@ -0,0 +1,30 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionInstances": { + "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": { + "BulkInsert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instances_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instances_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_instances_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_endpoint_groups_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_endpoint_groups_client.ts new file mode 100644 index 00000000000..e57005cef6f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_endpoint_groups_client.ts @@ -0,0 +1,775 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_network_endpoint_groups_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_network_endpoint_groups_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionNetworkEndpointGroups API. + * @class + * @memberof v1 + */ +export class RegionNetworkEndpointGroupsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionNetworkEndpointGroupsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionNetworkEndpointGroupsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionNetworkEndpointGroupsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionNetworkEndpointGroupsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionNetworkEndpointGroups', 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.regionNetworkEndpointGroupsStub) { + return this.regionNetworkEndpointGroupsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionNetworkEndpointGroups. + this.regionNetworkEndpointGroupsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionNetworkEndpointGroups') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionNetworkEndpointGroups, + 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 regionNetworkEndpointGroupsStubMethods = + ['delete', 'get', 'insert', 'list']; + for (const methodName of regionNetworkEndpointGroupsStubMethods) { + const callPromise = this.regionNetworkEndpointGroupsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionNetworkEndpointGroupsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified network endpoint group. Note that the NEG cannot be deleted if it is configured as a backend of a backend service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.networkEndpointGroup + * The name of the network endpoint group to delete. It should comply with RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region where the network endpoint group is located. It should comply with RFC1035. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_network_endpoint_groups.delete.js + * region_tag:compute_v1_generated_RegionNetworkEndpointGroups_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionNetworkEndpointGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionNetworkEndpointGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionNetworkEndpointGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionNetworkEndpointGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'network_endpoint_group': request.networkEndpointGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified network endpoint group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.networkEndpointGroup + * The name of the network endpoint group. It should comply with RFC1035. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region where the network endpoint group is located. It should comply with RFC1035. + * @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.compute.v1.NetworkEndpointGroup | NetworkEndpointGroup}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_network_endpoint_groups.get.js + * region_tag:compute_v1_generated_RegionNetworkEndpointGroups_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionNetworkEndpointGroupRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetRegionNetworkEndpointGroupRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionNetworkEndpointGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetRegionNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionNetworkEndpointGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetRegionNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionNetworkEndpointGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetRegionNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetRegionNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.INetworkEndpointGroup, + protos.google.cloud.compute.v1.IGetRegionNetworkEndpointGroupRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'network_endpoint_group': request.networkEndpointGroup ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a network endpoint group in the specified project using the parameters that are included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.NetworkEndpointGroup} request.networkEndpointGroupResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region where you want to create the network endpoint group. It should comply with RFC1035. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_network_endpoint_groups.insert.js + * region_tag:compute_v1_generated_RegionNetworkEndpointGroups_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionNetworkEndpointGroupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionNetworkEndpointGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionNetworkEndpointGroupRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionNetworkEndpointGroupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionNetworkEndpointGroupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves the list of regional network endpoint groups available to the specified project in the given region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region where the network endpoint group is located. It should comply with RFC1035. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.NetworkEndpointGroup | NetworkEndpointGroup}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionNetworkEndpointGroupsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INetworkEndpointGroup[], + protos.google.cloud.compute.v1.IListRegionNetworkEndpointGroupsRequest|null, + protos.google.cloud.compute.v1.INetworkEndpointGroupList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionNetworkEndpointGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupList|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointGroup>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionNetworkEndpointGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupList|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointGroup>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionNetworkEndpointGroupsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupList|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointGroup>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionNetworkEndpointGroupsRequest, + protos.google.cloud.compute.v1.INetworkEndpointGroupList|null|undefined, + protos.google.cloud.compute.v1.INetworkEndpointGroup>): + Promise<[ + protos.google.cloud.compute.v1.INetworkEndpointGroup[], + protos.google.cloud.compute.v1.IListRegionNetworkEndpointGroupsRequest|null, + protos.google.cloud.compute.v1.INetworkEndpointGroupList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region where the network endpoint group is located. It should comply with RFC1035. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.NetworkEndpointGroup | NetworkEndpointGroup} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionNetworkEndpointGroupsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region where the network endpoint group is located. It should comply with RFC1035. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.NetworkEndpointGroup | NetworkEndpointGroup}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_network_endpoint_groups.list.js + * region_tag:compute_v1_generated_RegionNetworkEndpointGroups_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionNetworkEndpointGroupsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionNetworkEndpointGroupsStub && !this._terminated) { + return this.regionNetworkEndpointGroupsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_endpoint_groups_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_endpoint_groups_client_config.json new file mode 100644 index 00000000000..052b8d57547 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_endpoint_groups_client_config.json @@ -0,0 +1,42 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionNetworkEndpointGroups": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_endpoint_groups_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_endpoint_groups_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_endpoint_groups_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_firewall_policies_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_firewall_policies_client.ts new file mode 100644 index 00000000000..a7b9658e91d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_firewall_policies_client.ts @@ -0,0 +1,1905 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_network_firewall_policies_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_network_firewall_policies_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionNetworkFirewallPolicies API. + * @class + * @memberof v1 + */ +export class RegionNetworkFirewallPoliciesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionNetworkFirewallPoliciesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionNetworkFirewallPoliciesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionNetworkFirewallPoliciesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionNetworkFirewallPoliciesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionNetworkFirewallPolicies', 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.regionNetworkFirewallPoliciesStub) { + return this.regionNetworkFirewallPoliciesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionNetworkFirewallPolicies. + this.regionNetworkFirewallPoliciesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionNetworkFirewallPolicies') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionNetworkFirewallPolicies, + 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 regionNetworkFirewallPoliciesStubMethods = + ['addAssociation', 'addRule', 'cloneRules', 'delete', 'get', 'getAssociation', 'getEffectiveFirewalls', 'getIamPolicy', 'getRule', 'insert', 'list', 'patch', 'patchRule', 'removeAssociation', 'removeRule', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of regionNetworkFirewallPoliciesStubMethods) { + const callPromise = this.regionNetworkFirewallPoliciesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionNetworkFirewallPoliciesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Inserts an association for the specified network firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {google.cloud.compute.v1.FirewallPolicyAssociation} request.firewallPolicyAssociationResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.replaceExistingAssociation + * Indicates whether or not to replace it if an association already exists. This is false by default, in which case an error will be returned if an association already exists. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_network_firewall_policies.add_association.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_AddAssociation_async + */ + addAssociation( + request?: protos.google.cloud.compute.v1.IAddAssociationRegionNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addAssociation( + request: protos.google.cloud.compute.v1.IAddAssociationRegionNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddAssociationRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + addAssociation( + request: protos.google.cloud.compute.v1.IAddAssociationRegionNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddAssociationRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + addAssociation( + request?: protos.google.cloud.compute.v1.IAddAssociationRegionNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddAssociationRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddAssociationRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.addAssociation(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Inserts a rule into a network firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {google.cloud.compute.v1.FirewallPolicyRule} request.firewallPolicyRuleResource + * The body resource for this request + * @param {number} request.maxPriority + * When rule.priority is not specified, auto choose a unused priority between minPriority and maxPriority>. This field is exclusive with rule.priority. + * @param {number} request.minPriority + * When rule.priority is not specified, auto choose a unused priority between minPriority and maxPriority>. This field is exclusive with rule.priority. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_network_firewall_policies.add_rule.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_AddRule_async + */ + addRule( + request?: protos.google.cloud.compute.v1.IAddRuleRegionNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addRule( + request: protos.google.cloud.compute.v1.IAddRuleRegionNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddRuleRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + addRule( + request: protos.google.cloud.compute.v1.IAddRuleRegionNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddRuleRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + addRule( + request?: protos.google.cloud.compute.v1.IAddRuleRegionNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddRuleRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddRuleRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.addRule(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Copies rules to the specified network firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.sourceFirewallPolicy + * The firewall policy from which to copy rules. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_network_firewall_policies.clone_rules.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_CloneRules_async + */ + cloneRules( + request?: protos.google.cloud.compute.v1.ICloneRulesRegionNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + cloneRules( + request: protos.google.cloud.compute.v1.ICloneRulesRegionNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICloneRulesRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + cloneRules( + request: protos.google.cloud.compute.v1.ICloneRulesRegionNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICloneRulesRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + cloneRules( + request?: protos.google.cloud.compute.v1.ICloneRulesRegionNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICloneRulesRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ICloneRulesRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.cloneRules(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified network firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_network_firewall_policies.delete.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified network firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to get. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @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.compute.v1.FirewallPolicy | FirewallPolicy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_network_firewall_policies.get.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetRegionNetworkFirewallPolicyRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicy, + protos.google.cloud.compute.v1.IGetRegionNetworkFirewallPolicyRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets an association with the specified name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to which the queried association belongs. + * @param {string} request.name + * The name of the association to get from the firewall policy. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @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.compute.v1.FirewallPolicyAssociation | FirewallPolicyAssociation}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_network_firewall_policies.get_association.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_GetAssociation_async + */ + getAssociation( + request?: protos.google.cloud.compute.v1.IGetAssociationRegionNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationRegionNetworkFirewallPolicyRequest|undefined, {}|undefined + ]>; + getAssociation( + request: protos.google.cloud.compute.v1.IGetAssociationRegionNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getAssociation( + request: protos.google.cloud.compute.v1.IGetAssociationRegionNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getAssociation( + request?: protos.google.cloud.compute.v1.IGetAssociationRegionNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicyAssociation, + protos.google.cloud.compute.v1.IGetAssociationRegionNetworkFirewallPolicyRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.getAssociation(request, options, callback); + } +/** + * Returns the effective firewalls on a given network. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.network + * Network reference + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @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.compute.v1.RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse | RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_network_firewall_policies.get_effective_firewalls.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_GetEffectiveFirewalls_async + */ + getEffectiveFirewalls( + request?: protos.google.cloud.compute.v1.IGetEffectiveFirewallsRegionNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IRegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsRegionNetworkFirewallPolicyRequest|undefined, {}|undefined + ]>; + getEffectiveFirewalls( + request: protos.google.cloud.compute.v1.IGetEffectiveFirewallsRegionNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IRegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getEffectiveFirewalls( + request: protos.google.cloud.compute.v1.IGetEffectiveFirewallsRegionNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IRegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getEffectiveFirewalls( + request?: protos.google.cloud.compute.v1.IGetEffectiveFirewallsRegionNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IRegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IRegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IRegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse, + protos.google.cloud.compute.v1.IGetEffectiveFirewallsRegionNetworkFirewallPolicyRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.getEffectiveFirewalls(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_network_firewall_policies.get_iam_policy.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyRegionNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionNetworkFirewallPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyRegionNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyRegionNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyRegionNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyRegionNetworkFirewallPolicyRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Gets a rule of the specified priority. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to which the queried rule belongs. + * @param {number} request.priority + * The priority of the rule to get from the firewall policy. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @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.compute.v1.FirewallPolicyRule | FirewallPolicyRule}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_network_firewall_policies.get_rule.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_GetRule_async + */ + getRule( + request?: protos.google.cloud.compute.v1.IGetRuleRegionNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleRegionNetworkFirewallPolicyRequest|undefined, {}|undefined + ]>; + getRule( + request: protos.google.cloud.compute.v1.IGetRuleRegionNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getRule( + request: protos.google.cloud.compute.v1.IGetRuleRegionNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + getRule( + request?: protos.google.cloud.compute.v1.IGetRuleRegionNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicyRule, + protos.google.cloud.compute.v1.IGetRuleRegionNetworkFirewallPolicyRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.getRule(request, options, callback); + } +/** + * Creates a new network firewall policy in the specified project and region. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.FirewallPolicy} request.firewallPolicyResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_network_firewall_policies.insert.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified network firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {google.cloud.compute.v1.FirewallPolicy} request.firewallPolicyResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_network_firewall_policies.patch.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches a rule of the specified priority. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {google.cloud.compute.v1.FirewallPolicyRule} request.firewallPolicyRuleResource + * The body resource for this request + * @param {number} request.priority + * The priority of the rule to patch. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_network_firewall_policies.patch_rule.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_PatchRule_async + */ + patchRule( + request?: protos.google.cloud.compute.v1.IPatchRuleRegionNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patchRule( + request: protos.google.cloud.compute.v1.IPatchRuleRegionNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRuleRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + patchRule( + request: protos.google.cloud.compute.v1.IPatchRuleRegionNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRuleRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + patchRule( + request?: protos.google.cloud.compute.v1.IPatchRuleRegionNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRuleRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRuleRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.patchRule(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Removes an association for the specified network firewall policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {string} request.name + * Name for the association that will be removed. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_network_firewall_policies.remove_association.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_RemoveAssociation_async + */ + removeAssociation( + request?: protos.google.cloud.compute.v1.IRemoveAssociationRegionNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + removeAssociation( + request: protos.google.cloud.compute.v1.IRemoveAssociationRegionNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveAssociationRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + removeAssociation( + request: protos.google.cloud.compute.v1.IRemoveAssociationRegionNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveAssociationRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + removeAssociation( + request?: protos.google.cloud.compute.v1.IRemoveAssociationRegionNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveAssociationRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveAssociationRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeAssociation(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes a rule of the specified priority. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.firewallPolicy + * Name of the firewall policy to update. + * @param {number} request.priority + * The priority of the rule to remove from the firewall policy. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_network_firewall_policies.remove_rule.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_RemoveRule_async + */ + removeRule( + request?: protos.google.cloud.compute.v1.IRemoveRuleRegionNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + removeRule( + request: protos.google.cloud.compute.v1.IRemoveRuleRegionNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveRuleRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + removeRule( + request: protos.google.cloud.compute.v1.IRemoveRuleRegionNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveRuleRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + removeRule( + request?: protos.google.cloud.compute.v1.IRemoveRuleRegionNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveRuleRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveRuleRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'firewall_policy': request.firewallPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeRule(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {google.cloud.compute.v1.RegionSetPolicyRequest} request.regionSetPolicyRequestResource + * The body resource for this request + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_network_firewall_policies.set_iam_policy.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyRegionNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionNetworkFirewallPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyRegionNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyRegionNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyRegionNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyRegionNetworkFirewallPolicyRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_network_firewall_policies.test_iam_permissions.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsRegionNetworkFirewallPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsRegionNetworkFirewallPolicyRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsRegionNetworkFirewallPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsRegionNetworkFirewallPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsRegionNetworkFirewallPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsRegionNetworkFirewallPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsRegionNetworkFirewallPolicyRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + /** + * Lists all the network firewall policies that have been configured for the specified project in the given region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.FirewallPolicy | FirewallPolicy}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionNetworkFirewallPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicy[], + protos.google.cloud.compute.v1.IListRegionNetworkFirewallPoliciesRequest|null, + protos.google.cloud.compute.v1.IFirewallPolicyList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionNetworkFirewallPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionNetworkFirewallPoliciesRequest, + protos.google.cloud.compute.v1.IFirewallPolicyList|null|undefined, + protos.google.cloud.compute.v1.IFirewallPolicy>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionNetworkFirewallPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionNetworkFirewallPoliciesRequest, + protos.google.cloud.compute.v1.IFirewallPolicyList|null|undefined, + protos.google.cloud.compute.v1.IFirewallPolicy>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionNetworkFirewallPoliciesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionNetworkFirewallPoliciesRequest, + protos.google.cloud.compute.v1.IFirewallPolicyList|null|undefined, + protos.google.cloud.compute.v1.IFirewallPolicy>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionNetworkFirewallPoliciesRequest, + protos.google.cloud.compute.v1.IFirewallPolicyList|null|undefined, + protos.google.cloud.compute.v1.IFirewallPolicy>): + Promise<[ + protos.google.cloud.compute.v1.IFirewallPolicy[], + protos.google.cloud.compute.v1.IListRegionNetworkFirewallPoliciesRequest|null, + protos.google.cloud.compute.v1.IFirewallPolicyList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.FirewallPolicy | FirewallPolicy} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionNetworkFirewallPoliciesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.FirewallPolicy | FirewallPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_network_firewall_policies.list.js + * region_tag:compute_v1_generated_RegionNetworkFirewallPolicies_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionNetworkFirewallPoliciesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionNetworkFirewallPoliciesStub && !this._terminated) { + return this.regionNetworkFirewallPoliciesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_firewall_policies_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_firewall_policies_client_config.json new file mode 100644 index 00000000000..200e56daa33 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_firewall_policies_client_config.json @@ -0,0 +1,94 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionNetworkFirewallPolicies": { + "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": { + "AddAssociation": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AddRule": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CloneRules": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetAssociation": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetEffectiveFirewalls": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetRule": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PatchRule": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveAssociation": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveRule": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_firewall_policies_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_firewall_policies_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_network_firewall_policies_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_notification_endpoints_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_notification_endpoints_client.ts new file mode 100644 index 00000000000..f17c69740c5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_notification_endpoints_client.ts @@ -0,0 +1,775 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_notification_endpoints_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_notification_endpoints_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionNotificationEndpoints API. + * @class + * @memberof v1 + */ +export class RegionNotificationEndpointsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionNotificationEndpointsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionNotificationEndpointsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionNotificationEndpointsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionNotificationEndpointsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionNotificationEndpoints', 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.regionNotificationEndpointsStub) { + return this.regionNotificationEndpointsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionNotificationEndpoints. + this.regionNotificationEndpointsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionNotificationEndpoints') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionNotificationEndpoints, + 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 regionNotificationEndpointsStubMethods = + ['delete', 'get', 'insert', 'list']; + for (const methodName of regionNotificationEndpointsStubMethods) { + const callPromise = this.regionNotificationEndpointsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionNotificationEndpointsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified NotificationEndpoint in the given region + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.notificationEndpoint + * Name of the NotificationEndpoint resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_notification_endpoints.delete.js + * region_tag:compute_v1_generated_RegionNotificationEndpoints_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionNotificationEndpointRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionNotificationEndpointRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionNotificationEndpointRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionNotificationEndpointRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionNotificationEndpointRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionNotificationEndpointRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionNotificationEndpointRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionNotificationEndpointRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'notification_endpoint': request.notificationEndpoint ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified NotificationEndpoint resource in the given region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.notificationEndpoint + * Name of the NotificationEndpoint resource to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @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.compute.v1.NotificationEndpoint | NotificationEndpoint}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_notification_endpoints.get.js + * region_tag:compute_v1_generated_RegionNotificationEndpoints_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionNotificationEndpointRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INotificationEndpoint, + protos.google.cloud.compute.v1.IGetRegionNotificationEndpointRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionNotificationEndpointRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.INotificationEndpoint, + protos.google.cloud.compute.v1.IGetRegionNotificationEndpointRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionNotificationEndpointRequest, + callback: Callback< + protos.google.cloud.compute.v1.INotificationEndpoint, + protos.google.cloud.compute.v1.IGetRegionNotificationEndpointRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionNotificationEndpointRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.INotificationEndpoint, + protos.google.cloud.compute.v1.IGetRegionNotificationEndpointRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.INotificationEndpoint, + protos.google.cloud.compute.v1.IGetRegionNotificationEndpointRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.INotificationEndpoint, + protos.google.cloud.compute.v1.IGetRegionNotificationEndpointRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'notification_endpoint': request.notificationEndpoint ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Create a NotificationEndpoint in the specified project in the given region using the parameters that are included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.NotificationEndpoint} request.notificationEndpointResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_notification_endpoints.insert.js + * region_tag:compute_v1_generated_RegionNotificationEndpoints_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionNotificationEndpointRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionNotificationEndpointRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionNotificationEndpointRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionNotificationEndpointRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionNotificationEndpointRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionNotificationEndpointRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionNotificationEndpointRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionNotificationEndpointRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Lists the NotificationEndpoints for a project in the given region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.NotificationEndpoint | NotificationEndpoint}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionNotificationEndpointsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.INotificationEndpoint[], + protos.google.cloud.compute.v1.IListRegionNotificationEndpointsRequest|null, + protos.google.cloud.compute.v1.INotificationEndpointList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionNotificationEndpointsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionNotificationEndpointsRequest, + protos.google.cloud.compute.v1.INotificationEndpointList|null|undefined, + protos.google.cloud.compute.v1.INotificationEndpoint>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionNotificationEndpointsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionNotificationEndpointsRequest, + protos.google.cloud.compute.v1.INotificationEndpointList|null|undefined, + protos.google.cloud.compute.v1.INotificationEndpoint>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionNotificationEndpointsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionNotificationEndpointsRequest, + protos.google.cloud.compute.v1.INotificationEndpointList|null|undefined, + protos.google.cloud.compute.v1.INotificationEndpoint>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionNotificationEndpointsRequest, + protos.google.cloud.compute.v1.INotificationEndpointList|null|undefined, + protos.google.cloud.compute.v1.INotificationEndpoint>): + Promise<[ + protos.google.cloud.compute.v1.INotificationEndpoint[], + protos.google.cloud.compute.v1.IListRegionNotificationEndpointsRequest|null, + protos.google.cloud.compute.v1.INotificationEndpointList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.NotificationEndpoint | NotificationEndpoint} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionNotificationEndpointsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.NotificationEndpoint | NotificationEndpoint}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_notification_endpoints.list.js + * region_tag:compute_v1_generated_RegionNotificationEndpoints_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionNotificationEndpointsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionNotificationEndpointsStub && !this._terminated) { + return this.regionNotificationEndpointsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_notification_endpoints_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_notification_endpoints_client_config.json new file mode 100644 index 00000000000..865932573f5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_notification_endpoints_client_config.json @@ -0,0 +1,42 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionNotificationEndpoints": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_notification_endpoints_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_notification_endpoints_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_notification_endpoints_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_operations_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_operations_client.ts new file mode 100644 index 00000000000..57b0340cd35 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_operations_client.ts @@ -0,0 +1,748 @@ +// Copyright 2023 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_operations_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_operations_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionOperations API. + * @class + * @memberof v1 + */ +export class RegionOperationsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionOperationsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionOperationsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionOperationsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionOperationsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionOperations', 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.regionOperationsStub) { + return this.regionOperationsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionOperations. + this.regionOperationsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionOperations') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionOperations, + 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 regionOperationsStubMethods = + ['delete', 'get', 'list', 'wait']; + for (const methodName of regionOperationsStubMethods) { + const callPromise = this.regionOperationsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionOperationsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified region-specific Operations resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Name of the Operations resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @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.compute.v1.DeleteRegionOperationResponse | DeleteRegionOperationResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_operations.delete.js + * region_tag:compute_v1_generated_RegionOperations_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionOperationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IDeleteRegionOperationResponse, + protos.google.cloud.compute.v1.IDeleteRegionOperationRequest|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionOperationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IDeleteRegionOperationResponse, + protos.google.cloud.compute.v1.IDeleteRegionOperationRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionOperationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IDeleteRegionOperationResponse, + protos.google.cloud.compute.v1.IDeleteRegionOperationRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionOperationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IDeleteRegionOperationResponse, + protos.google.cloud.compute.v1.IDeleteRegionOperationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IDeleteRegionOperationResponse, + protos.google.cloud.compute.v1.IDeleteRegionOperationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IDeleteRegionOperationResponse, + protos.google.cloud.compute.v1.IDeleteRegionOperationRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'operation': request.operation ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback); + } +/** + * Retrieves the specified region-specific Operations resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Name of the Operations resource to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @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.compute.v1.Operation | Operation}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_operations.get.js + * region_tag:compute_v1_generated_RegionOperations_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionOperationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetRegionOperationRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionOperationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetRegionOperationRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionOperationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetRegionOperationRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionOperationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetRegionOperationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetRegionOperationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetRegionOperationRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'operation': request.operation ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the `GET` method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Name of the Operations resource to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @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.compute.v1.Operation | Operation}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_operations.wait.js + * region_tag:compute_v1_generated_RegionOperations_Wait_async + */ + wait( + request?: protos.google.cloud.compute.v1.IWaitRegionOperationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitRegionOperationRequest|undefined, {}|undefined + ]>; + wait( + request: protos.google.cloud.compute.v1.IWaitRegionOperationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitRegionOperationRequest|null|undefined, + {}|null|undefined>): void; + wait( + request: protos.google.cloud.compute.v1.IWaitRegionOperationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitRegionOperationRequest|null|undefined, + {}|null|undefined>): void; + wait( + request?: protos.google.cloud.compute.v1.IWaitRegionOperationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitRegionOperationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitRegionOperationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitRegionOperationRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'operation': request.operation ?? '', + }); + this.initialize(); + return this.innerApiCalls.wait(request, options, callback); + } + + /** + * Retrieves a list of Operation resources contained within the specified region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Operation | Operation}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionOperationsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IOperation[], + protos.google.cloud.compute.v1.IListRegionOperationsRequest|null, + protos.google.cloud.compute.v1.IOperationList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionOperationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionOperationsRequest, + protos.google.cloud.compute.v1.IOperationList|null|undefined, + protos.google.cloud.compute.v1.IOperation>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionOperationsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionOperationsRequest, + protos.google.cloud.compute.v1.IOperationList|null|undefined, + protos.google.cloud.compute.v1.IOperation>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionOperationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionOperationsRequest, + protos.google.cloud.compute.v1.IOperationList|null|undefined, + protos.google.cloud.compute.v1.IOperation>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionOperationsRequest, + protos.google.cloud.compute.v1.IOperationList|null|undefined, + protos.google.cloud.compute.v1.IOperation>): + Promise<[ + protos.google.cloud.compute.v1.IOperation[], + protos.google.cloud.compute.v1.IListRegionOperationsRequest|null, + protos.google.cloud.compute.v1.IOperationList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Operation | Operation} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionOperationsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Operation | Operation}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_operations.list.js + * region_tag:compute_v1_generated_RegionOperations_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionOperationsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionOperationsStub && !this._terminated) { + return this.regionOperationsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_operations_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_operations_client_config.json new file mode 100644 index 00000000000..517773ba1eb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_operations_client_config.json @@ -0,0 +1,42 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionOperations": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Wait": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_operations_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_operations_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_operations_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_security_policies_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_security_policies_client.ts new file mode 100644 index 00000000000..6d8138cd3e8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_security_policies_client.ts @@ -0,0 +1,870 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_security_policies_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_security_policies_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionSecurityPolicies API. + * @class + * @memberof v1 + */ +export class RegionSecurityPoliciesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionSecurityPoliciesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionSecurityPoliciesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionSecurityPoliciesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionSecurityPoliciesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionSecurityPolicies', 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.regionSecurityPoliciesStub) { + return this.regionSecurityPoliciesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionSecurityPolicies. + this.regionSecurityPoliciesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionSecurityPolicies') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionSecurityPolicies, + 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 regionSecurityPoliciesStubMethods = + ['delete', 'get', 'insert', 'list', 'patch']; + for (const methodName of regionSecurityPoliciesStubMethods) { + const callPromise = this.regionSecurityPoliciesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionSecurityPoliciesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.securityPolicy + * Name of the security policy to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_security_policies.delete.js + * region_tag:compute_v1_generated_RegionSecurityPolicies_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionSecurityPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionSecurityPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionSecurityPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionSecurityPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionSecurityPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionSecurityPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'security_policy': request.securityPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * List all of the ordered rules present in a single specified policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.securityPolicy + * Name of the security policy to get. + * @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.compute.v1.SecurityPolicy | SecurityPolicy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_security_policies.get.js + * region_tag:compute_v1_generated_RegionSecurityPolicies_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionSecurityPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISecurityPolicy, + protos.google.cloud.compute.v1.IGetRegionSecurityPolicyRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionSecurityPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ISecurityPolicy, + protos.google.cloud.compute.v1.IGetRegionSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionSecurityPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ISecurityPolicy, + protos.google.cloud.compute.v1.IGetRegionSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionSecurityPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ISecurityPolicy, + protos.google.cloud.compute.v1.IGetRegionSecurityPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ISecurityPolicy, + protos.google.cloud.compute.v1.IGetRegionSecurityPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ISecurityPolicy, + protos.google.cloud.compute.v1.IGetRegionSecurityPolicyRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'security_policy': request.securityPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a new policy in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.SecurityPolicy} request.securityPolicyResource + * The body resource for this request + * @param {boolean} request.validateOnly + * If true, the request will not be committed. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_security_policies.insert.js + * region_tag:compute_v1_generated_RegionSecurityPolicies_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionSecurityPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionSecurityPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionSecurityPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionSecurityPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionSecurityPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionSecurityPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified policy with the data included in the request. To clear fields in the rule, leave the fields empty and specify them in the updateMask. This cannot be used to be update the rules in the policy. Please use the per rule methods like addRule, patchRule, and removeRule instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.securityPolicy + * Name of the security policy to update. + * @param {google.cloud.compute.v1.SecurityPolicy} request.securityPolicyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_security_policies.patch.js + * region_tag:compute_v1_generated_RegionSecurityPolicies_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionSecurityPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionSecurityPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionSecurityPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionSecurityPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionSecurityPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionSecurityPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'security_policy': request.securityPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * List all the policies that have been configured for the specified project and region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.SecurityPolicy | SecurityPolicy}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionSecurityPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISecurityPolicy[], + protos.google.cloud.compute.v1.IListRegionSecurityPoliciesRequest|null, + protos.google.cloud.compute.v1.ISecurityPolicyList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionSecurityPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionSecurityPoliciesRequest, + protos.google.cloud.compute.v1.ISecurityPolicyList|null|undefined, + protos.google.cloud.compute.v1.ISecurityPolicy>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionSecurityPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionSecurityPoliciesRequest, + protos.google.cloud.compute.v1.ISecurityPolicyList|null|undefined, + protos.google.cloud.compute.v1.ISecurityPolicy>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionSecurityPoliciesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionSecurityPoliciesRequest, + protos.google.cloud.compute.v1.ISecurityPolicyList|null|undefined, + protos.google.cloud.compute.v1.ISecurityPolicy>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionSecurityPoliciesRequest, + protos.google.cloud.compute.v1.ISecurityPolicyList|null|undefined, + protos.google.cloud.compute.v1.ISecurityPolicy>): + Promise<[ + protos.google.cloud.compute.v1.ISecurityPolicy[], + protos.google.cloud.compute.v1.IListRegionSecurityPoliciesRequest|null, + protos.google.cloud.compute.v1.ISecurityPolicyList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.SecurityPolicy | SecurityPolicy} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionSecurityPoliciesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.SecurityPolicy | SecurityPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_security_policies.list.js + * region_tag:compute_v1_generated_RegionSecurityPolicies_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionSecurityPoliciesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionSecurityPoliciesStub && !this._terminated) { + return this.regionSecurityPoliciesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_security_policies_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_security_policies_client_config.json new file mode 100644 index 00000000000..410ee33280a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_security_policies_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionSecurityPolicies": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_security_policies_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_security_policies_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_security_policies_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_certificates_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_certificates_client.ts new file mode 100644 index 00000000000..e86843d9ad6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_certificates_client.ts @@ -0,0 +1,775 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_ssl_certificates_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_ssl_certificates_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionSslCertificates API. + * @class + * @memberof v1 + */ +export class RegionSslCertificatesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionSslCertificatesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionSslCertificatesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionSslCertificatesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionSslCertificatesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionSslCertificates', 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.regionSslCertificatesStub) { + return this.regionSslCertificatesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionSslCertificates. + this.regionSslCertificatesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionSslCertificates') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionSslCertificates, + 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 regionSslCertificatesStubMethods = + ['delete', 'get', 'insert', 'list']; + for (const methodName of regionSslCertificatesStubMethods) { + const callPromise = this.regionSslCertificatesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionSslCertificatesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified SslCertificate resource in the region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.sslCertificate + * Name of the SslCertificate resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_ssl_certificates.delete.js + * region_tag:compute_v1_generated_RegionSslCertificates_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionSslCertificateRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionSslCertificateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionSslCertificateRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionSslCertificateRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionSslCertificateRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionSslCertificateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionSslCertificateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionSslCertificateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'ssl_certificate': request.sslCertificate ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified SslCertificate resource in the specified region. Get a list of available SSL certificates by making a list() request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.sslCertificate + * Name of the SslCertificate resource to return. + * @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.compute.v1.SslCertificate | SslCertificate}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_ssl_certificates.get.js + * region_tag:compute_v1_generated_RegionSslCertificates_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionSslCertificateRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISslCertificate, + protos.google.cloud.compute.v1.IGetRegionSslCertificateRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionSslCertificateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ISslCertificate, + protos.google.cloud.compute.v1.IGetRegionSslCertificateRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionSslCertificateRequest, + callback: Callback< + protos.google.cloud.compute.v1.ISslCertificate, + protos.google.cloud.compute.v1.IGetRegionSslCertificateRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionSslCertificateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ISslCertificate, + protos.google.cloud.compute.v1.IGetRegionSslCertificateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ISslCertificate, + protos.google.cloud.compute.v1.IGetRegionSslCertificateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ISslCertificate, + protos.google.cloud.compute.v1.IGetRegionSslCertificateRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'ssl_certificate': request.sslCertificate ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a SslCertificate resource in the specified project and region using the data included in the request + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.SslCertificate} request.sslCertificateResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_ssl_certificates.insert.js + * region_tag:compute_v1_generated_RegionSslCertificates_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionSslCertificateRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionSslCertificateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionSslCertificateRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionSslCertificateRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionSslCertificateRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionSslCertificateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionSslCertificateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionSslCertificateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves the list of SslCertificate resources available to the specified project in the specified region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.SslCertificate | SslCertificate}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionSslCertificatesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISslCertificate[], + protos.google.cloud.compute.v1.IListRegionSslCertificatesRequest|null, + protos.google.cloud.compute.v1.ISslCertificateList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionSslCertificatesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionSslCertificatesRequest, + protos.google.cloud.compute.v1.ISslCertificateList|null|undefined, + protos.google.cloud.compute.v1.ISslCertificate>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionSslCertificatesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionSslCertificatesRequest, + protos.google.cloud.compute.v1.ISslCertificateList|null|undefined, + protos.google.cloud.compute.v1.ISslCertificate>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionSslCertificatesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionSslCertificatesRequest, + protos.google.cloud.compute.v1.ISslCertificateList|null|undefined, + protos.google.cloud.compute.v1.ISslCertificate>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionSslCertificatesRequest, + protos.google.cloud.compute.v1.ISslCertificateList|null|undefined, + protos.google.cloud.compute.v1.ISslCertificate>): + Promise<[ + protos.google.cloud.compute.v1.ISslCertificate[], + protos.google.cloud.compute.v1.IListRegionSslCertificatesRequest|null, + protos.google.cloud.compute.v1.ISslCertificateList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.SslCertificate | SslCertificate} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionSslCertificatesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.SslCertificate | SslCertificate}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_ssl_certificates.list.js + * region_tag:compute_v1_generated_RegionSslCertificates_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionSslCertificatesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionSslCertificatesStub && !this._terminated) { + return this.regionSslCertificatesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_certificates_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_certificates_client_config.json new file mode 100644 index 00000000000..af77bfa957d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_certificates_client_config.json @@ -0,0 +1,42 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionSslCertificates": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_certificates_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_certificates_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_certificates_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_policies_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_policies_client.ts new file mode 100644 index 00000000000..37a3281003b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_policies_client.ts @@ -0,0 +1,952 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_ssl_policies_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_ssl_policies_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionSslPolicies API. + * @class + * @memberof v1 + */ +export class RegionSslPoliciesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionSslPoliciesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionSslPoliciesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionSslPoliciesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionSslPoliciesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionSslPolicies', 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.regionSslPoliciesStub) { + return this.regionSslPoliciesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionSslPolicies. + this.regionSslPoliciesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionSslPolicies') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionSslPolicies, + 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 regionSslPoliciesStubMethods = + ['delete', 'get', 'insert', 'list', 'listAvailableFeatures', 'patch']; + for (const methodName of regionSslPoliciesStubMethods) { + const callPromise = this.regionSslPoliciesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionSslPoliciesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified SSL policy. The SSL policy resource can be deleted only if it is not in use by any TargetHttpsProxy or TargetSslProxy resources. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.sslPolicy + * Name of the SSL policy to delete. The name must be 1-63 characters long, and comply with RFC1035. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_ssl_policies.delete.js + * region_tag:compute_v1_generated_RegionSslPolicies_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionSslPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionSslPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionSslPolicyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionSslPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionSslPolicyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionSslPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionSslPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionSslPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'ssl_policy': request.sslPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Lists all of the ordered rules present in a single specified policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.sslPolicy + * Name of the SSL policy to update. The name must be 1-63 characters long, and comply with RFC1035. + * @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.compute.v1.SslPolicy | SslPolicy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_ssl_policies.get.js + * region_tag:compute_v1_generated_RegionSslPolicies_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionSslPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISslPolicy, + protos.google.cloud.compute.v1.IGetRegionSslPolicyRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionSslPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ISslPolicy, + protos.google.cloud.compute.v1.IGetRegionSslPolicyRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionSslPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ISslPolicy, + protos.google.cloud.compute.v1.IGetRegionSslPolicyRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionSslPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ISslPolicy, + protos.google.cloud.compute.v1.IGetRegionSslPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ISslPolicy, + protos.google.cloud.compute.v1.IGetRegionSslPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ISslPolicy, + protos.google.cloud.compute.v1.IGetRegionSslPolicyRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'ssl_policy': request.sslPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a new policy in the specified project and region using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.SslPolicy} request.sslPolicyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_ssl_policies.insert.js + * region_tag:compute_v1_generated_RegionSslPolicies_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionSslPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionSslPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionSslPolicyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionSslPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionSslPolicyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionSslPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionSslPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionSslPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Lists all features that can be specified in the SSL policy when using custom profile. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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.compute.v1.SslPoliciesListAvailableFeaturesResponse | SslPoliciesListAvailableFeaturesResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_ssl_policies.list_available_features.js + * region_tag:compute_v1_generated_RegionSslPolicies_ListAvailableFeatures_async + */ + listAvailableFeatures( + request?: protos.google.cloud.compute.v1.IListAvailableFeaturesRegionSslPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISslPoliciesListAvailableFeaturesResponse, + protos.google.cloud.compute.v1.IListAvailableFeaturesRegionSslPoliciesRequest|undefined, {}|undefined + ]>; + listAvailableFeatures( + request: protos.google.cloud.compute.v1.IListAvailableFeaturesRegionSslPoliciesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ISslPoliciesListAvailableFeaturesResponse, + protos.google.cloud.compute.v1.IListAvailableFeaturesRegionSslPoliciesRequest|null|undefined, + {}|null|undefined>): void; + listAvailableFeatures( + request: protos.google.cloud.compute.v1.IListAvailableFeaturesRegionSslPoliciesRequest, + callback: Callback< + protos.google.cloud.compute.v1.ISslPoliciesListAvailableFeaturesResponse, + protos.google.cloud.compute.v1.IListAvailableFeaturesRegionSslPoliciesRequest|null|undefined, + {}|null|undefined>): void; + listAvailableFeatures( + request?: protos.google.cloud.compute.v1.IListAvailableFeaturesRegionSslPoliciesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ISslPoliciesListAvailableFeaturesResponse, + protos.google.cloud.compute.v1.IListAvailableFeaturesRegionSslPoliciesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ISslPoliciesListAvailableFeaturesResponse, + protos.google.cloud.compute.v1.IListAvailableFeaturesRegionSslPoliciesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ISslPoliciesListAvailableFeaturesResponse, + protos.google.cloud.compute.v1.IListAvailableFeaturesRegionSslPoliciesRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.listAvailableFeatures(request, options, callback); + } +/** + * Patches the specified SSL policy with the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.sslPolicy + * Name of the SSL policy to update. The name must be 1-63 characters long, and comply with RFC1035. + * @param {google.cloud.compute.v1.SslPolicy} request.sslPolicyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_ssl_policies.patch.js + * region_tag:compute_v1_generated_RegionSslPolicies_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionSslPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionSslPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionSslPolicyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionSslPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionSslPolicyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionSslPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionSslPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionSslPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'ssl_policy': request.sslPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Lists all the SSL policies that have been configured for the specified project and region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.SslPolicy | SslPolicy}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionSslPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISslPolicy[], + protos.google.cloud.compute.v1.IListRegionSslPoliciesRequest|null, + protos.google.cloud.compute.v1.ISslPoliciesList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionSslPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionSslPoliciesRequest, + protos.google.cloud.compute.v1.ISslPoliciesList|null|undefined, + protos.google.cloud.compute.v1.ISslPolicy>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionSslPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionSslPoliciesRequest, + protos.google.cloud.compute.v1.ISslPoliciesList|null|undefined, + protos.google.cloud.compute.v1.ISslPolicy>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionSslPoliciesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionSslPoliciesRequest, + protos.google.cloud.compute.v1.ISslPoliciesList|null|undefined, + protos.google.cloud.compute.v1.ISslPolicy>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionSslPoliciesRequest, + protos.google.cloud.compute.v1.ISslPoliciesList|null|undefined, + protos.google.cloud.compute.v1.ISslPolicy>): + Promise<[ + protos.google.cloud.compute.v1.ISslPolicy[], + protos.google.cloud.compute.v1.IListRegionSslPoliciesRequest|null, + protos.google.cloud.compute.v1.ISslPoliciesList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.SslPolicy | SslPolicy} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionSslPoliciesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.SslPolicy | SslPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_ssl_policies.list.js + * region_tag:compute_v1_generated_RegionSslPolicies_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionSslPoliciesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionSslPoliciesStub && !this._terminated) { + return this.regionSslPoliciesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_policies_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_policies_client_config.json new file mode 100644 index 00000000000..070c4506280 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_policies_client_config.json @@ -0,0 +1,50 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionSslPolicies": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListAvailableFeatures": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_policies_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_policies_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_ssl_policies_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_http_proxies_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_http_proxies_client.ts new file mode 100644 index 00000000000..057553e68f7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_http_proxies_client.ts @@ -0,0 +1,868 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_target_http_proxies_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_target_http_proxies_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionTargetHttpProxies API. + * @class + * @memberof v1 + */ +export class RegionTargetHttpProxiesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionTargetHttpProxiesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionTargetHttpProxiesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionTargetHttpProxiesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionTargetHttpProxiesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionTargetHttpProxies', 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.regionTargetHttpProxiesStub) { + return this.regionTargetHttpProxiesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionTargetHttpProxies. + this.regionTargetHttpProxiesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionTargetHttpProxies') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionTargetHttpProxies, + 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 regionTargetHttpProxiesStubMethods = + ['delete', 'get', 'insert', 'list', 'setUrlMap']; + for (const methodName of regionTargetHttpProxiesStubMethods) { + const callPromise = this.regionTargetHttpProxiesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionTargetHttpProxiesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified TargetHttpProxy resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetHttpProxy + * Name of the TargetHttpProxy resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_target_http_proxies.delete.js + * region_tag:compute_v1_generated_RegionTargetHttpProxies_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionTargetHttpProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionTargetHttpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionTargetHttpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionTargetHttpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionTargetHttpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_http_proxy': request.targetHttpProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified TargetHttpProxy resource in the specified region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.targetHttpProxy + * Name of the TargetHttpProxy resource to return. + * @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.compute.v1.TargetHttpProxy | TargetHttpProxy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_target_http_proxies.get.js + * region_tag:compute_v1_generated_RegionTargetHttpProxies_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionTargetHttpProxyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetHttpProxy, + protos.google.cloud.compute.v1.IGetRegionTargetHttpProxyRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionTargetHttpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITargetHttpProxy, + protos.google.cloud.compute.v1.IGetRegionTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionTargetHttpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITargetHttpProxy, + protos.google.cloud.compute.v1.IGetRegionTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionTargetHttpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITargetHttpProxy, + protos.google.cloud.compute.v1.IGetRegionTargetHttpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITargetHttpProxy, + protos.google.cloud.compute.v1.IGetRegionTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITargetHttpProxy, + protos.google.cloud.compute.v1.IGetRegionTargetHttpProxyRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_http_proxy': request.targetHttpProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a TargetHttpProxy resource in the specified project and region using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetHttpProxy} request.targetHttpProxyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_target_http_proxies.insert.js + * region_tag:compute_v1_generated_RegionTargetHttpProxies_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionTargetHttpProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionTargetHttpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionTargetHttpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionTargetHttpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionTargetHttpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes the URL map for TargetHttpProxy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetHttpProxy + * Name of the TargetHttpProxy to set a URL map for. + * @param {google.cloud.compute.v1.UrlMapReference} request.urlMapReferenceResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_target_http_proxies.set_url_map.js + * region_tag:compute_v1_generated_RegionTargetHttpProxies_SetUrlMap_async + */ + setUrlMap( + request?: protos.google.cloud.compute.v1.ISetUrlMapRegionTargetHttpProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setUrlMap( + request: protos.google.cloud.compute.v1.ISetUrlMapRegionTargetHttpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUrlMapRegionTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + setUrlMap( + request: protos.google.cloud.compute.v1.ISetUrlMapRegionTargetHttpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUrlMapRegionTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + setUrlMap( + request?: protos.google.cloud.compute.v1.ISetUrlMapRegionTargetHttpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUrlMapRegionTargetHttpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUrlMapRegionTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_http_proxy': request.targetHttpProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.setUrlMap(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves the list of TargetHttpProxy resources available to the specified project in the specified region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetHttpProxy | TargetHttpProxy}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionTargetHttpProxiesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetHttpProxy[], + protos.google.cloud.compute.v1.IListRegionTargetHttpProxiesRequest|null, + protos.google.cloud.compute.v1.ITargetHttpProxyList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionTargetHttpProxiesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionTargetHttpProxiesRequest, + protos.google.cloud.compute.v1.ITargetHttpProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetHttpProxy>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionTargetHttpProxiesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionTargetHttpProxiesRequest, + protos.google.cloud.compute.v1.ITargetHttpProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetHttpProxy>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionTargetHttpProxiesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionTargetHttpProxiesRequest, + protos.google.cloud.compute.v1.ITargetHttpProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetHttpProxy>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionTargetHttpProxiesRequest, + protos.google.cloud.compute.v1.ITargetHttpProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetHttpProxy>): + Promise<[ + protos.google.cloud.compute.v1.ITargetHttpProxy[], + protos.google.cloud.compute.v1.IListRegionTargetHttpProxiesRequest|null, + protos.google.cloud.compute.v1.ITargetHttpProxyList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetHttpProxy | TargetHttpProxy} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionTargetHttpProxiesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.TargetHttpProxy | TargetHttpProxy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_target_http_proxies.list.js + * region_tag:compute_v1_generated_RegionTargetHttpProxies_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionTargetHttpProxiesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionTargetHttpProxiesStub && !this._terminated) { + return this.regionTargetHttpProxiesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_http_proxies_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_http_proxies_client_config.json new file mode 100644 index 00000000000..354217530b1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_http_proxies_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionTargetHttpProxies": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetUrlMap": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_http_proxies_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_http_proxies_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_http_proxies_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_https_proxies_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_https_proxies_client.ts new file mode 100644 index 00000000000..7bdc1496db8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_https_proxies_client.ts @@ -0,0 +1,1054 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_target_https_proxies_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_target_https_proxies_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionTargetHttpsProxies API. + * @class + * @memberof v1 + */ +export class RegionTargetHttpsProxiesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionTargetHttpsProxiesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionTargetHttpsProxiesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionTargetHttpsProxiesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionTargetHttpsProxiesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionTargetHttpsProxies', 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.regionTargetHttpsProxiesStub) { + return this.regionTargetHttpsProxiesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionTargetHttpsProxies. + this.regionTargetHttpsProxiesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionTargetHttpsProxies') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionTargetHttpsProxies, + 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 regionTargetHttpsProxiesStubMethods = + ['delete', 'get', 'insert', 'list', 'patch', 'setSslCertificates', 'setUrlMap']; + for (const methodName of regionTargetHttpsProxiesStubMethods) { + const callPromise = this.regionTargetHttpsProxiesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionTargetHttpsProxiesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified TargetHttpsProxy resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetHttpsProxy + * Name of the TargetHttpsProxy resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_target_https_proxies.delete.js + * region_tag:compute_v1_generated_RegionTargetHttpsProxies_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionTargetHttpsProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionTargetHttpsProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionTargetHttpsProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionTargetHttpsProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_https_proxy': request.targetHttpsProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified TargetHttpsProxy resource in the specified region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.targetHttpsProxy + * Name of the TargetHttpsProxy resource to return. + * @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.compute.v1.TargetHttpsProxy | TargetHttpsProxy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_target_https_proxies.get.js + * region_tag:compute_v1_generated_RegionTargetHttpsProxies_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionTargetHttpsProxyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetHttpsProxy, + protos.google.cloud.compute.v1.IGetRegionTargetHttpsProxyRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionTargetHttpsProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITargetHttpsProxy, + protos.google.cloud.compute.v1.IGetRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionTargetHttpsProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITargetHttpsProxy, + protos.google.cloud.compute.v1.IGetRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionTargetHttpsProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITargetHttpsProxy, + protos.google.cloud.compute.v1.IGetRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITargetHttpsProxy, + protos.google.cloud.compute.v1.IGetRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITargetHttpsProxy, + protos.google.cloud.compute.v1.IGetRegionTargetHttpsProxyRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_https_proxy': request.targetHttpsProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a TargetHttpsProxy resource in the specified project and region using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetHttpsProxy} request.targetHttpsProxyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_target_https_proxies.insert.js + * region_tag:compute_v1_generated_RegionTargetHttpsProxies_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionTargetHttpsProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionTargetHttpsProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionTargetHttpsProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionTargetHttpsProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified regional TargetHttpsProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetHttpsProxy + * Name of the TargetHttpsProxy resource to patch. + * @param {google.cloud.compute.v1.TargetHttpsProxy} request.targetHttpsProxyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_target_https_proxies.patch.js + * region_tag:compute_v1_generated_RegionTargetHttpsProxies_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionTargetHttpsProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionTargetHttpsProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionTargetHttpsProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionTargetHttpsProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_https_proxy': request.targetHttpsProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Replaces SslCertificates for TargetHttpsProxy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {google.cloud.compute.v1.RegionTargetHttpsProxiesSetSslCertificatesRequest} request.regionTargetHttpsProxiesSetSslCertificatesRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetHttpsProxy + * Name of the TargetHttpsProxy resource to set an SslCertificates resource for. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_target_https_proxies.set_ssl_certificates.js + * region_tag:compute_v1_generated_RegionTargetHttpsProxies_SetSslCertificates_async + */ + setSslCertificates( + request?: protos.google.cloud.compute.v1.ISetSslCertificatesRegionTargetHttpsProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setSslCertificates( + request: protos.google.cloud.compute.v1.ISetSslCertificatesRegionTargetHttpsProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslCertificatesRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + setSslCertificates( + request: protos.google.cloud.compute.v1.ISetSslCertificatesRegionTargetHttpsProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslCertificatesRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + setSslCertificates( + request?: protos.google.cloud.compute.v1.ISetSslCertificatesRegionTargetHttpsProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslCertificatesRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslCertificatesRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_https_proxy': request.targetHttpsProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.setSslCertificates(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes the URL map for TargetHttpsProxy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetHttpsProxy + * Name of the TargetHttpsProxy to set a URL map for. + * @param {google.cloud.compute.v1.UrlMapReference} request.urlMapReferenceResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_target_https_proxies.set_url_map.js + * region_tag:compute_v1_generated_RegionTargetHttpsProxies_SetUrlMap_async + */ + setUrlMap( + request?: protos.google.cloud.compute.v1.ISetUrlMapRegionTargetHttpsProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setUrlMap( + request: protos.google.cloud.compute.v1.ISetUrlMapRegionTargetHttpsProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUrlMapRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + setUrlMap( + request: protos.google.cloud.compute.v1.ISetUrlMapRegionTargetHttpsProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUrlMapRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + setUrlMap( + request?: protos.google.cloud.compute.v1.ISetUrlMapRegionTargetHttpsProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUrlMapRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUrlMapRegionTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_https_proxy': request.targetHttpsProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.setUrlMap(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves the list of TargetHttpsProxy resources available to the specified project in the specified region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetHttpsProxy | TargetHttpsProxy}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionTargetHttpsProxiesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetHttpsProxy[], + protos.google.cloud.compute.v1.IListRegionTargetHttpsProxiesRequest|null, + protos.google.cloud.compute.v1.ITargetHttpsProxyList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionTargetHttpsProxiesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionTargetHttpsProxiesRequest, + protos.google.cloud.compute.v1.ITargetHttpsProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetHttpsProxy>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionTargetHttpsProxiesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionTargetHttpsProxiesRequest, + protos.google.cloud.compute.v1.ITargetHttpsProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetHttpsProxy>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionTargetHttpsProxiesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionTargetHttpsProxiesRequest, + protos.google.cloud.compute.v1.ITargetHttpsProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetHttpsProxy>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionTargetHttpsProxiesRequest, + protos.google.cloud.compute.v1.ITargetHttpsProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetHttpsProxy>): + Promise<[ + protos.google.cloud.compute.v1.ITargetHttpsProxy[], + protos.google.cloud.compute.v1.IListRegionTargetHttpsProxiesRequest|null, + protos.google.cloud.compute.v1.ITargetHttpsProxyList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetHttpsProxy | TargetHttpsProxy} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionTargetHttpsProxiesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.TargetHttpsProxy | TargetHttpsProxy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_target_https_proxies.list.js + * region_tag:compute_v1_generated_RegionTargetHttpsProxies_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionTargetHttpsProxiesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionTargetHttpsProxiesStub && !this._terminated) { + return this.regionTargetHttpsProxiesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_https_proxies_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_https_proxies_client_config.json new file mode 100644 index 00000000000..dc65fded77d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_https_proxies_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionTargetHttpsProxies": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetSslCertificates": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetUrlMap": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_https_proxies_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_https_proxies_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_https_proxies_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_tcp_proxies_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_tcp_proxies_client.ts new file mode 100644 index 00000000000..3693e8fb2d9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_tcp_proxies_client.ts @@ -0,0 +1,775 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_target_tcp_proxies_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_target_tcp_proxies_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionTargetTcpProxies API. + * @class + * @memberof v1 + */ +export class RegionTargetTcpProxiesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionTargetTcpProxiesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionTargetTcpProxiesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionTargetTcpProxiesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionTargetTcpProxiesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionTargetTcpProxies', 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.regionTargetTcpProxiesStub) { + return this.regionTargetTcpProxiesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionTargetTcpProxies. + this.regionTargetTcpProxiesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionTargetTcpProxies') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionTargetTcpProxies, + 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 regionTargetTcpProxiesStubMethods = + ['delete', 'get', 'insert', 'list']; + for (const methodName of regionTargetTcpProxiesStubMethods) { + const callPromise = this.regionTargetTcpProxiesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionTargetTcpProxiesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified TargetTcpProxy resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetTcpProxy + * Name of the TargetTcpProxy resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_target_tcp_proxies.delete.js + * region_tag:compute_v1_generated_RegionTargetTcpProxies_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionTargetTcpProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionTargetTcpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionTargetTcpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionTargetTcpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionTargetTcpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_tcp_proxy': request.targetTcpProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified TargetTcpProxy resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.targetTcpProxy + * Name of the TargetTcpProxy resource to return. + * @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.compute.v1.TargetTcpProxy | TargetTcpProxy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_target_tcp_proxies.get.js + * region_tag:compute_v1_generated_RegionTargetTcpProxies_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionTargetTcpProxyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetTcpProxy, + protos.google.cloud.compute.v1.IGetRegionTargetTcpProxyRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionTargetTcpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITargetTcpProxy, + protos.google.cloud.compute.v1.IGetRegionTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionTargetTcpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITargetTcpProxy, + protos.google.cloud.compute.v1.IGetRegionTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionTargetTcpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITargetTcpProxy, + protos.google.cloud.compute.v1.IGetRegionTargetTcpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITargetTcpProxy, + protos.google.cloud.compute.v1.IGetRegionTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITargetTcpProxy, + protos.google.cloud.compute.v1.IGetRegionTargetTcpProxyRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_tcp_proxy': request.targetTcpProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a TargetTcpProxy resource in the specified project and region using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetTcpProxy} request.targetTcpProxyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_target_tcp_proxies.insert.js + * region_tag:compute_v1_generated_RegionTargetTcpProxies_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionTargetTcpProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionTargetTcpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionTargetTcpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionTargetTcpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionTargetTcpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves a list of TargetTcpProxy resources available to the specified project in a given region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetTcpProxy | TargetTcpProxy}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionTargetTcpProxiesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetTcpProxy[], + protos.google.cloud.compute.v1.IListRegionTargetTcpProxiesRequest|null, + protos.google.cloud.compute.v1.ITargetTcpProxyList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionTargetTcpProxiesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionTargetTcpProxiesRequest, + protos.google.cloud.compute.v1.ITargetTcpProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetTcpProxy>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionTargetTcpProxiesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionTargetTcpProxiesRequest, + protos.google.cloud.compute.v1.ITargetTcpProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetTcpProxy>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionTargetTcpProxiesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionTargetTcpProxiesRequest, + protos.google.cloud.compute.v1.ITargetTcpProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetTcpProxy>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionTargetTcpProxiesRequest, + protos.google.cloud.compute.v1.ITargetTcpProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetTcpProxy>): + Promise<[ + protos.google.cloud.compute.v1.ITargetTcpProxy[], + protos.google.cloud.compute.v1.IListRegionTargetTcpProxiesRequest|null, + protos.google.cloud.compute.v1.ITargetTcpProxyList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetTcpProxy | TargetTcpProxy} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionTargetTcpProxiesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.TargetTcpProxy | TargetTcpProxy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_target_tcp_proxies.list.js + * region_tag:compute_v1_generated_RegionTargetTcpProxies_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionTargetTcpProxiesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionTargetTcpProxiesStub && !this._terminated) { + return this.regionTargetTcpProxiesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_tcp_proxies_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_tcp_proxies_client_config.json new file mode 100644 index 00000000000..71a3421081b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_tcp_proxies_client_config.json @@ -0,0 +1,42 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionTargetTcpProxies": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_tcp_proxies_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_tcp_proxies_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_target_tcp_proxies_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_url_maps_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_url_maps_client.ts new file mode 100644 index 00000000000..ec959d7e6ea --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_url_maps_client.ts @@ -0,0 +1,1040 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/region_url_maps_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_url_maps_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionUrlMaps API. + * @class + * @memberof v1 + */ +export class RegionUrlMapsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionUrlMapsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionUrlMapsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionUrlMapsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionUrlMapsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.RegionUrlMaps', 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.regionUrlMapsStub) { + return this.regionUrlMapsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.RegionUrlMaps. + this.regionUrlMapsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.RegionUrlMaps') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.RegionUrlMaps, + 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 regionUrlMapsStubMethods = + ['delete', 'get', 'insert', 'list', 'patch', 'update', 'validate']; + for (const methodName of regionUrlMapsStubMethods) { + const callPromise = this.regionUrlMapsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionUrlMapsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified UrlMap resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * begin_interface: MixerMutationRequestBuilder Request ID to support idempotency. + * @param {string} request.urlMap + * Name of the UrlMap resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_url_maps.delete.js + * region_tag:compute_v1_generated_RegionUrlMaps_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionUrlMapRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionUrlMapRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionUrlMapRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRegionUrlMapRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionUrlMapRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRegionUrlMapRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionUrlMapRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRegionUrlMapRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'url_map': request.urlMap ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified UrlMap resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.urlMap + * Name of the UrlMap resource to return. + * @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.compute.v1.UrlMap | UrlMap}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_url_maps.get.js + * region_tag:compute_v1_generated_RegionUrlMaps_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionUrlMapRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IUrlMap, + protos.google.cloud.compute.v1.IGetRegionUrlMapRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionUrlMapRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IUrlMap, + protos.google.cloud.compute.v1.IGetRegionUrlMapRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionUrlMapRequest, + callback: Callback< + protos.google.cloud.compute.v1.IUrlMap, + protos.google.cloud.compute.v1.IGetRegionUrlMapRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionUrlMapRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IUrlMap, + protos.google.cloud.compute.v1.IGetRegionUrlMapRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IUrlMap, + protos.google.cloud.compute.v1.IGetRegionUrlMapRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IUrlMap, + protos.google.cloud.compute.v1.IGetRegionUrlMapRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'url_map': request.urlMap ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a UrlMap resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * begin_interface: MixerMutationRequestBuilder Request ID to support idempotency. + * @param {google.cloud.compute.v1.UrlMap} request.urlMapResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_url_maps.insert.js + * region_tag:compute_v1_generated_RegionUrlMaps_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionUrlMapRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionUrlMapRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionUrlMapRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRegionUrlMapRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionUrlMapRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRegionUrlMapRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionUrlMapRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRegionUrlMapRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified UrlMap resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * begin_interface: MixerMutationRequestBuilder Request ID to support idempotency. + * @param {string} request.urlMap + * Name of the UrlMap resource to patch. + * @param {google.cloud.compute.v1.UrlMap} request.urlMapResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_url_maps.patch.js + * region_tag:compute_v1_generated_RegionUrlMaps_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionUrlMapRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionUrlMapRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionUrlMapRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchRegionUrlMapRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionUrlMapRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchRegionUrlMapRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionUrlMapRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRegionUrlMapRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'url_map': request.urlMap ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified UrlMap resource with the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * begin_interface: MixerMutationRequestBuilder Request ID to support idempotency. + * @param {string} request.urlMap + * Name of the UrlMap resource to update. + * @param {google.cloud.compute.v1.UrlMap} request.urlMapResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/region_url_maps.update.js + * region_tag:compute_v1_generated_RegionUrlMaps_Update_async + */ + update( + request?: protos.google.cloud.compute.v1.IUpdateRegionUrlMapRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + update( + request: protos.google.cloud.compute.v1.IUpdateRegionUrlMapRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionUrlMapRequest|null|undefined, + {}|null|undefined>): void; + update( + request: protos.google.cloud.compute.v1.IUpdateRegionUrlMapRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionUrlMapRequest|null|undefined, + {}|null|undefined>): void; + update( + request?: protos.google.cloud.compute.v1.IUpdateRegionUrlMapRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionUrlMapRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRegionUrlMapRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'url_map': request.urlMap ?? '', + }); + this.initialize(); + return this.innerApiCalls.update(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling this method does NOT create the UrlMap. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {google.cloud.compute.v1.RegionUrlMapsValidateRequest} request.regionUrlMapsValidateRequestResource + * The body resource for this request + * @param {string} request.urlMap + * Name of the UrlMap resource to be validated as. + * @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.compute.v1.UrlMapsValidateResponse | UrlMapsValidateResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/region_url_maps.validate.js + * region_tag:compute_v1_generated_RegionUrlMaps_Validate_async + */ + validate( + request?: protos.google.cloud.compute.v1.IValidateRegionUrlMapRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IUrlMapsValidateResponse, + protos.google.cloud.compute.v1.IValidateRegionUrlMapRequest|undefined, {}|undefined + ]>; + validate( + request: protos.google.cloud.compute.v1.IValidateRegionUrlMapRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IUrlMapsValidateResponse, + protos.google.cloud.compute.v1.IValidateRegionUrlMapRequest|null|undefined, + {}|null|undefined>): void; + validate( + request: protos.google.cloud.compute.v1.IValidateRegionUrlMapRequest, + callback: Callback< + protos.google.cloud.compute.v1.IUrlMapsValidateResponse, + protos.google.cloud.compute.v1.IValidateRegionUrlMapRequest|null|undefined, + {}|null|undefined>): void; + validate( + request?: protos.google.cloud.compute.v1.IValidateRegionUrlMapRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IUrlMapsValidateResponse, + protos.google.cloud.compute.v1.IValidateRegionUrlMapRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IUrlMapsValidateResponse, + protos.google.cloud.compute.v1.IValidateRegionUrlMapRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IUrlMapsValidateResponse, + protos.google.cloud.compute.v1.IValidateRegionUrlMapRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'url_map': request.urlMap ?? '', + }); + this.initialize(); + return this.innerApiCalls.validate(request, options, callback); + } + + /** + * Retrieves the list of UrlMap resources available to the specified project in the specified region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.UrlMap | UrlMap}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionUrlMapsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IUrlMap[], + protos.google.cloud.compute.v1.IListRegionUrlMapsRequest|null, + protos.google.cloud.compute.v1.IUrlMapList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionUrlMapsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionUrlMapsRequest, + protos.google.cloud.compute.v1.IUrlMapList|null|undefined, + protos.google.cloud.compute.v1.IUrlMap>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionUrlMapsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionUrlMapsRequest, + protos.google.cloud.compute.v1.IUrlMapList|null|undefined, + protos.google.cloud.compute.v1.IUrlMap>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionUrlMapsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionUrlMapsRequest, + protos.google.cloud.compute.v1.IUrlMapList|null|undefined, + protos.google.cloud.compute.v1.IUrlMap>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionUrlMapsRequest, + protos.google.cloud.compute.v1.IUrlMapList|null|undefined, + protos.google.cloud.compute.v1.IUrlMap>): + Promise<[ + protos.google.cloud.compute.v1.IUrlMap[], + protos.google.cloud.compute.v1.IListRegionUrlMapsRequest|null, + protos.google.cloud.compute.v1.IUrlMapList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.UrlMap | UrlMap} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionUrlMapsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.UrlMap | UrlMap}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/region_url_maps.list.js + * region_tag:compute_v1_generated_RegionUrlMaps_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionUrlMapsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionUrlMapsStub && !this._terminated) { + return this.regionUrlMapsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_url_maps_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_url_maps_client_config.json new file mode 100644 index 00000000000..d6cda9382d8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_url_maps_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.compute.v1.RegionUrlMaps": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Update": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Validate": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/region_url_maps_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_url_maps_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/region_url_maps_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/regions_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/regions_client.ts new file mode 100644 index 00000000000..e50747e4fbd --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/regions_client.ts @@ -0,0 +1,583 @@ +// Copyright 2023 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/regions_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './regions_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Regions API. + * @class + * @memberof v1 + */ +export class RegionsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.Regions', 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.regionsStub) { + return this.regionsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.Regions. + this.regionsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Regions') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.Regions, + 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 regionsStubMethods = + ['get', 'list']; + for (const methodName of regionsStubMethods) { + const callPromise = this.regionsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute.readonly', + 'https://www.googleapis.com/auth/compute', + '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 -- + // ------------------- +/** + * Returns the specified Region resource. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region resource to return. + * @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.compute.v1.Region | Region}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/regions.get.js + * region_tag:compute_v1_generated_Regions_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRegionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IRegion, + protos.google.cloud.compute.v1.IGetRegionRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRegionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IRegion, + protos.google.cloud.compute.v1.IGetRegionRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRegionRequest, + callback: Callback< + protos.google.cloud.compute.v1.IRegion, + protos.google.cloud.compute.v1.IGetRegionRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRegionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IRegion, + protos.google.cloud.compute.v1.IGetRegionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IRegion, + protos.google.cloud.compute.v1.IGetRegionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IRegion, + protos.google.cloud.compute.v1.IGetRegionRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } + + /** + * Retrieves the list of region resources available to the specified project. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `items.quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Region | Region}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRegionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IRegion[], + protos.google.cloud.compute.v1.IListRegionsRequest|null, + protos.google.cloud.compute.v1.IRegionList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRegionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionsRequest, + protos.google.cloud.compute.v1.IRegionList|null|undefined, + protos.google.cloud.compute.v1.IRegion>): void; + list( + request: protos.google.cloud.compute.v1.IListRegionsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionsRequest, + protos.google.cloud.compute.v1.IRegionList|null|undefined, + protos.google.cloud.compute.v1.IRegion>): void; + list( + request?: protos.google.cloud.compute.v1.IListRegionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRegionsRequest, + protos.google.cloud.compute.v1.IRegionList|null|undefined, + protos.google.cloud.compute.v1.IRegion>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRegionsRequest, + protos.google.cloud.compute.v1.IRegionList|null|undefined, + protos.google.cloud.compute.v1.IRegion>): + Promise<[ + protos.google.cloud.compute.v1.IRegion[], + protos.google.cloud.compute.v1.IListRegionsRequest|null, + protos.google.cloud.compute.v1.IRegionList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Region | Region} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRegionsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Region | Region}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/regions.list.js + * region_tag:compute_v1_generated_Regions_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRegionsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.regionsStub && !this._terminated) { + return this.regionsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/regions_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/regions_client_config.json new file mode 100644 index 00000000000..0c86e316bf0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/regions_client_config.json @@ -0,0 +1,34 @@ +{ + "interfaces": { + "google.cloud.compute.v1.Regions": { + "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": { + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/regions_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/regions_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/regions_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/reservations_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/reservations_client.ts new file mode 100644 index 00000000000..b0e6696223c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/reservations_client.ts @@ -0,0 +1,1259 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/reservations_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './reservations_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Reservations API. + * @class + * @memberof v1 + */ +export class ReservationsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + reservationsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ReservationsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ReservationsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ReservationsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.Reservations', 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.reservationsStub) { + return this.reservationsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.Reservations. + this.reservationsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Reservations') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.Reservations, + 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 reservationsStubMethods = + ['aggregatedList', 'delete', 'get', 'getIamPolicy', 'insert', 'list', 'resize', 'setIamPolicy', 'testIamPermissions', 'update']; + for (const methodName of reservationsStubMethods) { + const callPromise = this.reservationsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.reservationsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified reservation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.reservation + * Name of the reservation to delete. + * @param {string} request.zone + * Name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/reservations.delete.js + * region_tag:compute_v1_generated_Reservations_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteReservationRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteReservationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteReservationRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteReservationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteReservationRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteReservationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteReservationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteReservationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'reservation': request.reservation ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Retrieves information about the specified reservation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.reservation + * Name of the reservation to retrieve. + * @param {string} request.zone + * Name of the zone for this request. + * @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.compute.v1.Reservation | Reservation}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/reservations.get.js + * region_tag:compute_v1_generated_Reservations_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetReservationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IReservation, + protos.google.cloud.compute.v1.IGetReservationRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetReservationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IReservation, + protos.google.cloud.compute.v1.IGetReservationRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetReservationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IReservation, + protos.google.cloud.compute.v1.IGetReservationRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetReservationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IReservation, + protos.google.cloud.compute.v1.IGetReservationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IReservation, + protos.google.cloud.compute.v1.IGetReservationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IReservation, + protos.google.cloud.compute.v1.IGetReservationRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'reservation': request.reservation ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/reservations.get_iam_policy.js + * region_tag:compute_v1_generated_Reservations_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyReservationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyReservationRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyReservationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyReservationRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyReservationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyReservationRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyReservationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyReservationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyReservationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyReservationRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Creates a new reservation. For more information, read Reserving zonal resources. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.Reservation} request.reservationResource + * The body resource for this request + * @param {string} request.zone + * Name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/reservations.insert.js + * region_tag:compute_v1_generated_Reservations_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertReservationRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertReservationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertReservationRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertReservationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertReservationRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertReservationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertReservationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertReservationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Resizes the reservation (applicable to standalone reservations only). For more information, read Modifying reservations. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.reservation + * Name of the reservation to update. + * @param {google.cloud.compute.v1.ReservationsResizeRequest} request.reservationsResizeRequestResource + * The body resource for this request + * @param {string} request.zone + * Name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/reservations.resize.js + * region_tag:compute_v1_generated_Reservations_Resize_async + */ + resize( + request?: protos.google.cloud.compute.v1.IResizeReservationRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + resize( + request: protos.google.cloud.compute.v1.IResizeReservationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeReservationRequest|null|undefined, + {}|null|undefined>): void; + resize( + request: protos.google.cloud.compute.v1.IResizeReservationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeReservationRequest|null|undefined, + {}|null|undefined>): void; + resize( + request?: protos.google.cloud.compute.v1.IResizeReservationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeReservationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IResizeReservationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'reservation': request.reservation ?? '', + }); + this.initialize(); + return this.innerApiCalls.resize(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {string} request.zone + * The name of the zone for this request. + * @param {google.cloud.compute.v1.ZoneSetPolicyRequest} request.zoneSetPolicyRequestResource + * The body resource for this request + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/reservations.set_iam_policy.js + * region_tag:compute_v1_generated_Reservations_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyReservationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyReservationRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyReservationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyReservationRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyReservationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyReservationRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyReservationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyReservationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyReservationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyReservationRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @param {string} request.zone + * The name of the zone for this request. + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/reservations.test_iam_permissions.js + * region_tag:compute_v1_generated_Reservations_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsReservationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsReservationRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsReservationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsReservationRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsReservationRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsReservationRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsReservationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsReservationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsReservationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsReservationRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } +/** + * Update share settings of the reservation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.paths + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.reservation + * Name of the reservation to update. + * @param {google.cloud.compute.v1.Reservation} request.reservationResource + * The body resource for this request + * @param {string} request.updateMask + * Update_mask indicates fields to be updated as part of this request. + * @param {string} request.zone + * Name of the zone for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/reservations.update.js + * region_tag:compute_v1_generated_Reservations_Update_async + */ + update( + request?: protos.google.cloud.compute.v1.IUpdateReservationRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + update( + request: protos.google.cloud.compute.v1.IUpdateReservationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateReservationRequest|null|undefined, + {}|null|undefined>): void; + update( + request: protos.google.cloud.compute.v1.IUpdateReservationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateReservationRequest|null|undefined, + {}|null|undefined>): void; + update( + request?: protos.google.cloud.compute.v1.IUpdateReservationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateReservationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateReservationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'reservation': request.reservation ?? '', + }); + this.initialize(); + return this.innerApiCalls.update(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves an aggregated list of reservations. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.ReservationsScopedList | ReservationsScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/reservations.aggregated_list.js + * region_tag:compute_v1_generated_Reservations_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListReservationsRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IReservationsScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IReservationsScopedList]>; + } + /** + * A list of all the reservations that have been configured for the specified project in specified zone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * Name of the zone for this request. + * @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 google.cloud.compute.v1.Reservation | Reservation}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListReservationsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IReservation[], + protos.google.cloud.compute.v1.IListReservationsRequest|null, + protos.google.cloud.compute.v1.IReservationList + ]>; + list( + request: protos.google.cloud.compute.v1.IListReservationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListReservationsRequest, + protos.google.cloud.compute.v1.IReservationList|null|undefined, + protos.google.cloud.compute.v1.IReservation>): void; + list( + request: protos.google.cloud.compute.v1.IListReservationsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListReservationsRequest, + protos.google.cloud.compute.v1.IReservationList|null|undefined, + protos.google.cloud.compute.v1.IReservation>): void; + list( + request?: protos.google.cloud.compute.v1.IListReservationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListReservationsRequest, + protos.google.cloud.compute.v1.IReservationList|null|undefined, + protos.google.cloud.compute.v1.IReservation>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListReservationsRequest, + protos.google.cloud.compute.v1.IReservationList|null|undefined, + protos.google.cloud.compute.v1.IReservation>): + Promise<[ + protos.google.cloud.compute.v1.IReservation[], + protos.google.cloud.compute.v1.IListReservationsRequest|null, + protos.google.cloud.compute.v1.IReservationList + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * Name of the zone for this request. + * @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 google.cloud.compute.v1.Reservation | Reservation} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListReservationsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * Name of the zone for this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Reservation | Reservation}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/reservations.list.js + * region_tag:compute_v1_generated_Reservations_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListReservationsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.reservationsStub && !this._terminated) { + return this.reservationsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/reservations_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/reservations_client_config.json new file mode 100644 index 00000000000..22cce787cd2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/reservations_client_config.json @@ -0,0 +1,66 @@ +{ + "interfaces": { + "google.cloud.compute.v1.Reservations": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Resize": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Update": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/reservations_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/reservations_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/reservations_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/resource_policies_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/resource_policies_client.ts new file mode 100644 index 00000000000..b5f341cd898 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/resource_policies_client.ts @@ -0,0 +1,1070 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/resource_policies_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './resource_policies_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The ResourcePolicies API. + * @class + * @memberof v1 + */ +export class ResourcePoliciesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + resourcePoliciesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ResourcePoliciesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ResourcePoliciesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ResourcePoliciesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.ResourcePolicies', 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.resourcePoliciesStub) { + return this.resourcePoliciesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.ResourcePolicies. + this.resourcePoliciesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.ResourcePolicies') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.ResourcePolicies, + 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 resourcePoliciesStubMethods = + ['aggregatedList', 'delete', 'get', 'getIamPolicy', 'insert', 'list', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of resourcePoliciesStubMethods) { + const callPromise = this.resourcePoliciesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.resourcePoliciesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified resource policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.resourcePolicy + * Name of the resource policy to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/resource_policies.delete.js + * region_tag:compute_v1_generated_ResourcePolicies_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteResourcePolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteResourcePolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteResourcePolicyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteResourcePolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteResourcePolicyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteResourcePolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteResourcePolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteResourcePolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource_policy': request.resourcePolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Retrieves all information of the specified resource policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.resourcePolicy + * Name of the resource policy to retrieve. + * @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.compute.v1.ResourcePolicy | ResourcePolicy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/resource_policies.get.js + * region_tag:compute_v1_generated_ResourcePolicies_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetResourcePolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IResourcePolicy, + protos.google.cloud.compute.v1.IGetResourcePolicyRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetResourcePolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IResourcePolicy, + protos.google.cloud.compute.v1.IGetResourcePolicyRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetResourcePolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IResourcePolicy, + protos.google.cloud.compute.v1.IGetResourcePolicyRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetResourcePolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IResourcePolicy, + protos.google.cloud.compute.v1.IGetResourcePolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IResourcePolicy, + protos.google.cloud.compute.v1.IGetResourcePolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IResourcePolicy, + protos.google.cloud.compute.v1.IGetResourcePolicyRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource_policy': request.resourcePolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/resource_policies.get_iam_policy.js + * region_tag:compute_v1_generated_ResourcePolicies_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyResourcePolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyResourcePolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyResourcePolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyResourcePolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyResourcePolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyResourcePolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyResourcePolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyResourcePolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyResourcePolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyResourcePolicyRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Creates a new resource policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.ResourcePolicy} request.resourcePolicyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/resource_policies.insert.js + * region_tag:compute_v1_generated_ResourcePolicies_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertResourcePolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertResourcePolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertResourcePolicyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertResourcePolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertResourcePolicyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertResourcePolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertResourcePolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertResourcePolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {google.cloud.compute.v1.RegionSetPolicyRequest} request.regionSetPolicyRequestResource + * The body resource for this request + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/resource_policies.set_iam_policy.js + * region_tag:compute_v1_generated_ResourcePolicies_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyResourcePolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyResourcePolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyResourcePolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyResourcePolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyResourcePolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyResourcePolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyResourcePolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyResourcePolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyResourcePolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyResourcePolicyRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/resource_policies.test_iam_permissions.js + * region_tag:compute_v1_generated_ResourcePolicies_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsResourcePolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsResourcePolicyRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsResourcePolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsResourcePolicyRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsResourcePolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsResourcePolicyRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsResourcePolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsResourcePolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsResourcePolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsResourcePolicyRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + +/** + * Retrieves an aggregated list of resource policies. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.ResourcePoliciesScopedList | ResourcePoliciesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/resource_policies.aggregated_list.js + * region_tag:compute_v1_generated_ResourcePolicies_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListResourcePoliciesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IResourcePoliciesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IResourcePoliciesScopedList]>; + } + /** + * A list all the resource policies that have been configured for the specified project in specified region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.ResourcePolicy | ResourcePolicy}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListResourcePoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IResourcePolicy[], + protos.google.cloud.compute.v1.IListResourcePoliciesRequest|null, + protos.google.cloud.compute.v1.IResourcePolicyList + ]>; + list( + request: protos.google.cloud.compute.v1.IListResourcePoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListResourcePoliciesRequest, + protos.google.cloud.compute.v1.IResourcePolicyList|null|undefined, + protos.google.cloud.compute.v1.IResourcePolicy>): void; + list( + request: protos.google.cloud.compute.v1.IListResourcePoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListResourcePoliciesRequest, + protos.google.cloud.compute.v1.IResourcePolicyList|null|undefined, + protos.google.cloud.compute.v1.IResourcePolicy>): void; + list( + request?: protos.google.cloud.compute.v1.IListResourcePoliciesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListResourcePoliciesRequest, + protos.google.cloud.compute.v1.IResourcePolicyList|null|undefined, + protos.google.cloud.compute.v1.IResourcePolicy>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListResourcePoliciesRequest, + protos.google.cloud.compute.v1.IResourcePolicyList|null|undefined, + protos.google.cloud.compute.v1.IResourcePolicy>): + Promise<[ + protos.google.cloud.compute.v1.IResourcePolicy[], + protos.google.cloud.compute.v1.IListResourcePoliciesRequest|null, + protos.google.cloud.compute.v1.IResourcePolicyList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.ResourcePolicy | ResourcePolicy} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListResourcePoliciesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.ResourcePolicy | ResourcePolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/resource_policies.list.js + * region_tag:compute_v1_generated_ResourcePolicies_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListResourcePoliciesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.resourcePoliciesStub && !this._terminated) { + return this.resourcePoliciesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/resource_policies_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/resource_policies_client_config.json new file mode 100644 index 00000000000..5e0e41c3d2a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/resource_policies_client_config.json @@ -0,0 +1,58 @@ +{ + "interfaces": { + "google.cloud.compute.v1.ResourcePolicies": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/resource_policies_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/resource_policies_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/resource_policies_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/routers_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/routers_client.ts new file mode 100644 index 00000000000..426aac75347 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/routers_client.ts @@ -0,0 +1,1386 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/routers_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './routers_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Routers API. + * @class + * @memberof v1 + */ +export class RoutersClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + routersStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RoutersClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RoutersClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RoutersClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + getNatMappingInfo: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'result'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.Routers', 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.routersStub) { + return this.routersStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.Routers. + this.routersStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Routers') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.Routers, + 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 routersStubMethods = + ['aggregatedList', 'delete', 'get', 'getNatMappingInfo', 'getRouterStatus', 'insert', 'list', 'patch', 'preview', 'update']; + for (const methodName of routersStubMethods) { + const callPromise = this.routersStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.routersStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified Router resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.router + * Name of the Router resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/routers.delete.js + * region_tag:compute_v1_generated_Routers_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRouterRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRouterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRouterRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRouterRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRouterRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRouterRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRouterRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRouterRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'router': request.router ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified Router resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.router + * Name of the Router resource to return. + * @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.compute.v1.Router | Router}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/routers.get.js + * region_tag:compute_v1_generated_Routers_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRouterRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IRouter, + protos.google.cloud.compute.v1.IGetRouterRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRouterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IRouter, + protos.google.cloud.compute.v1.IGetRouterRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRouterRequest, + callback: Callback< + protos.google.cloud.compute.v1.IRouter, + protos.google.cloud.compute.v1.IGetRouterRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRouterRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IRouter, + protos.google.cloud.compute.v1.IGetRouterRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IRouter, + protos.google.cloud.compute.v1.IGetRouterRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IRouter, + protos.google.cloud.compute.v1.IGetRouterRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'router': request.router ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Retrieves runtime information of the specified router. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.router + * Name of the Router resource to query. + * @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.compute.v1.RouterStatusResponse | RouterStatusResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/routers.get_router_status.js + * region_tag:compute_v1_generated_Routers_GetRouterStatus_async + */ + getRouterStatus( + request?: protos.google.cloud.compute.v1.IGetRouterStatusRouterRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IRouterStatusResponse, + protos.google.cloud.compute.v1.IGetRouterStatusRouterRequest|undefined, {}|undefined + ]>; + getRouterStatus( + request: protos.google.cloud.compute.v1.IGetRouterStatusRouterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IRouterStatusResponse, + protos.google.cloud.compute.v1.IGetRouterStatusRouterRequest|null|undefined, + {}|null|undefined>): void; + getRouterStatus( + request: protos.google.cloud.compute.v1.IGetRouterStatusRouterRequest, + callback: Callback< + protos.google.cloud.compute.v1.IRouterStatusResponse, + protos.google.cloud.compute.v1.IGetRouterStatusRouterRequest|null|undefined, + {}|null|undefined>): void; + getRouterStatus( + request?: protos.google.cloud.compute.v1.IGetRouterStatusRouterRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IRouterStatusResponse, + protos.google.cloud.compute.v1.IGetRouterStatusRouterRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IRouterStatusResponse, + protos.google.cloud.compute.v1.IGetRouterStatusRouterRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IRouterStatusResponse, + protos.google.cloud.compute.v1.IGetRouterStatusRouterRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'router': request.router ?? '', + }); + this.initialize(); + return this.innerApiCalls.getRouterStatus(request, options, callback); + } +/** + * Creates a Router resource in the specified project and region using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.Router} request.routerResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/routers.insert.js + * region_tag:compute_v1_generated_Routers_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRouterRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRouterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRouterRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRouterRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRouterRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRouterRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRouterRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRouterRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified Router resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.router + * Name of the Router resource to patch. + * @param {google.cloud.compute.v1.Router} request.routerResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/routers.patch.js + * region_tag:compute_v1_generated_Routers_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchRouterRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchRouterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRouterRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchRouterRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRouterRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchRouterRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRouterRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRouterRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'router': request.router ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Preview fields auto-generated during router create and update operations. Calling this method does NOT create or update the router. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.router + * Name of the Router resource to query. + * @param {google.cloud.compute.v1.Router} request.routerResource + * The body resource for this request + * @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.compute.v1.RoutersPreviewResponse | RoutersPreviewResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/routers.preview.js + * region_tag:compute_v1_generated_Routers_Preview_async + */ + preview( + request?: protos.google.cloud.compute.v1.IPreviewRouterRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IRoutersPreviewResponse, + protos.google.cloud.compute.v1.IPreviewRouterRequest|undefined, {}|undefined + ]>; + preview( + request: protos.google.cloud.compute.v1.IPreviewRouterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IRoutersPreviewResponse, + protos.google.cloud.compute.v1.IPreviewRouterRequest|null|undefined, + {}|null|undefined>): void; + preview( + request: protos.google.cloud.compute.v1.IPreviewRouterRequest, + callback: Callback< + protos.google.cloud.compute.v1.IRoutersPreviewResponse, + protos.google.cloud.compute.v1.IPreviewRouterRequest|null|undefined, + {}|null|undefined>): void; + preview( + request?: protos.google.cloud.compute.v1.IPreviewRouterRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IRoutersPreviewResponse, + protos.google.cloud.compute.v1.IPreviewRouterRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IRoutersPreviewResponse, + protos.google.cloud.compute.v1.IPreviewRouterRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IRoutersPreviewResponse, + protos.google.cloud.compute.v1.IPreviewRouterRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'router': request.router ?? '', + }); + this.initialize(); + return this.innerApiCalls.preview(request, options, callback); + } +/** + * Updates the specified Router resource with the data included in the request. This method conforms to PUT semantics, which requests that the state of the target resource be created or replaced with the state defined by the representation enclosed in the request message payload. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.router + * Name of the Router resource to update. + * @param {google.cloud.compute.v1.Router} request.routerResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/routers.update.js + * region_tag:compute_v1_generated_Routers_Update_async + */ + update( + request?: protos.google.cloud.compute.v1.IUpdateRouterRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + update( + request: protos.google.cloud.compute.v1.IUpdateRouterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRouterRequest|null|undefined, + {}|null|undefined>): void; + update( + request: protos.google.cloud.compute.v1.IUpdateRouterRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRouterRequest|null|undefined, + {}|null|undefined>): void; + update( + request?: protos.google.cloud.compute.v1.IUpdateRouterRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRouterRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateRouterRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'router': request.router ?? '', + }); + this.initialize(); + return this.innerApiCalls.update(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves an aggregated list of routers. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.RoutersScopedList | RoutersScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/routers.aggregated_list.js + * region_tag:compute_v1_generated_Routers_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListRoutersRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IRoutersScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IRoutersScopedList]>; + } + /** + * Retrieves runtime Nat mapping information of VM endpoints. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.router + * Name of the Router resource to query for Nat Mapping information of VM endpoints. + * @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 google.cloud.compute.v1.VmEndpointNatMappings | VmEndpointNatMappings}. + * 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 `getNatMappingInfoAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + getNatMappingInfo( + request?: protos.google.cloud.compute.v1.IGetNatMappingInfoRoutersRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IVmEndpointNatMappings[], + protos.google.cloud.compute.v1.IGetNatMappingInfoRoutersRequest|null, + protos.google.cloud.compute.v1.IVmEndpointNatMappingsList + ]>; + getNatMappingInfo( + request: protos.google.cloud.compute.v1.IGetNatMappingInfoRoutersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IGetNatMappingInfoRoutersRequest, + protos.google.cloud.compute.v1.IVmEndpointNatMappingsList|null|undefined, + protos.google.cloud.compute.v1.IVmEndpointNatMappings>): void; + getNatMappingInfo( + request: protos.google.cloud.compute.v1.IGetNatMappingInfoRoutersRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IGetNatMappingInfoRoutersRequest, + protos.google.cloud.compute.v1.IVmEndpointNatMappingsList|null|undefined, + protos.google.cloud.compute.v1.IVmEndpointNatMappings>): void; + getNatMappingInfo( + request?: protos.google.cloud.compute.v1.IGetNatMappingInfoRoutersRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IGetNatMappingInfoRoutersRequest, + protos.google.cloud.compute.v1.IVmEndpointNatMappingsList|null|undefined, + protos.google.cloud.compute.v1.IVmEndpointNatMappings>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IGetNatMappingInfoRoutersRequest, + protos.google.cloud.compute.v1.IVmEndpointNatMappingsList|null|undefined, + protos.google.cloud.compute.v1.IVmEndpointNatMappings>): + Promise<[ + protos.google.cloud.compute.v1.IVmEndpointNatMappings[], + protos.google.cloud.compute.v1.IGetNatMappingInfoRoutersRequest|null, + protos.google.cloud.compute.v1.IVmEndpointNatMappingsList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'router': request.router ?? '', + }); + this.initialize(); + return this.innerApiCalls.getNatMappingInfo(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.router + * Name of the Router resource to query for Nat Mapping information of VM endpoints. + * @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 google.cloud.compute.v1.VmEndpointNatMappings | VmEndpointNatMappings} 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 `getNatMappingInfoAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + getNatMappingInfoStream( + request?: protos.google.cloud.compute.v1.IGetNatMappingInfoRoutersRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'router': request.router ?? '', + }); + const defaultCallSettings = this._defaults['getNatMappingInfo']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.getNatMappingInfo.createStream( + this.innerApiCalls.getNatMappingInfo as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `getNatMappingInfo`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.router + * Name of the Router resource to query for Nat Mapping information of VM endpoints. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.VmEndpointNatMappings | VmEndpointNatMappings}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/routers.get_nat_mapping_info.js + * region_tag:compute_v1_generated_Routers_GetNatMappingInfo_async + */ + getNatMappingInfoAsync( + request?: protos.google.cloud.compute.v1.IGetNatMappingInfoRoutersRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'router': request.router ?? '', + }); + const defaultCallSettings = this._defaults['getNatMappingInfo']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.getNatMappingInfo.asyncIterate( + this.innerApiCalls['getNatMappingInfo'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Retrieves a list of Router resources available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Router | Router}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRoutersRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IRouter[], + protos.google.cloud.compute.v1.IListRoutersRequest|null, + protos.google.cloud.compute.v1.IRouterList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRoutersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRoutersRequest, + protos.google.cloud.compute.v1.IRouterList|null|undefined, + protos.google.cloud.compute.v1.IRouter>): void; + list( + request: protos.google.cloud.compute.v1.IListRoutersRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRoutersRequest, + protos.google.cloud.compute.v1.IRouterList|null|undefined, + protos.google.cloud.compute.v1.IRouter>): void; + list( + request?: protos.google.cloud.compute.v1.IListRoutersRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRoutersRequest, + protos.google.cloud.compute.v1.IRouterList|null|undefined, + protos.google.cloud.compute.v1.IRouter>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRoutersRequest, + protos.google.cloud.compute.v1.IRouterList|null|undefined, + protos.google.cloud.compute.v1.IRouter>): + Promise<[ + protos.google.cloud.compute.v1.IRouter[], + protos.google.cloud.compute.v1.IListRoutersRequest|null, + protos.google.cloud.compute.v1.IRouterList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Router | Router} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRoutersRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Router | Router}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/routers.list.js + * region_tag:compute_v1_generated_Routers_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRoutersRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.routersStub && !this._terminated) { + return this.routersStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/routers_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/routers_client_config.json new file mode 100644 index 00000000000..ad60e60ab58 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/routers_client_config.json @@ -0,0 +1,66 @@ +{ + "interfaces": { + "google.cloud.compute.v1.Routers": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetNatMappingInfo": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetRouterStatus": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Preview": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Update": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/routers_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/routers_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/routers_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/routes_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/routes_client.ts new file mode 100644 index 00000000000..55bfbaf44b1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/routes_client.ts @@ -0,0 +1,757 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/routes_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './routes_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Routes API. + * @class + * @memberof v1 + */ +export class RoutesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + routesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RoutesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RoutesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RoutesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.Routes', 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.routesStub) { + return this.routesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.Routes. + this.routesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Routes') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.Routes, + 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 routesStubMethods = + ['delete', 'get', 'insert', 'list']; + for (const methodName of routesStubMethods) { + const callPromise = this.routesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.routesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified Route resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.route + * Name of the Route resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/routes.delete.js + * region_tag:compute_v1_generated_Routes_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteRouteRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteRouteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRouteRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteRouteRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRouteRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteRouteRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRouteRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteRouteRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'route': request.route ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified Route resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.route + * Name of the Route resource to return. + * @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.compute.v1.Route | Route}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/routes.get.js + * region_tag:compute_v1_generated_Routes_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetRouteRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IRoute, + protos.google.cloud.compute.v1.IGetRouteRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetRouteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IRoute, + protos.google.cloud.compute.v1.IGetRouteRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetRouteRequest, + callback: Callback< + protos.google.cloud.compute.v1.IRoute, + protos.google.cloud.compute.v1.IGetRouteRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetRouteRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IRoute, + protos.google.cloud.compute.v1.IGetRouteRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IRoute, + protos.google.cloud.compute.v1.IGetRouteRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IRoute, + protos.google.cloud.compute.v1.IGetRouteRequest|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({ + 'project': request.project ?? '', + 'route': request.route ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a Route resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.Route} request.routeResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/routes.insert.js + * region_tag:compute_v1_generated_Routes_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertRouteRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertRouteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRouteRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertRouteRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRouteRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertRouteRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRouteRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertRouteRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves the list of Route resources available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Route | Route}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListRoutesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IRoute[], + protos.google.cloud.compute.v1.IListRoutesRequest|null, + protos.google.cloud.compute.v1.IRouteList + ]>; + list( + request: protos.google.cloud.compute.v1.IListRoutesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRoutesRequest, + protos.google.cloud.compute.v1.IRouteList|null|undefined, + protos.google.cloud.compute.v1.IRoute>): void; + list( + request: protos.google.cloud.compute.v1.IListRoutesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListRoutesRequest, + protos.google.cloud.compute.v1.IRouteList|null|undefined, + protos.google.cloud.compute.v1.IRoute>): void; + list( + request?: protos.google.cloud.compute.v1.IListRoutesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListRoutesRequest, + protos.google.cloud.compute.v1.IRouteList|null|undefined, + protos.google.cloud.compute.v1.IRoute>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListRoutesRequest, + protos.google.cloud.compute.v1.IRouteList|null|undefined, + protos.google.cloud.compute.v1.IRoute>): + Promise<[ + protos.google.cloud.compute.v1.IRoute[], + protos.google.cloud.compute.v1.IListRoutesRequest|null, + protos.google.cloud.compute.v1.IRouteList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Route | Route} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListRoutesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Route | Route}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/routes.list.js + * region_tag:compute_v1_generated_Routes_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListRoutesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.routesStub && !this._terminated) { + return this.routesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/routes_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/routes_client_config.json new file mode 100644 index 00000000000..15a5c18059b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/routes_client_config.json @@ -0,0 +1,42 @@ +{ + "interfaces": { + "google.cloud.compute.v1.Routes": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/routes_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/routes_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/routes_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/security_policies_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/security_policies_client.ts new file mode 100644 index 00000000000..763d4911d8c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/security_policies_client.ts @@ -0,0 +1,1422 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/security_policies_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './security_policies_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The SecurityPolicies API. + * @class + * @memberof v1 + */ +export class SecurityPoliciesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + securityPoliciesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SecurityPoliciesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SecurityPoliciesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SecurityPoliciesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.SecurityPolicies', 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.securityPoliciesStub) { + return this.securityPoliciesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.SecurityPolicies. + this.securityPoliciesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.SecurityPolicies') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.SecurityPolicies, + 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 securityPoliciesStubMethods = + ['addRule', 'aggregatedList', 'delete', 'get', 'getRule', 'insert', 'list', 'listPreconfiguredExpressionSets', 'patch', 'patchRule', 'removeRule', 'setLabels']; + for (const methodName of securityPoliciesStubMethods) { + const callPromise = this.securityPoliciesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.securityPoliciesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Inserts a rule into a security policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.securityPolicy + * Name of the security policy to update. + * @param {google.cloud.compute.v1.SecurityPolicyRule} request.securityPolicyRuleResource + * The body resource for this request + * @param {boolean} request.validateOnly + * If true, the request will not be committed. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/security_policies.add_rule.js + * region_tag:compute_v1_generated_SecurityPolicies_AddRule_async + */ + addRule( + request?: protos.google.cloud.compute.v1.IAddRuleSecurityPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addRule( + request: protos.google.cloud.compute.v1.IAddRuleSecurityPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddRuleSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + addRule( + request: protos.google.cloud.compute.v1.IAddRuleSecurityPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddRuleSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + addRule( + request?: protos.google.cloud.compute.v1.IAddRuleSecurityPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddRuleSecurityPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddRuleSecurityPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'security_policy': request.securityPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.addRule(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.securityPolicy + * Name of the security policy to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/security_policies.delete.js + * region_tag:compute_v1_generated_SecurityPolicies_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteSecurityPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteSecurityPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteSecurityPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteSecurityPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSecurityPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSecurityPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'security_policy': request.securityPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * List all of the ordered rules present in a single specified policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.securityPolicy + * Name of the security policy to get. + * @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.compute.v1.SecurityPolicy | SecurityPolicy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/security_policies.get.js + * region_tag:compute_v1_generated_SecurityPolicies_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetSecurityPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISecurityPolicy, + protos.google.cloud.compute.v1.IGetSecurityPolicyRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetSecurityPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ISecurityPolicy, + protos.google.cloud.compute.v1.IGetSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetSecurityPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ISecurityPolicy, + protos.google.cloud.compute.v1.IGetSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetSecurityPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ISecurityPolicy, + protos.google.cloud.compute.v1.IGetSecurityPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ISecurityPolicy, + protos.google.cloud.compute.v1.IGetSecurityPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ISecurityPolicy, + protos.google.cloud.compute.v1.IGetSecurityPolicyRequest|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({ + 'project': request.project ?? '', + 'security_policy': request.securityPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets a rule at the specified priority. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.priority + * The priority of the rule to get from the security policy. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.securityPolicy + * Name of the security policy to which the queried rule belongs. + * @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.compute.v1.SecurityPolicyRule | SecurityPolicyRule}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/security_policies.get_rule.js + * region_tag:compute_v1_generated_SecurityPolicies_GetRule_async + */ + getRule( + request?: protos.google.cloud.compute.v1.IGetRuleSecurityPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISecurityPolicyRule, + protos.google.cloud.compute.v1.IGetRuleSecurityPolicyRequest|undefined, {}|undefined + ]>; + getRule( + request: protos.google.cloud.compute.v1.IGetRuleSecurityPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ISecurityPolicyRule, + protos.google.cloud.compute.v1.IGetRuleSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + getRule( + request: protos.google.cloud.compute.v1.IGetRuleSecurityPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ISecurityPolicyRule, + protos.google.cloud.compute.v1.IGetRuleSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + getRule( + request?: protos.google.cloud.compute.v1.IGetRuleSecurityPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ISecurityPolicyRule, + protos.google.cloud.compute.v1.IGetRuleSecurityPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ISecurityPolicyRule, + protos.google.cloud.compute.v1.IGetRuleSecurityPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ISecurityPolicyRule, + protos.google.cloud.compute.v1.IGetRuleSecurityPolicyRequest|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({ + 'project': request.project ?? '', + 'security_policy': request.securityPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.getRule(request, options, callback); + } +/** + * Creates a new policy in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.SecurityPolicy} request.securityPolicyResource + * The body resource for this request + * @param {boolean} request.validateOnly + * If true, the request will not be committed. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/security_policies.insert.js + * region_tag:compute_v1_generated_SecurityPolicies_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertSecurityPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertSecurityPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertSecurityPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertSecurityPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSecurityPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSecurityPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Gets the current list of preconfigured Web Application Firewall (WAF) expressions. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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.compute.v1.SecurityPoliciesListPreconfiguredExpressionSetsResponse | SecurityPoliciesListPreconfiguredExpressionSetsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/security_policies.list_preconfigured_expression_sets.js + * region_tag:compute_v1_generated_SecurityPolicies_ListPreconfiguredExpressionSets_async + */ + listPreconfiguredExpressionSets( + request?: protos.google.cloud.compute.v1.IListPreconfiguredExpressionSetsSecurityPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISecurityPoliciesListPreconfiguredExpressionSetsResponse, + protos.google.cloud.compute.v1.IListPreconfiguredExpressionSetsSecurityPoliciesRequest|undefined, {}|undefined + ]>; + listPreconfiguredExpressionSets( + request: protos.google.cloud.compute.v1.IListPreconfiguredExpressionSetsSecurityPoliciesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ISecurityPoliciesListPreconfiguredExpressionSetsResponse, + protos.google.cloud.compute.v1.IListPreconfiguredExpressionSetsSecurityPoliciesRequest|null|undefined, + {}|null|undefined>): void; + listPreconfiguredExpressionSets( + request: protos.google.cloud.compute.v1.IListPreconfiguredExpressionSetsSecurityPoliciesRequest, + callback: Callback< + protos.google.cloud.compute.v1.ISecurityPoliciesListPreconfiguredExpressionSetsResponse, + protos.google.cloud.compute.v1.IListPreconfiguredExpressionSetsSecurityPoliciesRequest|null|undefined, + {}|null|undefined>): void; + listPreconfiguredExpressionSets( + request?: protos.google.cloud.compute.v1.IListPreconfiguredExpressionSetsSecurityPoliciesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ISecurityPoliciesListPreconfiguredExpressionSetsResponse, + protos.google.cloud.compute.v1.IListPreconfiguredExpressionSetsSecurityPoliciesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ISecurityPoliciesListPreconfiguredExpressionSetsResponse, + protos.google.cloud.compute.v1.IListPreconfiguredExpressionSetsSecurityPoliciesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ISecurityPoliciesListPreconfiguredExpressionSetsResponse, + protos.google.cloud.compute.v1.IListPreconfiguredExpressionSetsSecurityPoliciesRequest|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.listPreconfiguredExpressionSets(request, options, callback); + } +/** + * Patches the specified policy with the data included in the request. To clear fields in the rule, leave the fields empty and specify them in the updateMask. This cannot be used to be update the rules in the policy. Please use the per rule methods like addRule, patchRule, and removeRule instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.securityPolicy + * Name of the security policy to update. + * @param {google.cloud.compute.v1.SecurityPolicy} request.securityPolicyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/security_policies.patch.js + * region_tag:compute_v1_generated_SecurityPolicies_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchSecurityPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchSecurityPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchSecurityPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchSecurityPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchSecurityPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchSecurityPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'security_policy': request.securityPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches a rule at the specified priority. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.priority + * The priority of the rule to patch. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.securityPolicy + * Name of the security policy to update. + * @param {google.cloud.compute.v1.SecurityPolicyRule} request.securityPolicyRuleResource + * The body resource for this request + * @param {boolean} request.validateOnly + * If true, the request will not be committed. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/security_policies.patch_rule.js + * region_tag:compute_v1_generated_SecurityPolicies_PatchRule_async + */ + patchRule( + request?: protos.google.cloud.compute.v1.IPatchRuleSecurityPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patchRule( + request: protos.google.cloud.compute.v1.IPatchRuleSecurityPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRuleSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + patchRule( + request: protos.google.cloud.compute.v1.IPatchRuleSecurityPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRuleSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + patchRule( + request?: protos.google.cloud.compute.v1.IPatchRuleSecurityPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRuleSecurityPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchRuleSecurityPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'security_policy': request.securityPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.patchRule(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes a rule at the specified priority. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.priority + * The priority of the rule to remove from the security policy. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.securityPolicy + * Name of the security policy to update. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/security_policies.remove_rule.js + * region_tag:compute_v1_generated_SecurityPolicies_RemoveRule_async + */ + removeRule( + request?: protos.google.cloud.compute.v1.IRemoveRuleSecurityPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + removeRule( + request: protos.google.cloud.compute.v1.IRemoveRuleSecurityPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveRuleSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + removeRule( + request: protos.google.cloud.compute.v1.IRemoveRuleSecurityPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveRuleSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + removeRule( + request?: protos.google.cloud.compute.v1.IRemoveRuleSecurityPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveRuleSecurityPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveRuleSecurityPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'security_policy': request.securityPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeRule(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the labels on a security policy. To learn more about labels, read the Labeling Resources documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalSetLabelsRequest} request.globalSetLabelsRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/security_policies.set_labels.js + * region_tag:compute_v1_generated_SecurityPolicies_SetLabels_async + */ + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsSecurityPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsSecurityPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsSecurityPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsSecurityPolicyRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsSecurityPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsSecurityPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsSecurityPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setLabels(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves the list of all SecurityPolicy resources, regional and global, available to the specified project. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Name of the project scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.SecurityPoliciesScopedList | SecurityPoliciesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/security_policies.aggregated_list.js + * region_tag:compute_v1_generated_SecurityPolicies_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListSecurityPoliciesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.ISecurityPoliciesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.ISecurityPoliciesScopedList]>; + } + /** + * List all the policies that have been configured for the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.SecurityPolicy | SecurityPolicy}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListSecurityPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISecurityPolicy[], + protos.google.cloud.compute.v1.IListSecurityPoliciesRequest|null, + protos.google.cloud.compute.v1.ISecurityPolicyList + ]>; + list( + request: protos.google.cloud.compute.v1.IListSecurityPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListSecurityPoliciesRequest, + protos.google.cloud.compute.v1.ISecurityPolicyList|null|undefined, + protos.google.cloud.compute.v1.ISecurityPolicy>): void; + list( + request: protos.google.cloud.compute.v1.IListSecurityPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListSecurityPoliciesRequest, + protos.google.cloud.compute.v1.ISecurityPolicyList|null|undefined, + protos.google.cloud.compute.v1.ISecurityPolicy>): void; + list( + request?: protos.google.cloud.compute.v1.IListSecurityPoliciesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListSecurityPoliciesRequest, + protos.google.cloud.compute.v1.ISecurityPolicyList|null|undefined, + protos.google.cloud.compute.v1.ISecurityPolicy>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListSecurityPoliciesRequest, + protos.google.cloud.compute.v1.ISecurityPolicyList|null|undefined, + protos.google.cloud.compute.v1.ISecurityPolicy>): + Promise<[ + protos.google.cloud.compute.v1.ISecurityPolicy[], + protos.google.cloud.compute.v1.IListSecurityPoliciesRequest|null, + protos.google.cloud.compute.v1.ISecurityPolicyList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.SecurityPolicy | SecurityPolicy} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListSecurityPoliciesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.SecurityPolicy | SecurityPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/security_policies.list.js + * region_tag:compute_v1_generated_SecurityPolicies_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListSecurityPoliciesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.securityPoliciesStub && !this._terminated) { + return this.securityPoliciesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/security_policies_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/security_policies_client_config.json new file mode 100644 index 00000000000..087221f616c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/security_policies_client_config.json @@ -0,0 +1,74 @@ +{ + "interfaces": { + "google.cloud.compute.v1.SecurityPolicies": { + "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": { + "AddRule": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetRule": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListPreconfiguredExpressionSets": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PatchRule": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveRule": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetLabels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/security_policies_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/security_policies_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/security_policies_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/service_attachments_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/service_attachments_client.ts new file mode 100644 index 00000000000..307240918cf --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/service_attachments_client.ts @@ -0,0 +1,1163 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/service_attachments_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './service_attachments_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The ServiceAttachments API. + * @class + * @memberof v1 + */ +export class ServiceAttachmentsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + serviceAttachmentsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ServiceAttachmentsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ServiceAttachmentsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ServiceAttachmentsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.ServiceAttachments', 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.serviceAttachmentsStub) { + return this.serviceAttachmentsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.ServiceAttachments. + this.serviceAttachmentsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.ServiceAttachments') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.ServiceAttachments, + 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 serviceAttachmentsStubMethods = + ['aggregatedList', 'delete', 'get', 'getIamPolicy', 'insert', 'list', 'patch', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of serviceAttachmentsStubMethods) { + const callPromise = this.serviceAttachmentsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.serviceAttachmentsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified ServiceAttachment in the given scope + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region of this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.serviceAttachment + * Name of the ServiceAttachment resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/service_attachments.delete.js + * region_tag:compute_v1_generated_ServiceAttachments_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteServiceAttachmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteServiceAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteServiceAttachmentRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteServiceAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteServiceAttachmentRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteServiceAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteServiceAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteServiceAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'service_attachment': request.serviceAttachment ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified ServiceAttachment resource in the given scope. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region of this request. + * @param {string} request.serviceAttachment + * Name of the ServiceAttachment resource to return. + * @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.compute.v1.ServiceAttachment | ServiceAttachment}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/service_attachments.get.js + * region_tag:compute_v1_generated_ServiceAttachments_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetServiceAttachmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IServiceAttachment, + protos.google.cloud.compute.v1.IGetServiceAttachmentRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetServiceAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IServiceAttachment, + protos.google.cloud.compute.v1.IGetServiceAttachmentRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetServiceAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IServiceAttachment, + protos.google.cloud.compute.v1.IGetServiceAttachmentRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetServiceAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IServiceAttachment, + protos.google.cloud.compute.v1.IGetServiceAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IServiceAttachment, + protos.google.cloud.compute.v1.IGetServiceAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IServiceAttachment, + protos.google.cloud.compute.v1.IGetServiceAttachmentRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'service_attachment': request.serviceAttachment ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/service_attachments.get_iam_policy.js + * region_tag:compute_v1_generated_ServiceAttachments_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyServiceAttachmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyServiceAttachmentRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyServiceAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyServiceAttachmentRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicyServiceAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyServiceAttachmentRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicyServiceAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyServiceAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyServiceAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicyServiceAttachmentRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Creates a ServiceAttachment in the specified project in the given scope using the parameters that are included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region of this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.ServiceAttachment} request.serviceAttachmentResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/service_attachments.insert.js + * region_tag:compute_v1_generated_ServiceAttachments_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertServiceAttachmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertServiceAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertServiceAttachmentRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertServiceAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertServiceAttachmentRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertServiceAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertServiceAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertServiceAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified ServiceAttachment resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The region scoping this request and should conform to RFC1035. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.serviceAttachment + * The resource id of the ServiceAttachment to patch. It should conform to RFC1035 resource name or be a string form on an unsigned long number. + * @param {google.cloud.compute.v1.ServiceAttachment} request.serviceAttachmentResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/service_attachments.patch.js + * region_tag:compute_v1_generated_ServiceAttachments_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchServiceAttachmentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchServiceAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchServiceAttachmentRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchServiceAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchServiceAttachmentRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchServiceAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchServiceAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchServiceAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'service_attachment': request.serviceAttachment ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {google.cloud.compute.v1.RegionSetPolicyRequest} request.regionSetPolicyRequestResource + * The body resource for this request + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/service_attachments.set_iam_policy.js + * region_tag:compute_v1_generated_ServiceAttachments_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyServiceAttachmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyServiceAttachmentRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyServiceAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyServiceAttachmentRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicyServiceAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyServiceAttachmentRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicyServiceAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyServiceAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyServiceAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicyServiceAttachmentRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/service_attachments.test_iam_permissions.js + * region_tag:compute_v1_generated_ServiceAttachments_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsServiceAttachmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsServiceAttachmentRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsServiceAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsServiceAttachmentRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsServiceAttachmentRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsServiceAttachmentRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsServiceAttachmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsServiceAttachmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsServiceAttachmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsServiceAttachmentRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + +/** + * Retrieves the list of all ServiceAttachment resources, regional and global, available to the specified project. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Name of the project scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.ServiceAttachmentsScopedList | ServiceAttachmentsScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/service_attachments.aggregated_list.js + * region_tag:compute_v1_generated_ServiceAttachments_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListServiceAttachmentsRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IServiceAttachmentsScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IServiceAttachmentsScopedList]>; + } + /** + * Lists the ServiceAttachments for a project in the given scope. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region of this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.ServiceAttachment | ServiceAttachment}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListServiceAttachmentsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IServiceAttachment[], + protos.google.cloud.compute.v1.IListServiceAttachmentsRequest|null, + protos.google.cloud.compute.v1.IServiceAttachmentList + ]>; + list( + request: protos.google.cloud.compute.v1.IListServiceAttachmentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListServiceAttachmentsRequest, + protos.google.cloud.compute.v1.IServiceAttachmentList|null|undefined, + protos.google.cloud.compute.v1.IServiceAttachment>): void; + list( + request: protos.google.cloud.compute.v1.IListServiceAttachmentsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListServiceAttachmentsRequest, + protos.google.cloud.compute.v1.IServiceAttachmentList|null|undefined, + protos.google.cloud.compute.v1.IServiceAttachment>): void; + list( + request?: protos.google.cloud.compute.v1.IListServiceAttachmentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListServiceAttachmentsRequest, + protos.google.cloud.compute.v1.IServiceAttachmentList|null|undefined, + protos.google.cloud.compute.v1.IServiceAttachment>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListServiceAttachmentsRequest, + protos.google.cloud.compute.v1.IServiceAttachmentList|null|undefined, + protos.google.cloud.compute.v1.IServiceAttachment>): + Promise<[ + protos.google.cloud.compute.v1.IServiceAttachment[], + protos.google.cloud.compute.v1.IListServiceAttachmentsRequest|null, + protos.google.cloud.compute.v1.IServiceAttachmentList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region of this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.ServiceAttachment | ServiceAttachment} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListServiceAttachmentsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region of this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.ServiceAttachment | ServiceAttachment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/service_attachments.list.js + * region_tag:compute_v1_generated_ServiceAttachments_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListServiceAttachmentsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.serviceAttachmentsStub && !this._terminated) { + return this.serviceAttachmentsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/service_attachments_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/service_attachments_client_config.json new file mode 100644 index 00000000000..7bddf2c7a9e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/service_attachments_client_config.json @@ -0,0 +1,62 @@ +{ + "interfaces": { + "google.cloud.compute.v1.ServiceAttachments": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/service_attachments_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/service_attachments_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/service_attachments_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/snapshots_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/snapshots_client.ts new file mode 100644 index 00000000000..166c992e357 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/snapshots_client.ts @@ -0,0 +1,1073 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/snapshots_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './snapshots_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Snapshots API. + * @class + * @memberof v1 + */ +export class SnapshotsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + snapshotsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SnapshotsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SnapshotsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SnapshotsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.Snapshots', 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.snapshotsStub) { + return this.snapshotsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.Snapshots. + this.snapshotsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Snapshots') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.Snapshots, + 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 snapshotsStubMethods = + ['delete', 'get', 'getIamPolicy', 'insert', 'list', 'setIamPolicy', 'setLabels', 'testIamPermissions']; + for (const methodName of snapshotsStubMethods) { + const callPromise = this.snapshotsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.snapshotsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified Snapshot resource. Keep in mind that deleting a single snapshot might not necessarily delete all the data on that snapshot. If any data on the snapshot that is marked for deletion is needed for subsequent snapshots, the data will be moved to the next corresponding snapshot. For more information, see Deleting snapshots. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.snapshot + * Name of the Snapshot resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/snapshots.delete.js + * region_tag:compute_v1_generated_Snapshots_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteSnapshotRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteSnapshotRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSnapshotRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteSnapshotRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSnapshotRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteSnapshotRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSnapshotRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSnapshotRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'snapshot': request.snapshot ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified Snapshot resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.snapshot + * Name of the Snapshot resource to return. + * @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.compute.v1.Snapshot | Snapshot}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/snapshots.get.js + * region_tag:compute_v1_generated_Snapshots_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetSnapshotRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISnapshot, + protos.google.cloud.compute.v1.IGetSnapshotRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetSnapshotRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ISnapshot, + protos.google.cloud.compute.v1.IGetSnapshotRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetSnapshotRequest, + callback: Callback< + protos.google.cloud.compute.v1.ISnapshot, + protos.google.cloud.compute.v1.IGetSnapshotRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetSnapshotRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ISnapshot, + protos.google.cloud.compute.v1.IGetSnapshotRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ISnapshot, + protos.google.cloud.compute.v1.IGetSnapshotRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ISnapshot, + protos.google.cloud.compute.v1.IGetSnapshotRequest|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({ + 'project': request.project ?? '', + 'snapshot': request.snapshot ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/snapshots.get_iam_policy.js + * region_tag:compute_v1_generated_Snapshots_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicySnapshotRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicySnapshotRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicySnapshotRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicySnapshotRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicySnapshotRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicySnapshotRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicySnapshotRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicySnapshotRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicySnapshotRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicySnapshotRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Creates a snapshot in the specified project using the data included in the request. For regular snapshot creation, consider using this method instead of disks.createSnapshot, as this method supports more features, such as creating snapshots in a project different from the source disk project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.Snapshot} request.snapshotResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/snapshots.insert.js + * region_tag:compute_v1_generated_Snapshots_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertSnapshotRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertSnapshotRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSnapshotRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertSnapshotRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSnapshotRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertSnapshotRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSnapshotRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSnapshotRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalSetPolicyRequest} request.globalSetPolicyRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/snapshots.set_iam_policy.js + * region_tag:compute_v1_generated_Snapshots_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicySnapshotRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicySnapshotRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicySnapshotRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicySnapshotRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicySnapshotRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicySnapshotRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicySnapshotRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicySnapshotRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicySnapshotRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicySnapshotRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Sets the labels on a snapshot. To learn more about labels, read the Labeling Resources documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.GlobalSetLabelsRequest} request.globalSetLabelsRequestResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/snapshots.set_labels.js + * region_tag:compute_v1_generated_Snapshots_SetLabels_async + */ + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsSnapshotRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsSnapshotRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsSnapshotRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsSnapshotRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsSnapshotRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsSnapshotRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsSnapshotRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsSnapshotRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setLabels(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/snapshots.test_iam_permissions.js + * region_tag:compute_v1_generated_Snapshots_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsSnapshotRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsSnapshotRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsSnapshotRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsSnapshotRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsSnapshotRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsSnapshotRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsSnapshotRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsSnapshotRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsSnapshotRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsSnapshotRequest|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({ + 'project': request.project ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + /** + * Retrieves the list of Snapshot resources contained within the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Snapshot | Snapshot}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListSnapshotsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISnapshot[], + protos.google.cloud.compute.v1.IListSnapshotsRequest|null, + protos.google.cloud.compute.v1.ISnapshotList + ]>; + list( + request: protos.google.cloud.compute.v1.IListSnapshotsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListSnapshotsRequest, + protos.google.cloud.compute.v1.ISnapshotList|null|undefined, + protos.google.cloud.compute.v1.ISnapshot>): void; + list( + request: protos.google.cloud.compute.v1.IListSnapshotsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListSnapshotsRequest, + protos.google.cloud.compute.v1.ISnapshotList|null|undefined, + protos.google.cloud.compute.v1.ISnapshot>): void; + list( + request?: protos.google.cloud.compute.v1.IListSnapshotsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListSnapshotsRequest, + protos.google.cloud.compute.v1.ISnapshotList|null|undefined, + protos.google.cloud.compute.v1.ISnapshot>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListSnapshotsRequest, + protos.google.cloud.compute.v1.ISnapshotList|null|undefined, + protos.google.cloud.compute.v1.ISnapshot>): + Promise<[ + protos.google.cloud.compute.v1.ISnapshot[], + protos.google.cloud.compute.v1.IListSnapshotsRequest|null, + protos.google.cloud.compute.v1.ISnapshotList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Snapshot | Snapshot} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListSnapshotsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Snapshot | Snapshot}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/snapshots.list.js + * region_tag:compute_v1_generated_Snapshots_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListSnapshotsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.snapshotsStub && !this._terminated) { + return this.snapshotsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/snapshots_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/snapshots_client_config.json new file mode 100644 index 00000000000..4043bbff9f1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/snapshots_client_config.json @@ -0,0 +1,58 @@ +{ + "interfaces": { + "google.cloud.compute.v1.Snapshots": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetLabels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/snapshots_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/snapshots_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/snapshots_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_certificates_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_certificates_client.ts new file mode 100644 index 00000000000..b054c5d931b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_certificates_client.ts @@ -0,0 +1,815 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/ssl_certificates_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './ssl_certificates_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The SslCertificates API. + * @class + * @memberof v1 + */ +export class SslCertificatesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + sslCertificatesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SslCertificatesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SslCertificatesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SslCertificatesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.SslCertificates', 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.sslCertificatesStub) { + return this.sslCertificatesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.SslCertificates. + this.sslCertificatesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.SslCertificates') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.SslCertificates, + 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 sslCertificatesStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'list']; + for (const methodName of sslCertificatesStubMethods) { + const callPromise = this.sslCertificatesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.sslCertificatesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified SslCertificate resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.sslCertificate + * Name of the SslCertificate resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/ssl_certificates.delete.js + * region_tag:compute_v1_generated_SslCertificates_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteSslCertificateRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteSslCertificateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSslCertificateRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteSslCertificateRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSslCertificateRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteSslCertificateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSslCertificateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSslCertificateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'ssl_certificate': request.sslCertificate ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified SslCertificate resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.sslCertificate + * Name of the SslCertificate resource to return. + * @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.compute.v1.SslCertificate | SslCertificate}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/ssl_certificates.get.js + * region_tag:compute_v1_generated_SslCertificates_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetSslCertificateRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISslCertificate, + protos.google.cloud.compute.v1.IGetSslCertificateRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetSslCertificateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ISslCertificate, + protos.google.cloud.compute.v1.IGetSslCertificateRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetSslCertificateRequest, + callback: Callback< + protos.google.cloud.compute.v1.ISslCertificate, + protos.google.cloud.compute.v1.IGetSslCertificateRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetSslCertificateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ISslCertificate, + protos.google.cloud.compute.v1.IGetSslCertificateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ISslCertificate, + protos.google.cloud.compute.v1.IGetSslCertificateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ISslCertificate, + protos.google.cloud.compute.v1.IGetSslCertificateRequest|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({ + 'project': request.project ?? '', + 'ssl_certificate': request.sslCertificate ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a SslCertificate resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.SslCertificate} request.sslCertificateResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/ssl_certificates.insert.js + * region_tag:compute_v1_generated_SslCertificates_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertSslCertificateRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertSslCertificateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSslCertificateRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertSslCertificateRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSslCertificateRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertSslCertificateRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSslCertificateRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSslCertificateRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves the list of all SslCertificate resources, regional and global, available to the specified project. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Name of the project scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.SslCertificatesScopedList | SslCertificatesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/ssl_certificates.aggregated_list.js + * region_tag:compute_v1_generated_SslCertificates_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListSslCertificatesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.ISslCertificatesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.ISslCertificatesScopedList]>; + } + /** + * Retrieves the list of SslCertificate resources available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.SslCertificate | SslCertificate}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListSslCertificatesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISslCertificate[], + protos.google.cloud.compute.v1.IListSslCertificatesRequest|null, + protos.google.cloud.compute.v1.ISslCertificateList + ]>; + list( + request: protos.google.cloud.compute.v1.IListSslCertificatesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListSslCertificatesRequest, + protos.google.cloud.compute.v1.ISslCertificateList|null|undefined, + protos.google.cloud.compute.v1.ISslCertificate>): void; + list( + request: protos.google.cloud.compute.v1.IListSslCertificatesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListSslCertificatesRequest, + protos.google.cloud.compute.v1.ISslCertificateList|null|undefined, + protos.google.cloud.compute.v1.ISslCertificate>): void; + list( + request?: protos.google.cloud.compute.v1.IListSslCertificatesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListSslCertificatesRequest, + protos.google.cloud.compute.v1.ISslCertificateList|null|undefined, + protos.google.cloud.compute.v1.ISslCertificate>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListSslCertificatesRequest, + protos.google.cloud.compute.v1.ISslCertificateList|null|undefined, + protos.google.cloud.compute.v1.ISslCertificate>): + Promise<[ + protos.google.cloud.compute.v1.ISslCertificate[], + protos.google.cloud.compute.v1.IListSslCertificatesRequest|null, + protos.google.cloud.compute.v1.ISslCertificateList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.SslCertificate | SslCertificate} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListSslCertificatesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.SslCertificate | SslCertificate}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/ssl_certificates.list.js + * region_tag:compute_v1_generated_SslCertificates_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListSslCertificatesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.sslCertificatesStub && !this._terminated) { + return this.sslCertificatesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_certificates_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_certificates_client_config.json new file mode 100644 index 00000000000..1ed2c359b62 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_certificates_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.compute.v1.SslCertificates": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_certificates_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_certificates_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_certificates_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_policies_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_policies_client.ts new file mode 100644 index 00000000000..834fffff3e0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_policies_client.ts @@ -0,0 +1,986 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/ssl_policies_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './ssl_policies_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The SslPolicies API. + * @class + * @memberof v1 + */ +export class SslPoliciesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + sslPoliciesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SslPoliciesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SslPoliciesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SslPoliciesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.SslPolicies', 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.sslPoliciesStub) { + return this.sslPoliciesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.SslPolicies. + this.sslPoliciesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.SslPolicies') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.SslPolicies, + 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 sslPoliciesStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'list', 'listAvailableFeatures', 'patch']; + for (const methodName of sslPoliciesStubMethods) { + const callPromise = this.sslPoliciesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.sslPoliciesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified SSL policy. The SSL policy resource can be deleted only if it is not in use by any TargetHttpsProxy or TargetSslProxy resources. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.sslPolicy + * Name of the SSL policy to delete. The name must be 1-63 characters long, and comply with RFC1035. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/ssl_policies.delete.js + * region_tag:compute_v1_generated_SslPolicies_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteSslPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteSslPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSslPolicyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteSslPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSslPolicyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteSslPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSslPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSslPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'ssl_policy': request.sslPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Lists all of the ordered rules present in a single specified policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.sslPolicy + * Name of the SSL policy to update. The name must be 1-63 characters long, and comply with RFC1035. + * @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.compute.v1.SslPolicy | SslPolicy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/ssl_policies.get.js + * region_tag:compute_v1_generated_SslPolicies_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetSslPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISslPolicy, + protos.google.cloud.compute.v1.IGetSslPolicyRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetSslPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ISslPolicy, + protos.google.cloud.compute.v1.IGetSslPolicyRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetSslPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ISslPolicy, + protos.google.cloud.compute.v1.IGetSslPolicyRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetSslPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ISslPolicy, + protos.google.cloud.compute.v1.IGetSslPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ISslPolicy, + protos.google.cloud.compute.v1.IGetSslPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ISslPolicy, + protos.google.cloud.compute.v1.IGetSslPolicyRequest|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({ + 'project': request.project ?? '', + 'ssl_policy': request.sslPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Returns the specified SSL policy resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.SslPolicy} request.sslPolicyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/ssl_policies.insert.js + * region_tag:compute_v1_generated_SslPolicies_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertSslPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertSslPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSslPolicyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertSslPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSslPolicyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertSslPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSslPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSslPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Lists all features that can be specified in the SSL policy when using custom profile. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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.compute.v1.SslPoliciesListAvailableFeaturesResponse | SslPoliciesListAvailableFeaturesResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/ssl_policies.list_available_features.js + * region_tag:compute_v1_generated_SslPolicies_ListAvailableFeatures_async + */ + listAvailableFeatures( + request?: protos.google.cloud.compute.v1.IListAvailableFeaturesSslPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISslPoliciesListAvailableFeaturesResponse, + protos.google.cloud.compute.v1.IListAvailableFeaturesSslPoliciesRequest|undefined, {}|undefined + ]>; + listAvailableFeatures( + request: protos.google.cloud.compute.v1.IListAvailableFeaturesSslPoliciesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ISslPoliciesListAvailableFeaturesResponse, + protos.google.cloud.compute.v1.IListAvailableFeaturesSslPoliciesRequest|null|undefined, + {}|null|undefined>): void; + listAvailableFeatures( + request: protos.google.cloud.compute.v1.IListAvailableFeaturesSslPoliciesRequest, + callback: Callback< + protos.google.cloud.compute.v1.ISslPoliciesListAvailableFeaturesResponse, + protos.google.cloud.compute.v1.IListAvailableFeaturesSslPoliciesRequest|null|undefined, + {}|null|undefined>): void; + listAvailableFeatures( + request?: protos.google.cloud.compute.v1.IListAvailableFeaturesSslPoliciesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ISslPoliciesListAvailableFeaturesResponse, + protos.google.cloud.compute.v1.IListAvailableFeaturesSslPoliciesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ISslPoliciesListAvailableFeaturesResponse, + protos.google.cloud.compute.v1.IListAvailableFeaturesSslPoliciesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ISslPoliciesListAvailableFeaturesResponse, + protos.google.cloud.compute.v1.IListAvailableFeaturesSslPoliciesRequest|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.listAvailableFeatures(request, options, callback); + } +/** + * Patches the specified SSL policy with the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.sslPolicy + * Name of the SSL policy to update. The name must be 1-63 characters long, and comply with RFC1035. + * @param {google.cloud.compute.v1.SslPolicy} request.sslPolicyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/ssl_policies.patch.js + * region_tag:compute_v1_generated_SslPolicies_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchSslPolicyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchSslPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchSslPolicyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchSslPolicyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchSslPolicyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchSslPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchSslPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchSslPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'ssl_policy': request.sslPolicy ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves the list of all SslPolicy resources, regional and global, available to the specified project. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Name of the project scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.SslPoliciesScopedList | SslPoliciesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/ssl_policies.aggregated_list.js + * region_tag:compute_v1_generated_SslPolicies_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListSslPoliciesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.ISslPoliciesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.ISslPoliciesScopedList]>; + } + /** + * Lists all the SSL policies that have been configured for the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.SslPolicy | SslPolicy}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListSslPoliciesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISslPolicy[], + protos.google.cloud.compute.v1.IListSslPoliciesRequest|null, + protos.google.cloud.compute.v1.ISslPoliciesList + ]>; + list( + request: protos.google.cloud.compute.v1.IListSslPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListSslPoliciesRequest, + protos.google.cloud.compute.v1.ISslPoliciesList|null|undefined, + protos.google.cloud.compute.v1.ISslPolicy>): void; + list( + request: protos.google.cloud.compute.v1.IListSslPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListSslPoliciesRequest, + protos.google.cloud.compute.v1.ISslPoliciesList|null|undefined, + protos.google.cloud.compute.v1.ISslPolicy>): void; + list( + request?: protos.google.cloud.compute.v1.IListSslPoliciesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListSslPoliciesRequest, + protos.google.cloud.compute.v1.ISslPoliciesList|null|undefined, + protos.google.cloud.compute.v1.ISslPolicy>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListSslPoliciesRequest, + protos.google.cloud.compute.v1.ISslPoliciesList|null|undefined, + protos.google.cloud.compute.v1.ISslPolicy>): + Promise<[ + protos.google.cloud.compute.v1.ISslPolicy[], + protos.google.cloud.compute.v1.IListSslPoliciesRequest|null, + protos.google.cloud.compute.v1.ISslPoliciesList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.SslPolicy | SslPolicy} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListSslPoliciesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.SslPolicy | SslPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/ssl_policies.list.js + * region_tag:compute_v1_generated_SslPolicies_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListSslPoliciesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.sslPoliciesStub && !this._terminated) { + return this.sslPoliciesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_policies_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_policies_client_config.json new file mode 100644 index 00000000000..e8767aceecf --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_policies_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.compute.v1.SslPolicies": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListAvailableFeatures": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_policies_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_policies_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/ssl_policies_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/subnetworks_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/subnetworks_client.ts new file mode 100644 index 00000000000..1f327f158a8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/subnetworks_client.ts @@ -0,0 +1,1544 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/subnetworks_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './subnetworks_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Subnetworks API. + * @class + * @memberof v1 + */ +export class SubnetworksClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + subnetworksStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SubnetworksClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SubnetworksClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SubnetworksClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + listUsable: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.Subnetworks', 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.subnetworksStub) { + return this.subnetworksStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.Subnetworks. + this.subnetworksStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Subnetworks') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.Subnetworks, + 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 subnetworksStubMethods = + ['aggregatedList', 'delete', 'expandIpCidrRange', 'get', 'getIamPolicy', 'insert', 'list', 'listUsable', 'patch', 'setIamPolicy', 'setPrivateIpGoogleAccess', 'testIamPermissions']; + for (const methodName of subnetworksStubMethods) { + const callPromise = this.subnetworksStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.subnetworksStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified subnetwork. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.subnetwork + * Name of the Subnetwork resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/subnetworks.delete.js + * region_tag:compute_v1_generated_Subnetworks_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteSubnetworkRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteSubnetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSubnetworkRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteSubnetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSubnetworkRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteSubnetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSubnetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteSubnetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'subnetwork': request.subnetwork ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Expands the IP CIDR range of the subnetwork to a specified value. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.subnetwork + * Name of the Subnetwork resource to update. + * @param {google.cloud.compute.v1.SubnetworksExpandIpCidrRangeRequest} request.subnetworksExpandIpCidrRangeRequestResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/subnetworks.expand_ip_cidr_range.js + * region_tag:compute_v1_generated_Subnetworks_ExpandIpCidrRange_async + */ + expandIpCidrRange( + request?: protos.google.cloud.compute.v1.IExpandIpCidrRangeSubnetworkRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + expandIpCidrRange( + request: protos.google.cloud.compute.v1.IExpandIpCidrRangeSubnetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IExpandIpCidrRangeSubnetworkRequest|null|undefined, + {}|null|undefined>): void; + expandIpCidrRange( + request: protos.google.cloud.compute.v1.IExpandIpCidrRangeSubnetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IExpandIpCidrRangeSubnetworkRequest|null|undefined, + {}|null|undefined>): void; + expandIpCidrRange( + request?: protos.google.cloud.compute.v1.IExpandIpCidrRangeSubnetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IExpandIpCidrRangeSubnetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IExpandIpCidrRangeSubnetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'subnetwork': request.subnetwork ?? '', + }); + this.initialize(); + return this.innerApiCalls.expandIpCidrRange(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified subnetwork. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.subnetwork + * Name of the Subnetwork resource to return. + * @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.compute.v1.Subnetwork | Subnetwork}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/subnetworks.get.js + * region_tag:compute_v1_generated_Subnetworks_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetSubnetworkRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISubnetwork, + protos.google.cloud.compute.v1.IGetSubnetworkRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetSubnetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ISubnetwork, + protos.google.cloud.compute.v1.IGetSubnetworkRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetSubnetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.ISubnetwork, + protos.google.cloud.compute.v1.IGetSubnetworkRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetSubnetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ISubnetwork, + protos.google.cloud.compute.v1.IGetSubnetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ISubnetwork, + protos.google.cloud.compute.v1.IGetSubnetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ISubnetwork, + protos.google.cloud.compute.v1.IGetSubnetworkRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'subnetwork': request.subnetwork ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.optionsRequestedPolicyVersion + * Requested IAM Policy version. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/subnetworks.get_iam_policy.js + * region_tag:compute_v1_generated_Subnetworks_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicySubnetworkRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicySubnetworkRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicySubnetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicySubnetworkRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.cloud.compute.v1.IGetIamPolicySubnetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicySubnetworkRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.cloud.compute.v1.IGetIamPolicySubnetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicySubnetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicySubnetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.IGetIamPolicySubnetworkRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Creates a subnetwork in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.Subnetwork} request.subnetworkResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/subnetworks.insert.js + * region_tag:compute_v1_generated_Subnetworks_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertSubnetworkRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertSubnetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSubnetworkRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertSubnetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSubnetworkRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertSubnetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSubnetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertSubnetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified subnetwork with the data included in the request. Only certain fields can be updated with a patch request as indicated in the field descriptions. You must specify the current fingerprint of the subnetwork resource being patched. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.drainTimeoutSeconds + * The drain timeout specifies the upper bound in seconds on the amount of time allowed to drain connections from the current ACTIVE subnetwork to the current BACKUP subnetwork. The drain timeout is only applicable when the following conditions are true: - the subnetwork being patched has purpose = INTERNAL_HTTPS_LOAD_BALANCER - the subnetwork being patched has role = BACKUP - the patch request is setting the role to ACTIVE. Note that after this patch operation the roles of the ACTIVE and BACKUP subnetworks will be swapped. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.subnetwork + * Name of the Subnetwork resource to patch. + * @param {google.cloud.compute.v1.Subnetwork} request.subnetworkResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/subnetworks.patch.js + * region_tag:compute_v1_generated_Subnetworks_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchSubnetworkRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchSubnetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchSubnetworkRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchSubnetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchSubnetworkRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchSubnetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchSubnetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchSubnetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'subnetwork': request.subnetwork ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {google.cloud.compute.v1.RegionSetPolicyRequest} request.regionSetPolicyRequestResource + * The body resource for this request + * @param {string} request.resource + * Name or id of the resource for this request. + * @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.compute.v1.Policy | Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/subnetworks.set_iam_policy.js + * region_tag:compute_v1_generated_Subnetworks_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicySubnetworkRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicySubnetworkRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicySubnetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicySubnetworkRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.cloud.compute.v1.ISetIamPolicySubnetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicySubnetworkRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.cloud.compute.v1.ISetIamPolicySubnetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicySubnetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicySubnetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IPolicy, + protos.google.cloud.compute.v1.ISetIamPolicySubnetworkRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Set whether VMs in this subnet can access Google services without assigning external IP addresses through Private Google Access. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.subnetwork + * Name of the Subnetwork resource. + * @param {google.cloud.compute.v1.SubnetworksSetPrivateIpGoogleAccessRequest} request.subnetworksSetPrivateIpGoogleAccessRequestResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/subnetworks.set_private_ip_google_access.js + * region_tag:compute_v1_generated_Subnetworks_SetPrivateIpGoogleAccess_async + */ + setPrivateIpGoogleAccess( + request?: protos.google.cloud.compute.v1.ISetPrivateIpGoogleAccessSubnetworkRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setPrivateIpGoogleAccess( + request: protos.google.cloud.compute.v1.ISetPrivateIpGoogleAccessSubnetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetPrivateIpGoogleAccessSubnetworkRequest|null|undefined, + {}|null|undefined>): void; + setPrivateIpGoogleAccess( + request: protos.google.cloud.compute.v1.ISetPrivateIpGoogleAccessSubnetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetPrivateIpGoogleAccessSubnetworkRequest|null|undefined, + {}|null|undefined>): void; + setPrivateIpGoogleAccess( + request?: protos.google.cloud.compute.v1.ISetPrivateIpGoogleAccessSubnetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetPrivateIpGoogleAccessSubnetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetPrivateIpGoogleAccessSubnetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'subnetwork': request.subnetwork ?? '', + }); + this.initialize(); + return this.innerApiCalls.setPrivateIpGoogleAccess(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/subnetworks.test_iam_permissions.js + * region_tag:compute_v1_generated_Subnetworks_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsSubnetworkRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsSubnetworkRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsSubnetworkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsSubnetworkRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsSubnetworkRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsSubnetworkRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsSubnetworkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsSubnetworkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsSubnetworkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsSubnetworkRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + +/** + * Retrieves an aggregated list of subnetworks. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.SubnetworksScopedList | SubnetworksScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/subnetworks.aggregated_list.js + * region_tag:compute_v1_generated_Subnetworks_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListSubnetworksRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.ISubnetworksScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.ISubnetworksScopedList]>; + } + /** + * Retrieves a list of subnetworks available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Subnetwork | Subnetwork}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListSubnetworksRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ISubnetwork[], + protos.google.cloud.compute.v1.IListSubnetworksRequest|null, + protos.google.cloud.compute.v1.ISubnetworkList + ]>; + list( + request: protos.google.cloud.compute.v1.IListSubnetworksRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListSubnetworksRequest, + protos.google.cloud.compute.v1.ISubnetworkList|null|undefined, + protos.google.cloud.compute.v1.ISubnetwork>): void; + list( + request: protos.google.cloud.compute.v1.IListSubnetworksRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListSubnetworksRequest, + protos.google.cloud.compute.v1.ISubnetworkList|null|undefined, + protos.google.cloud.compute.v1.ISubnetwork>): void; + list( + request?: protos.google.cloud.compute.v1.IListSubnetworksRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListSubnetworksRequest, + protos.google.cloud.compute.v1.ISubnetworkList|null|undefined, + protos.google.cloud.compute.v1.ISubnetwork>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListSubnetworksRequest, + protos.google.cloud.compute.v1.ISubnetworkList|null|undefined, + protos.google.cloud.compute.v1.ISubnetwork>): + Promise<[ + protos.google.cloud.compute.v1.ISubnetwork[], + protos.google.cloud.compute.v1.IListSubnetworksRequest|null, + protos.google.cloud.compute.v1.ISubnetworkList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Subnetwork | Subnetwork} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListSubnetworksRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Subnetwork | Subnetwork}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/subnetworks.list.js + * region_tag:compute_v1_generated_Subnetworks_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListSubnetworksRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Retrieves an aggregated list of all usable subnetworks in the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.UsableSubnetwork | UsableSubnetwork}. + * 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 `listUsableAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listUsable( + request?: protos.google.cloud.compute.v1.IListUsableSubnetworksRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IUsableSubnetwork[], + protos.google.cloud.compute.v1.IListUsableSubnetworksRequest|null, + protos.google.cloud.compute.v1.IUsableSubnetworksAggregatedList + ]>; + listUsable( + request: protos.google.cloud.compute.v1.IListUsableSubnetworksRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListUsableSubnetworksRequest, + protos.google.cloud.compute.v1.IUsableSubnetworksAggregatedList|null|undefined, + protos.google.cloud.compute.v1.IUsableSubnetwork>): void; + listUsable( + request: protos.google.cloud.compute.v1.IListUsableSubnetworksRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListUsableSubnetworksRequest, + protos.google.cloud.compute.v1.IUsableSubnetworksAggregatedList|null|undefined, + protos.google.cloud.compute.v1.IUsableSubnetwork>): void; + listUsable( + request?: protos.google.cloud.compute.v1.IListUsableSubnetworksRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListUsableSubnetworksRequest, + protos.google.cloud.compute.v1.IUsableSubnetworksAggregatedList|null|undefined, + protos.google.cloud.compute.v1.IUsableSubnetwork>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListUsableSubnetworksRequest, + protos.google.cloud.compute.v1.IUsableSubnetworksAggregatedList|null|undefined, + protos.google.cloud.compute.v1.IUsableSubnetwork>): + Promise<[ + protos.google.cloud.compute.v1.IUsableSubnetwork[], + protos.google.cloud.compute.v1.IListUsableSubnetworksRequest|null, + protos.google.cloud.compute.v1.IUsableSubnetworksAggregatedList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.listUsable(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.UsableSubnetwork | UsableSubnetwork} 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 `listUsableAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listUsableStream( + request?: protos.google.cloud.compute.v1.IListUsableSubnetworksRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['listUsable']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listUsable.createStream( + this.innerApiCalls.listUsable as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listUsable`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.UsableSubnetwork | UsableSubnetwork}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/subnetworks.list_usable.js + * region_tag:compute_v1_generated_Subnetworks_ListUsable_async + */ + listUsableAsync( + request?: protos.google.cloud.compute.v1.IListUsableSubnetworksRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['listUsable']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listUsable.asyncIterate( + this.innerApiCalls['listUsable'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.subnetworksStub && !this._terminated) { + return this.subnetworksStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/subnetworks_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/subnetworks_client_config.json new file mode 100644 index 00000000000..b850981aee0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/subnetworks_client_config.json @@ -0,0 +1,74 @@ +{ + "interfaces": { + "google.cloud.compute.v1.Subnetworks": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ExpandIpCidrRange": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListUsable": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetPrivateIpGoogleAccess": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/subnetworks_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/subnetworks_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/subnetworks_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_grpc_proxies_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_grpc_proxies_client.ts new file mode 100644 index 00000000000..a219edc6317 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_grpc_proxies_client.ts @@ -0,0 +1,847 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/target_grpc_proxies_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './target_grpc_proxies_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The TargetGrpcProxies API. + * @class + * @memberof v1 + */ +export class TargetGrpcProxiesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + targetGrpcProxiesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TargetGrpcProxiesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new TargetGrpcProxiesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof TargetGrpcProxiesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.TargetGrpcProxies', 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.targetGrpcProxiesStub) { + return this.targetGrpcProxiesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.TargetGrpcProxies. + this.targetGrpcProxiesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.TargetGrpcProxies') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.TargetGrpcProxies, + 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 targetGrpcProxiesStubMethods = + ['delete', 'get', 'insert', 'list', 'patch']; + for (const methodName of targetGrpcProxiesStubMethods) { + const callPromise = this.targetGrpcProxiesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.targetGrpcProxiesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified TargetGrpcProxy in the given scope + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetGrpcProxy + * Name of the TargetGrpcProxy resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_grpc_proxies.delete.js + * region_tag:compute_v1_generated_TargetGrpcProxies_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteTargetGrpcProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteTargetGrpcProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetGrpcProxyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteTargetGrpcProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetGrpcProxyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteTargetGrpcProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetGrpcProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetGrpcProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_grpc_proxy': request.targetGrpcProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified TargetGrpcProxy resource in the given scope. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.targetGrpcProxy + * Name of the TargetGrpcProxy resource to return. + * @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.compute.v1.TargetGrpcProxy | TargetGrpcProxy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/target_grpc_proxies.get.js + * region_tag:compute_v1_generated_TargetGrpcProxies_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetTargetGrpcProxyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetGrpcProxy, + protos.google.cloud.compute.v1.IGetTargetGrpcProxyRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetTargetGrpcProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITargetGrpcProxy, + protos.google.cloud.compute.v1.IGetTargetGrpcProxyRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetTargetGrpcProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITargetGrpcProxy, + protos.google.cloud.compute.v1.IGetTargetGrpcProxyRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetTargetGrpcProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITargetGrpcProxy, + protos.google.cloud.compute.v1.IGetTargetGrpcProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITargetGrpcProxy, + protos.google.cloud.compute.v1.IGetTargetGrpcProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITargetGrpcProxy, + protos.google.cloud.compute.v1.IGetTargetGrpcProxyRequest|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({ + 'project': request.project ?? '', + 'target_grpc_proxy': request.targetGrpcProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a TargetGrpcProxy in the specified project in the given scope using the parameters that are included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetGrpcProxy} request.targetGrpcProxyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_grpc_proxies.insert.js + * region_tag:compute_v1_generated_TargetGrpcProxies_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertTargetGrpcProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertTargetGrpcProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetGrpcProxyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertTargetGrpcProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetGrpcProxyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertTargetGrpcProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetGrpcProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetGrpcProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified TargetGrpcProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetGrpcProxy + * Name of the TargetGrpcProxy resource to patch. + * @param {google.cloud.compute.v1.TargetGrpcProxy} request.targetGrpcProxyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_grpc_proxies.patch.js + * region_tag:compute_v1_generated_TargetGrpcProxies_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchTargetGrpcProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchTargetGrpcProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchTargetGrpcProxyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchTargetGrpcProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchTargetGrpcProxyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchTargetGrpcProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchTargetGrpcProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchTargetGrpcProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_grpc_proxy': request.targetGrpcProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Lists the TargetGrpcProxies for a project in the given scope. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetGrpcProxy | TargetGrpcProxy}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListTargetGrpcProxiesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetGrpcProxy[], + protos.google.cloud.compute.v1.IListTargetGrpcProxiesRequest|null, + protos.google.cloud.compute.v1.ITargetGrpcProxyList + ]>; + list( + request: protos.google.cloud.compute.v1.IListTargetGrpcProxiesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetGrpcProxiesRequest, + protos.google.cloud.compute.v1.ITargetGrpcProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetGrpcProxy>): void; + list( + request: protos.google.cloud.compute.v1.IListTargetGrpcProxiesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetGrpcProxiesRequest, + protos.google.cloud.compute.v1.ITargetGrpcProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetGrpcProxy>): void; + list( + request?: protos.google.cloud.compute.v1.IListTargetGrpcProxiesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListTargetGrpcProxiesRequest, + protos.google.cloud.compute.v1.ITargetGrpcProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetGrpcProxy>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetGrpcProxiesRequest, + protos.google.cloud.compute.v1.ITargetGrpcProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetGrpcProxy>): + Promise<[ + protos.google.cloud.compute.v1.ITargetGrpcProxy[], + protos.google.cloud.compute.v1.IListTargetGrpcProxiesRequest|null, + protos.google.cloud.compute.v1.ITargetGrpcProxyList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetGrpcProxy | TargetGrpcProxy} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListTargetGrpcProxiesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.TargetGrpcProxy | TargetGrpcProxy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/target_grpc_proxies.list.js + * region_tag:compute_v1_generated_TargetGrpcProxies_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListTargetGrpcProxiesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.targetGrpcProxiesStub && !this._terminated) { + return this.targetGrpcProxiesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_grpc_proxies_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_grpc_proxies_client_config.json new file mode 100644 index 00000000000..1c2f425ef91 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_grpc_proxies_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.compute.v1.TargetGrpcProxies": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_grpc_proxies_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_grpc_proxies_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_grpc_proxies_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_http_proxies_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_http_proxies_client.ts new file mode 100644 index 00000000000..04c1a6de18f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_http_proxies_client.ts @@ -0,0 +1,995 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/target_http_proxies_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './target_http_proxies_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The TargetHttpProxies API. + * @class + * @memberof v1 + */ +export class TargetHttpProxiesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + targetHttpProxiesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TargetHttpProxiesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new TargetHttpProxiesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof TargetHttpProxiesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.TargetHttpProxies', 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.targetHttpProxiesStub) { + return this.targetHttpProxiesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.TargetHttpProxies. + this.targetHttpProxiesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.TargetHttpProxies') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.TargetHttpProxies, + 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 targetHttpProxiesStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'list', 'patch', 'setUrlMap']; + for (const methodName of targetHttpProxiesStubMethods) { + const callPromise = this.targetHttpProxiesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.targetHttpProxiesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified TargetHttpProxy resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetHttpProxy + * Name of the TargetHttpProxy resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_http_proxies.delete.js + * region_tag:compute_v1_generated_TargetHttpProxies_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteTargetHttpProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteTargetHttpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteTargetHttpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteTargetHttpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetHttpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_http_proxy': request.targetHttpProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified TargetHttpProxy resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.targetHttpProxy + * Name of the TargetHttpProxy resource to return. + * @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.compute.v1.TargetHttpProxy | TargetHttpProxy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/target_http_proxies.get.js + * region_tag:compute_v1_generated_TargetHttpProxies_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetTargetHttpProxyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetHttpProxy, + protos.google.cloud.compute.v1.IGetTargetHttpProxyRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetTargetHttpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITargetHttpProxy, + protos.google.cloud.compute.v1.IGetTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetTargetHttpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITargetHttpProxy, + protos.google.cloud.compute.v1.IGetTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetTargetHttpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITargetHttpProxy, + protos.google.cloud.compute.v1.IGetTargetHttpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITargetHttpProxy, + protos.google.cloud.compute.v1.IGetTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITargetHttpProxy, + protos.google.cloud.compute.v1.IGetTargetHttpProxyRequest|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({ + 'project': request.project ?? '', + 'target_http_proxy': request.targetHttpProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a TargetHttpProxy resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetHttpProxy} request.targetHttpProxyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_http_proxies.insert.js + * region_tag:compute_v1_generated_TargetHttpProxies_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertTargetHttpProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertTargetHttpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertTargetHttpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertTargetHttpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetHttpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified TargetHttpProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetHttpProxy + * Name of the TargetHttpProxy resource to patch. + * @param {google.cloud.compute.v1.TargetHttpProxy} request.targetHttpProxyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_http_proxies.patch.js + * region_tag:compute_v1_generated_TargetHttpProxies_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchTargetHttpProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchTargetHttpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchTargetHttpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchTargetHttpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchTargetHttpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_http_proxy': request.targetHttpProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes the URL map for TargetHttpProxy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetHttpProxy + * Name of the TargetHttpProxy to set a URL map for. + * @param {google.cloud.compute.v1.UrlMapReference} request.urlMapReferenceResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_http_proxies.set_url_map.js + * region_tag:compute_v1_generated_TargetHttpProxies_SetUrlMap_async + */ + setUrlMap( + request?: protos.google.cloud.compute.v1.ISetUrlMapTargetHttpProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setUrlMap( + request: protos.google.cloud.compute.v1.ISetUrlMapTargetHttpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUrlMapTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + setUrlMap( + request: protos.google.cloud.compute.v1.ISetUrlMapTargetHttpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUrlMapTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): void; + setUrlMap( + request?: protos.google.cloud.compute.v1.ISetUrlMapTargetHttpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUrlMapTargetHttpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUrlMapTargetHttpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_http_proxy': request.targetHttpProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.setUrlMap(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves the list of all TargetHttpProxy resources, regional and global, available to the specified project. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Name of the project scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.TargetHttpProxiesScopedList | TargetHttpProxiesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/target_http_proxies.aggregated_list.js + * region_tag:compute_v1_generated_TargetHttpProxies_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListTargetHttpProxiesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.ITargetHttpProxiesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.ITargetHttpProxiesScopedList]>; + } + /** + * Retrieves the list of TargetHttpProxy resources available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetHttpProxy | TargetHttpProxy}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListTargetHttpProxiesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetHttpProxy[], + protos.google.cloud.compute.v1.IListTargetHttpProxiesRequest|null, + protos.google.cloud.compute.v1.ITargetHttpProxyList + ]>; + list( + request: protos.google.cloud.compute.v1.IListTargetHttpProxiesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetHttpProxiesRequest, + protos.google.cloud.compute.v1.ITargetHttpProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetHttpProxy>): void; + list( + request: protos.google.cloud.compute.v1.IListTargetHttpProxiesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetHttpProxiesRequest, + protos.google.cloud.compute.v1.ITargetHttpProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetHttpProxy>): void; + list( + request?: protos.google.cloud.compute.v1.IListTargetHttpProxiesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListTargetHttpProxiesRequest, + protos.google.cloud.compute.v1.ITargetHttpProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetHttpProxy>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetHttpProxiesRequest, + protos.google.cloud.compute.v1.ITargetHttpProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetHttpProxy>): + Promise<[ + protos.google.cloud.compute.v1.ITargetHttpProxy[], + protos.google.cloud.compute.v1.IListTargetHttpProxiesRequest|null, + protos.google.cloud.compute.v1.ITargetHttpProxyList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetHttpProxy | TargetHttpProxy} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListTargetHttpProxiesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.TargetHttpProxy | TargetHttpProxy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/target_http_proxies.list.js + * region_tag:compute_v1_generated_TargetHttpProxies_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListTargetHttpProxiesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.targetHttpProxiesStub && !this._terminated) { + return this.targetHttpProxiesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_http_proxies_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_http_proxies_client_config.json new file mode 100644 index 00000000000..6451b5185b5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_http_proxies_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.compute.v1.TargetHttpProxies": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetUrlMap": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_http_proxies_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_http_proxies_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_http_proxies_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_https_proxies_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_https_proxies_client.ts new file mode 100644 index 00000000000..3a901cbe689 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_https_proxies_client.ts @@ -0,0 +1,1355 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/target_https_proxies_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './target_https_proxies_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The TargetHttpsProxies API. + * @class + * @memberof v1 + */ +export class TargetHttpsProxiesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + targetHttpsProxiesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TargetHttpsProxiesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new TargetHttpsProxiesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof TargetHttpsProxiesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.TargetHttpsProxies', 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.targetHttpsProxiesStub) { + return this.targetHttpsProxiesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.TargetHttpsProxies. + this.targetHttpsProxiesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.TargetHttpsProxies') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.TargetHttpsProxies, + 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 targetHttpsProxiesStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'list', 'patch', 'setCertificateMap', 'setQuicOverride', 'setSslCertificates', 'setSslPolicy', 'setUrlMap']; + for (const methodName of targetHttpsProxiesStubMethods) { + const callPromise = this.targetHttpsProxiesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.targetHttpsProxiesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified TargetHttpsProxy resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetHttpsProxy + * Name of the TargetHttpsProxy resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_https_proxies.delete.js + * region_tag:compute_v1_generated_TargetHttpsProxies_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteTargetHttpsProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteTargetHttpsProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteTargetHttpsProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteTargetHttpsProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_https_proxy': request.targetHttpsProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified TargetHttpsProxy resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.targetHttpsProxy + * Name of the TargetHttpsProxy resource to return. + * @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.compute.v1.TargetHttpsProxy | TargetHttpsProxy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/target_https_proxies.get.js + * region_tag:compute_v1_generated_TargetHttpsProxies_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetTargetHttpsProxyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetHttpsProxy, + protos.google.cloud.compute.v1.IGetTargetHttpsProxyRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetTargetHttpsProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITargetHttpsProxy, + protos.google.cloud.compute.v1.IGetTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetTargetHttpsProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITargetHttpsProxy, + protos.google.cloud.compute.v1.IGetTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetTargetHttpsProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITargetHttpsProxy, + protos.google.cloud.compute.v1.IGetTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITargetHttpsProxy, + protos.google.cloud.compute.v1.IGetTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITargetHttpsProxy, + protos.google.cloud.compute.v1.IGetTargetHttpsProxyRequest|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({ + 'project': request.project ?? '', + 'target_https_proxy': request.targetHttpsProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a TargetHttpsProxy resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetHttpsProxy} request.targetHttpsProxyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_https_proxies.insert.js + * region_tag:compute_v1_generated_TargetHttpsProxies_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertTargetHttpsProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertTargetHttpsProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertTargetHttpsProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertTargetHttpsProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified TargetHttpsProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetHttpsProxy + * Name of the TargetHttpsProxy resource to patch. + * @param {google.cloud.compute.v1.TargetHttpsProxy} request.targetHttpsProxyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_https_proxies.patch.js + * region_tag:compute_v1_generated_TargetHttpsProxies_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchTargetHttpsProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchTargetHttpsProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchTargetHttpsProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchTargetHttpsProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_https_proxy': request.targetHttpsProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes the Certificate Map for TargetHttpsProxy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetHttpsProxiesSetCertificateMapRequest} request.targetHttpsProxiesSetCertificateMapRequestResource + * The body resource for this request + * @param {string} request.targetHttpsProxy + * Name of the TargetHttpsProxy resource whose CertificateMap is to be set. The name must be 1-63 characters long, and comply with RFC1035. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_https_proxies.set_certificate_map.js + * region_tag:compute_v1_generated_TargetHttpsProxies_SetCertificateMap_async + */ + setCertificateMap( + request?: protos.google.cloud.compute.v1.ISetCertificateMapTargetHttpsProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setCertificateMap( + request: protos.google.cloud.compute.v1.ISetCertificateMapTargetHttpsProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetCertificateMapTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + setCertificateMap( + request: protos.google.cloud.compute.v1.ISetCertificateMapTargetHttpsProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetCertificateMapTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + setCertificateMap( + request?: protos.google.cloud.compute.v1.ISetCertificateMapTargetHttpsProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetCertificateMapTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetCertificateMapTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_https_proxy': request.targetHttpsProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.setCertificateMap(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the QUIC override policy for TargetHttpsProxy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetHttpsProxiesSetQuicOverrideRequest} request.targetHttpsProxiesSetQuicOverrideRequestResource + * The body resource for this request + * @param {string} request.targetHttpsProxy + * Name of the TargetHttpsProxy resource to set the QUIC override policy for. The name should conform to RFC1035. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_https_proxies.set_quic_override.js + * region_tag:compute_v1_generated_TargetHttpsProxies_SetQuicOverride_async + */ + setQuicOverride( + request?: protos.google.cloud.compute.v1.ISetQuicOverrideTargetHttpsProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setQuicOverride( + request: protos.google.cloud.compute.v1.ISetQuicOverrideTargetHttpsProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetQuicOverrideTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + setQuicOverride( + request: protos.google.cloud.compute.v1.ISetQuicOverrideTargetHttpsProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetQuicOverrideTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + setQuicOverride( + request?: protos.google.cloud.compute.v1.ISetQuicOverrideTargetHttpsProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetQuicOverrideTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetQuicOverrideTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_https_proxy': request.targetHttpsProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.setQuicOverride(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Replaces SslCertificates for TargetHttpsProxy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetHttpsProxiesSetSslCertificatesRequest} request.targetHttpsProxiesSetSslCertificatesRequestResource + * The body resource for this request + * @param {string} request.targetHttpsProxy + * Name of the TargetHttpsProxy resource to set an SslCertificates resource for. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_https_proxies.set_ssl_certificates.js + * region_tag:compute_v1_generated_TargetHttpsProxies_SetSslCertificates_async + */ + setSslCertificates( + request?: protos.google.cloud.compute.v1.ISetSslCertificatesTargetHttpsProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setSslCertificates( + request: protos.google.cloud.compute.v1.ISetSslCertificatesTargetHttpsProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslCertificatesTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + setSslCertificates( + request: protos.google.cloud.compute.v1.ISetSslCertificatesTargetHttpsProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslCertificatesTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + setSslCertificates( + request?: protos.google.cloud.compute.v1.ISetSslCertificatesTargetHttpsProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslCertificatesTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslCertificatesTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_https_proxy': request.targetHttpsProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.setSslCertificates(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the SSL policy for TargetHttpsProxy. The SSL policy specifies the server-side support for SSL features. This affects connections between clients and the HTTPS proxy load balancer. They do not affect the connection between the load balancer and the backends. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.SslPolicyReference} request.sslPolicyReferenceResource + * The body resource for this request + * @param {string} request.targetHttpsProxy + * Name of the TargetHttpsProxy resource whose SSL policy is to be set. The name must be 1-63 characters long, and comply with RFC1035. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_https_proxies.set_ssl_policy.js + * region_tag:compute_v1_generated_TargetHttpsProxies_SetSslPolicy_async + */ + setSslPolicy( + request?: protos.google.cloud.compute.v1.ISetSslPolicyTargetHttpsProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setSslPolicy( + request: protos.google.cloud.compute.v1.ISetSslPolicyTargetHttpsProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslPolicyTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + setSslPolicy( + request: protos.google.cloud.compute.v1.ISetSslPolicyTargetHttpsProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslPolicyTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + setSslPolicy( + request?: protos.google.cloud.compute.v1.ISetSslPolicyTargetHttpsProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslPolicyTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslPolicyTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_https_proxy': request.targetHttpsProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.setSslPolicy(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes the URL map for TargetHttpsProxy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetHttpsProxy + * Name of the TargetHttpsProxy resource whose URL map is to be set. + * @param {google.cloud.compute.v1.UrlMapReference} request.urlMapReferenceResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_https_proxies.set_url_map.js + * region_tag:compute_v1_generated_TargetHttpsProxies_SetUrlMap_async + */ + setUrlMap( + request?: protos.google.cloud.compute.v1.ISetUrlMapTargetHttpsProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setUrlMap( + request: protos.google.cloud.compute.v1.ISetUrlMapTargetHttpsProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUrlMapTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + setUrlMap( + request: protos.google.cloud.compute.v1.ISetUrlMapTargetHttpsProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUrlMapTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): void; + setUrlMap( + request?: protos.google.cloud.compute.v1.ISetUrlMapTargetHttpsProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUrlMapTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetUrlMapTargetHttpsProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_https_proxy': request.targetHttpsProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.setUrlMap(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves the list of all TargetHttpsProxy resources, regional and global, available to the specified project. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Name of the project scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.TargetHttpsProxiesScopedList | TargetHttpsProxiesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/target_https_proxies.aggregated_list.js + * region_tag:compute_v1_generated_TargetHttpsProxies_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListTargetHttpsProxiesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.ITargetHttpsProxiesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.ITargetHttpsProxiesScopedList]>; + } + /** + * Retrieves the list of TargetHttpsProxy resources available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetHttpsProxy | TargetHttpsProxy}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListTargetHttpsProxiesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetHttpsProxy[], + protos.google.cloud.compute.v1.IListTargetHttpsProxiesRequest|null, + protos.google.cloud.compute.v1.ITargetHttpsProxyList + ]>; + list( + request: protos.google.cloud.compute.v1.IListTargetHttpsProxiesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetHttpsProxiesRequest, + protos.google.cloud.compute.v1.ITargetHttpsProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetHttpsProxy>): void; + list( + request: protos.google.cloud.compute.v1.IListTargetHttpsProxiesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetHttpsProxiesRequest, + protos.google.cloud.compute.v1.ITargetHttpsProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetHttpsProxy>): void; + list( + request?: protos.google.cloud.compute.v1.IListTargetHttpsProxiesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListTargetHttpsProxiesRequest, + protos.google.cloud.compute.v1.ITargetHttpsProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetHttpsProxy>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetHttpsProxiesRequest, + protos.google.cloud.compute.v1.ITargetHttpsProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetHttpsProxy>): + Promise<[ + protos.google.cloud.compute.v1.ITargetHttpsProxy[], + protos.google.cloud.compute.v1.IListTargetHttpsProxiesRequest|null, + protos.google.cloud.compute.v1.ITargetHttpsProxyList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetHttpsProxy | TargetHttpsProxy} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListTargetHttpsProxiesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.TargetHttpsProxy | TargetHttpsProxy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/target_https_proxies.list.js + * region_tag:compute_v1_generated_TargetHttpsProxies_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListTargetHttpsProxiesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.targetHttpsProxiesStub && !this._terminated) { + return this.targetHttpsProxiesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_https_proxies_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_https_proxies_client_config.json new file mode 100644 index 00000000000..69a436fb527 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_https_proxies_client_config.json @@ -0,0 +1,70 @@ +{ + "interfaces": { + "google.cloud.compute.v1.TargetHttpsProxies": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetCertificateMap": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetQuicOverride": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetSslCertificates": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetSslPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetUrlMap": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_https_proxies_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_https_proxies_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_https_proxies_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_instances_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_instances_client.ts new file mode 100644 index 00000000000..e5c3d398c49 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_instances_client.ts @@ -0,0 +1,833 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/target_instances_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './target_instances_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The TargetInstances API. + * @class + * @memberof v1 + */ +export class TargetInstancesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + targetInstancesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TargetInstancesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new TargetInstancesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof TargetInstancesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.TargetInstances', 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.targetInstancesStub) { + return this.targetInstancesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.TargetInstances. + this.targetInstancesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.TargetInstances') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.TargetInstances, + 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 targetInstancesStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'list']; + for (const methodName of targetInstancesStubMethods) { + const callPromise = this.targetInstancesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.targetInstancesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified TargetInstance resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetInstance + * Name of the TargetInstance resource to delete. + * @param {string} request.zone + * Name of the zone scoping this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_instances.delete.js + * region_tag:compute_v1_generated_TargetInstances_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteTargetInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteTargetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetInstanceRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteTargetInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetInstanceRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteTargetInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'target_instance': request.targetInstance ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified TargetInstance resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.targetInstance + * Name of the TargetInstance resource to return. + * @param {string} request.zone + * Name of the zone scoping this request. + * @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.compute.v1.TargetInstance | TargetInstance}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/target_instances.get.js + * region_tag:compute_v1_generated_TargetInstances_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetTargetInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetInstance, + protos.google.cloud.compute.v1.IGetTargetInstanceRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetTargetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITargetInstance, + protos.google.cloud.compute.v1.IGetTargetInstanceRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetTargetInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITargetInstance, + protos.google.cloud.compute.v1.IGetTargetInstanceRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetTargetInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITargetInstance, + protos.google.cloud.compute.v1.IGetTargetInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITargetInstance, + protos.google.cloud.compute.v1.IGetTargetInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITargetInstance, + protos.google.cloud.compute.v1.IGetTargetInstanceRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'target_instance': request.targetInstance ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a TargetInstance resource in the specified project and zone using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetInstance} request.targetInstanceResource + * The body resource for this request + * @param {string} request.zone + * Name of the zone scoping this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_instances.insert.js + * region_tag:compute_v1_generated_TargetInstances_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertTargetInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertTargetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetInstanceRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertTargetInstanceRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetInstanceRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertTargetInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves an aggregated list of target instances. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.TargetInstancesScopedList | TargetInstancesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/target_instances.aggregated_list.js + * region_tag:compute_v1_generated_TargetInstances_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListTargetInstancesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.ITargetInstancesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.ITargetInstancesScopedList]>; + } + /** + * Retrieves a list of TargetInstance resources available to the specified project and zone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * Name of the zone scoping this request. + * @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 google.cloud.compute.v1.TargetInstance | TargetInstance}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListTargetInstancesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetInstance[], + protos.google.cloud.compute.v1.IListTargetInstancesRequest|null, + protos.google.cloud.compute.v1.ITargetInstanceList + ]>; + list( + request: protos.google.cloud.compute.v1.IListTargetInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetInstancesRequest, + protos.google.cloud.compute.v1.ITargetInstanceList|null|undefined, + protos.google.cloud.compute.v1.ITargetInstance>): void; + list( + request: protos.google.cloud.compute.v1.IListTargetInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetInstancesRequest, + protos.google.cloud.compute.v1.ITargetInstanceList|null|undefined, + protos.google.cloud.compute.v1.ITargetInstance>): void; + list( + request?: protos.google.cloud.compute.v1.IListTargetInstancesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListTargetInstancesRequest, + protos.google.cloud.compute.v1.ITargetInstanceList|null|undefined, + protos.google.cloud.compute.v1.ITargetInstance>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetInstancesRequest, + protos.google.cloud.compute.v1.ITargetInstanceList|null|undefined, + protos.google.cloud.compute.v1.ITargetInstance>): + Promise<[ + protos.google.cloud.compute.v1.ITargetInstance[], + protos.google.cloud.compute.v1.IListTargetInstancesRequest|null, + protos.google.cloud.compute.v1.ITargetInstanceList + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * Name of the zone scoping this request. + * @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 google.cloud.compute.v1.TargetInstance | TargetInstance} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListTargetInstancesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * Name of the zone scoping this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.TargetInstance | TargetInstance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/target_instances.list.js + * region_tag:compute_v1_generated_TargetInstances_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListTargetInstancesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.targetInstancesStub && !this._terminated) { + return this.targetInstancesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_instances_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_instances_client_config.json new file mode 100644 index 00000000000..b56ce469278 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_instances_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.compute.v1.TargetInstances": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_instances_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_instances_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_instances_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_pools_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_pools_client.ts new file mode 100644 index 00000000000..e14f28c53f6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_pools_client.ts @@ -0,0 +1,1379 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/target_pools_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './target_pools_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The TargetPools API. + * @class + * @memberof v1 + */ +export class TargetPoolsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + targetPoolsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TargetPoolsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new TargetPoolsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof TargetPoolsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.TargetPools', 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.targetPoolsStub) { + return this.targetPoolsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.TargetPools. + this.targetPoolsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.TargetPools') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.TargetPools, + 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 targetPoolsStubMethods = + ['addHealthCheck', 'addInstance', 'aggregatedList', 'delete', 'get', 'getHealth', 'insert', 'list', 'removeHealthCheck', 'removeInstance', 'setBackup']; + for (const methodName of targetPoolsStubMethods) { + const callPromise = this.targetPoolsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.targetPoolsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Adds health check URLs to a target pool. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetPool + * Name of the target pool to add a health check to. + * @param {google.cloud.compute.v1.TargetPoolsAddHealthCheckRequest} request.targetPoolsAddHealthCheckRequestResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_pools.add_health_check.js + * region_tag:compute_v1_generated_TargetPools_AddHealthCheck_async + */ + addHealthCheck( + request?: protos.google.cloud.compute.v1.IAddHealthCheckTargetPoolRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addHealthCheck( + request: protos.google.cloud.compute.v1.IAddHealthCheckTargetPoolRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddHealthCheckTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + addHealthCheck( + request: protos.google.cloud.compute.v1.IAddHealthCheckTargetPoolRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddHealthCheckTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + addHealthCheck( + request?: protos.google.cloud.compute.v1.IAddHealthCheckTargetPoolRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddHealthCheckTargetPoolRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddHealthCheckTargetPoolRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_pool': request.targetPool ?? '', + }); + this.initialize(); + return this.innerApiCalls.addHealthCheck(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Adds an instance to a target pool. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetPool + * Name of the TargetPool resource to add instances to. + * @param {google.cloud.compute.v1.TargetPoolsAddInstanceRequest} request.targetPoolsAddInstanceRequestResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_pools.add_instance.js + * region_tag:compute_v1_generated_TargetPools_AddInstance_async + */ + addInstance( + request?: protos.google.cloud.compute.v1.IAddInstanceTargetPoolRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + addInstance( + request: protos.google.cloud.compute.v1.IAddInstanceTargetPoolRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddInstanceTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + addInstance( + request: protos.google.cloud.compute.v1.IAddInstanceTargetPoolRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddInstanceTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + addInstance( + request?: protos.google.cloud.compute.v1.IAddInstanceTargetPoolRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddInstanceTargetPoolRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IAddInstanceTargetPoolRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_pool': request.targetPool ?? '', + }); + this.initialize(); + return this.innerApiCalls.addInstance(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Deletes the specified target pool. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetPool + * Name of the TargetPool resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_pools.delete.js + * region_tag:compute_v1_generated_TargetPools_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteTargetPoolRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteTargetPoolRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteTargetPoolRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteTargetPoolRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetPoolRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetPoolRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_pool': request.targetPool ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified target pool. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.targetPool + * Name of the TargetPool resource to return. + * @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.compute.v1.TargetPool | TargetPool}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/target_pools.get.js + * region_tag:compute_v1_generated_TargetPools_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetTargetPoolRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetPool, + protos.google.cloud.compute.v1.IGetTargetPoolRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetTargetPoolRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITargetPool, + protos.google.cloud.compute.v1.IGetTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetTargetPoolRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITargetPool, + protos.google.cloud.compute.v1.IGetTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetTargetPoolRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITargetPool, + protos.google.cloud.compute.v1.IGetTargetPoolRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITargetPool, + protos.google.cloud.compute.v1.IGetTargetPoolRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITargetPool, + protos.google.cloud.compute.v1.IGetTargetPoolRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_pool': request.targetPool ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Gets the most recent health check results for each IP for the instance that is referenced by the given target pool. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.InstanceReference} request.instanceReferenceResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.targetPool + * Name of the TargetPool resource to which the queried instance belongs. + * @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.compute.v1.TargetPoolInstanceHealth | TargetPoolInstanceHealth}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/target_pools.get_health.js + * region_tag:compute_v1_generated_TargetPools_GetHealth_async + */ + getHealth( + request?: protos.google.cloud.compute.v1.IGetHealthTargetPoolRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetPoolInstanceHealth, + protos.google.cloud.compute.v1.IGetHealthTargetPoolRequest|undefined, {}|undefined + ]>; + getHealth( + request: protos.google.cloud.compute.v1.IGetHealthTargetPoolRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITargetPoolInstanceHealth, + protos.google.cloud.compute.v1.IGetHealthTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + getHealth( + request: protos.google.cloud.compute.v1.IGetHealthTargetPoolRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITargetPoolInstanceHealth, + protos.google.cloud.compute.v1.IGetHealthTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + getHealth( + request?: protos.google.cloud.compute.v1.IGetHealthTargetPoolRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITargetPoolInstanceHealth, + protos.google.cloud.compute.v1.IGetHealthTargetPoolRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITargetPoolInstanceHealth, + protos.google.cloud.compute.v1.IGetHealthTargetPoolRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITargetPoolInstanceHealth, + protos.google.cloud.compute.v1.IGetHealthTargetPoolRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_pool': request.targetPool ?? '', + }); + this.initialize(); + return this.innerApiCalls.getHealth(request, options, callback); + } +/** + * Creates a target pool in the specified project and region using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetPool} request.targetPoolResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_pools.insert.js + * region_tag:compute_v1_generated_TargetPools_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertTargetPoolRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertTargetPoolRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertTargetPoolRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertTargetPoolRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetPoolRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetPoolRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Removes health check URL from a target pool. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetPool + * Name of the target pool to remove health checks from. + * @param {google.cloud.compute.v1.TargetPoolsRemoveHealthCheckRequest} request.targetPoolsRemoveHealthCheckRequestResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_pools.remove_health_check.js + * region_tag:compute_v1_generated_TargetPools_RemoveHealthCheck_async + */ + removeHealthCheck( + request?: protos.google.cloud.compute.v1.IRemoveHealthCheckTargetPoolRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + removeHealthCheck( + request: protos.google.cloud.compute.v1.IRemoveHealthCheckTargetPoolRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveHealthCheckTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + removeHealthCheck( + request: protos.google.cloud.compute.v1.IRemoveHealthCheckTargetPoolRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveHealthCheckTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + removeHealthCheck( + request?: protos.google.cloud.compute.v1.IRemoveHealthCheckTargetPoolRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveHealthCheckTargetPoolRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveHealthCheckTargetPoolRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_pool': request.targetPool ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeHealthCheck(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Removes instance URL from a target pool. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetPool + * Name of the TargetPool resource to remove instances from. + * @param {google.cloud.compute.v1.TargetPoolsRemoveInstanceRequest} request.targetPoolsRemoveInstanceRequestResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_pools.remove_instance.js + * region_tag:compute_v1_generated_TargetPools_RemoveInstance_async + */ + removeInstance( + request?: protos.google.cloud.compute.v1.IRemoveInstanceTargetPoolRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + removeInstance( + request: protos.google.cloud.compute.v1.IRemoveInstanceTargetPoolRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveInstanceTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + removeInstance( + request: protos.google.cloud.compute.v1.IRemoveInstanceTargetPoolRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveInstanceTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + removeInstance( + request?: protos.google.cloud.compute.v1.IRemoveInstanceTargetPoolRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveInstanceTargetPoolRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IRemoveInstanceTargetPoolRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_pool': request.targetPool ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeInstance(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes a backup target pool's configurations. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.failoverRatio + * New failoverRatio value for the target pool. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetPool + * Name of the TargetPool resource to set a backup pool for. + * @param {google.cloud.compute.v1.TargetReference} request.targetReferenceResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_pools.set_backup.js + * region_tag:compute_v1_generated_TargetPools_SetBackup_async + */ + setBackup( + request?: protos.google.cloud.compute.v1.ISetBackupTargetPoolRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setBackup( + request: protos.google.cloud.compute.v1.ISetBackupTargetPoolRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetBackupTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + setBackup( + request: protos.google.cloud.compute.v1.ISetBackupTargetPoolRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetBackupTargetPoolRequest|null|undefined, + {}|null|undefined>): void; + setBackup( + request?: protos.google.cloud.compute.v1.ISetBackupTargetPoolRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetBackupTargetPoolRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetBackupTargetPoolRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_pool': request.targetPool ?? '', + }); + this.initialize(); + return this.innerApiCalls.setBackup(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves an aggregated list of target pools. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.TargetPoolsScopedList | TargetPoolsScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/target_pools.aggregated_list.js + * region_tag:compute_v1_generated_TargetPools_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListTargetPoolsRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.ITargetPoolsScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.ITargetPoolsScopedList]>; + } + /** + * Retrieves a list of target pools available to the specified project and region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetPool | TargetPool}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListTargetPoolsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetPool[], + protos.google.cloud.compute.v1.IListTargetPoolsRequest|null, + protos.google.cloud.compute.v1.ITargetPoolList + ]>; + list( + request: protos.google.cloud.compute.v1.IListTargetPoolsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetPoolsRequest, + protos.google.cloud.compute.v1.ITargetPoolList|null|undefined, + protos.google.cloud.compute.v1.ITargetPool>): void; + list( + request: protos.google.cloud.compute.v1.IListTargetPoolsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetPoolsRequest, + protos.google.cloud.compute.v1.ITargetPoolList|null|undefined, + protos.google.cloud.compute.v1.ITargetPool>): void; + list( + request?: protos.google.cloud.compute.v1.IListTargetPoolsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListTargetPoolsRequest, + protos.google.cloud.compute.v1.ITargetPoolList|null|undefined, + protos.google.cloud.compute.v1.ITargetPool>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetPoolsRequest, + protos.google.cloud.compute.v1.ITargetPoolList|null|undefined, + protos.google.cloud.compute.v1.ITargetPool>): + Promise<[ + protos.google.cloud.compute.v1.ITargetPool[], + protos.google.cloud.compute.v1.IListTargetPoolsRequest|null, + protos.google.cloud.compute.v1.ITargetPoolList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetPool | TargetPool} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListTargetPoolsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.TargetPool | TargetPool}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/target_pools.list.js + * region_tag:compute_v1_generated_TargetPools_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListTargetPoolsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.targetPoolsStub && !this._terminated) { + return this.targetPoolsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_pools_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_pools_client_config.json new file mode 100644 index 00000000000..1fe0572fc54 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_pools_client_config.json @@ -0,0 +1,70 @@ +{ + "interfaces": { + "google.cloud.compute.v1.TargetPools": { + "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": { + "AddHealthCheck": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AddInstance": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetHealth": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveHealthCheck": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveInstance": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetBackup": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_pools_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_pools_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_pools_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_ssl_proxies_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_ssl_proxies_client.ts new file mode 100644 index 00000000000..7aeccefb66b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_ssl_proxies_client.ts @@ -0,0 +1,1207 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/target_ssl_proxies_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './target_ssl_proxies_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The TargetSslProxies API. + * @class + * @memberof v1 + */ +export class TargetSslProxiesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + targetSslProxiesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TargetSslProxiesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new TargetSslProxiesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof TargetSslProxiesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.TargetSslProxies', 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.targetSslProxiesStub) { + return this.targetSslProxiesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.TargetSslProxies. + this.targetSslProxiesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.TargetSslProxies') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.TargetSslProxies, + 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 targetSslProxiesStubMethods = + ['delete', 'get', 'insert', 'list', 'setBackendService', 'setCertificateMap', 'setProxyHeader', 'setSslCertificates', 'setSslPolicy']; + for (const methodName of targetSslProxiesStubMethods) { + const callPromise = this.targetSslProxiesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.targetSslProxiesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified TargetSslProxy resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetSslProxy + * Name of the TargetSslProxy resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_ssl_proxies.delete.js + * region_tag:compute_v1_generated_TargetSslProxies_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteTargetSslProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteTargetSslProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetSslProxyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteTargetSslProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetSslProxyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteTargetSslProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetSslProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetSslProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_ssl_proxy': request.targetSslProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified TargetSslProxy resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.targetSslProxy + * Name of the TargetSslProxy resource to return. + * @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.compute.v1.TargetSslProxy | TargetSslProxy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/target_ssl_proxies.get.js + * region_tag:compute_v1_generated_TargetSslProxies_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetTargetSslProxyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetSslProxy, + protos.google.cloud.compute.v1.IGetTargetSslProxyRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetTargetSslProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITargetSslProxy, + protos.google.cloud.compute.v1.IGetTargetSslProxyRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetTargetSslProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITargetSslProxy, + protos.google.cloud.compute.v1.IGetTargetSslProxyRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetTargetSslProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITargetSslProxy, + protos.google.cloud.compute.v1.IGetTargetSslProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITargetSslProxy, + protos.google.cloud.compute.v1.IGetTargetSslProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITargetSslProxy, + protos.google.cloud.compute.v1.IGetTargetSslProxyRequest|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({ + 'project': request.project ?? '', + 'target_ssl_proxy': request.targetSslProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a TargetSslProxy resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetSslProxy} request.targetSslProxyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_ssl_proxies.insert.js + * region_tag:compute_v1_generated_TargetSslProxies_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertTargetSslProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertTargetSslProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetSslProxyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertTargetSslProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetSslProxyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertTargetSslProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetSslProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetSslProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes the BackendService for TargetSslProxy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetSslProxiesSetBackendServiceRequest} request.targetSslProxiesSetBackendServiceRequestResource + * The body resource for this request + * @param {string} request.targetSslProxy + * Name of the TargetSslProxy resource whose BackendService resource is to be set. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_ssl_proxies.set_backend_service.js + * region_tag:compute_v1_generated_TargetSslProxies_SetBackendService_async + */ + setBackendService( + request?: protos.google.cloud.compute.v1.ISetBackendServiceTargetSslProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setBackendService( + request: protos.google.cloud.compute.v1.ISetBackendServiceTargetSslProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetBackendServiceTargetSslProxyRequest|null|undefined, + {}|null|undefined>): void; + setBackendService( + request: protos.google.cloud.compute.v1.ISetBackendServiceTargetSslProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetBackendServiceTargetSslProxyRequest|null|undefined, + {}|null|undefined>): void; + setBackendService( + request?: protos.google.cloud.compute.v1.ISetBackendServiceTargetSslProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetBackendServiceTargetSslProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetBackendServiceTargetSslProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_ssl_proxy': request.targetSslProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.setBackendService(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes the Certificate Map for TargetSslProxy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetSslProxiesSetCertificateMapRequest} request.targetSslProxiesSetCertificateMapRequestResource + * The body resource for this request + * @param {string} request.targetSslProxy + * Name of the TargetSslProxy resource whose CertificateMap is to be set. The name must be 1-63 characters long, and comply with RFC1035. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_ssl_proxies.set_certificate_map.js + * region_tag:compute_v1_generated_TargetSslProxies_SetCertificateMap_async + */ + setCertificateMap( + request?: protos.google.cloud.compute.v1.ISetCertificateMapTargetSslProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setCertificateMap( + request: protos.google.cloud.compute.v1.ISetCertificateMapTargetSslProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetCertificateMapTargetSslProxyRequest|null|undefined, + {}|null|undefined>): void; + setCertificateMap( + request: protos.google.cloud.compute.v1.ISetCertificateMapTargetSslProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetCertificateMapTargetSslProxyRequest|null|undefined, + {}|null|undefined>): void; + setCertificateMap( + request?: protos.google.cloud.compute.v1.ISetCertificateMapTargetSslProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetCertificateMapTargetSslProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetCertificateMapTargetSslProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_ssl_proxy': request.targetSslProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.setCertificateMap(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes the ProxyHeaderType for TargetSslProxy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetSslProxiesSetProxyHeaderRequest} request.targetSslProxiesSetProxyHeaderRequestResource + * The body resource for this request + * @param {string} request.targetSslProxy + * Name of the TargetSslProxy resource whose ProxyHeader is to be set. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_ssl_proxies.set_proxy_header.js + * region_tag:compute_v1_generated_TargetSslProxies_SetProxyHeader_async + */ + setProxyHeader( + request?: protos.google.cloud.compute.v1.ISetProxyHeaderTargetSslProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setProxyHeader( + request: protos.google.cloud.compute.v1.ISetProxyHeaderTargetSslProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetProxyHeaderTargetSslProxyRequest|null|undefined, + {}|null|undefined>): void; + setProxyHeader( + request: protos.google.cloud.compute.v1.ISetProxyHeaderTargetSslProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetProxyHeaderTargetSslProxyRequest|null|undefined, + {}|null|undefined>): void; + setProxyHeader( + request?: protos.google.cloud.compute.v1.ISetProxyHeaderTargetSslProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetProxyHeaderTargetSslProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetProxyHeaderTargetSslProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_ssl_proxy': request.targetSslProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.setProxyHeader(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes SslCertificates for TargetSslProxy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetSslProxiesSetSslCertificatesRequest} request.targetSslProxiesSetSslCertificatesRequestResource + * The body resource for this request + * @param {string} request.targetSslProxy + * Name of the TargetSslProxy resource whose SslCertificate resource is to be set. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_ssl_proxies.set_ssl_certificates.js + * region_tag:compute_v1_generated_TargetSslProxies_SetSslCertificates_async + */ + setSslCertificates( + request?: protos.google.cloud.compute.v1.ISetSslCertificatesTargetSslProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setSslCertificates( + request: protos.google.cloud.compute.v1.ISetSslCertificatesTargetSslProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslCertificatesTargetSslProxyRequest|null|undefined, + {}|null|undefined>): void; + setSslCertificates( + request: protos.google.cloud.compute.v1.ISetSslCertificatesTargetSslProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslCertificatesTargetSslProxyRequest|null|undefined, + {}|null|undefined>): void; + setSslCertificates( + request?: protos.google.cloud.compute.v1.ISetSslCertificatesTargetSslProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslCertificatesTargetSslProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslCertificatesTargetSslProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_ssl_proxy': request.targetSslProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.setSslCertificates(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the SSL policy for TargetSslProxy. The SSL policy specifies the server-side support for SSL features. This affects connections between clients and the SSL proxy load balancer. They do not affect the connection between the load balancer and the backends. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.SslPolicyReference} request.sslPolicyReferenceResource + * The body resource for this request + * @param {string} request.targetSslProxy + * Name of the TargetSslProxy resource whose SSL policy is to be set. The name must be 1-63 characters long, and comply with RFC1035. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_ssl_proxies.set_ssl_policy.js + * region_tag:compute_v1_generated_TargetSslProxies_SetSslPolicy_async + */ + setSslPolicy( + request?: protos.google.cloud.compute.v1.ISetSslPolicyTargetSslProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setSslPolicy( + request: protos.google.cloud.compute.v1.ISetSslPolicyTargetSslProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslPolicyTargetSslProxyRequest|null|undefined, + {}|null|undefined>): void; + setSslPolicy( + request: protos.google.cloud.compute.v1.ISetSslPolicyTargetSslProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslPolicyTargetSslProxyRequest|null|undefined, + {}|null|undefined>): void; + setSslPolicy( + request?: protos.google.cloud.compute.v1.ISetSslPolicyTargetSslProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslPolicyTargetSslProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetSslPolicyTargetSslProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_ssl_proxy': request.targetSslProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.setSslPolicy(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + /** + * Retrieves the list of TargetSslProxy resources available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetSslProxy | TargetSslProxy}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListTargetSslProxiesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetSslProxy[], + protos.google.cloud.compute.v1.IListTargetSslProxiesRequest|null, + protos.google.cloud.compute.v1.ITargetSslProxyList + ]>; + list( + request: protos.google.cloud.compute.v1.IListTargetSslProxiesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetSslProxiesRequest, + protos.google.cloud.compute.v1.ITargetSslProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetSslProxy>): void; + list( + request: protos.google.cloud.compute.v1.IListTargetSslProxiesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetSslProxiesRequest, + protos.google.cloud.compute.v1.ITargetSslProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetSslProxy>): void; + list( + request?: protos.google.cloud.compute.v1.IListTargetSslProxiesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListTargetSslProxiesRequest, + protos.google.cloud.compute.v1.ITargetSslProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetSslProxy>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetSslProxiesRequest, + protos.google.cloud.compute.v1.ITargetSslProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetSslProxy>): + Promise<[ + protos.google.cloud.compute.v1.ITargetSslProxy[], + protos.google.cloud.compute.v1.IListTargetSslProxiesRequest|null, + protos.google.cloud.compute.v1.ITargetSslProxyList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetSslProxy | TargetSslProxy} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListTargetSslProxiesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.TargetSslProxy | TargetSslProxy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/target_ssl_proxies.list.js + * region_tag:compute_v1_generated_TargetSslProxies_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListTargetSslProxiesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.targetSslProxiesStub && !this._terminated) { + return this.targetSslProxiesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_ssl_proxies_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_ssl_proxies_client_config.json new file mode 100644 index 00000000000..2294fb9528b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_ssl_proxies_client_config.json @@ -0,0 +1,62 @@ +{ + "interfaces": { + "google.cloud.compute.v1.TargetSslProxies": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetBackendService": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetCertificateMap": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetProxyHeader": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetSslCertificates": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetSslPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_ssl_proxies_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_ssl_proxies_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_ssl_proxies_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_tcp_proxies_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_tcp_proxies_client.ts new file mode 100644 index 00000000000..4e765ab4b13 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_tcp_proxies_client.ts @@ -0,0 +1,995 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/target_tcp_proxies_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './target_tcp_proxies_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The TargetTcpProxies API. + * @class + * @memberof v1 + */ +export class TargetTcpProxiesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + targetTcpProxiesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TargetTcpProxiesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new TargetTcpProxiesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof TargetTcpProxiesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.TargetTcpProxies', 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.targetTcpProxiesStub) { + return this.targetTcpProxiesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.TargetTcpProxies. + this.targetTcpProxiesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.TargetTcpProxies') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.TargetTcpProxies, + 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 targetTcpProxiesStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'list', 'setBackendService', 'setProxyHeader']; + for (const methodName of targetTcpProxiesStubMethods) { + const callPromise = this.targetTcpProxiesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.targetTcpProxiesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified TargetTcpProxy resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetTcpProxy + * Name of the TargetTcpProxy resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_tcp_proxies.delete.js + * region_tag:compute_v1_generated_TargetTcpProxies_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteTargetTcpProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteTargetTcpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteTargetTcpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteTargetTcpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetTcpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_tcp_proxy': request.targetTcpProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified TargetTcpProxy resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.targetTcpProxy + * Name of the TargetTcpProxy resource to return. + * @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.compute.v1.TargetTcpProxy | TargetTcpProxy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/target_tcp_proxies.get.js + * region_tag:compute_v1_generated_TargetTcpProxies_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetTargetTcpProxyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetTcpProxy, + protos.google.cloud.compute.v1.IGetTargetTcpProxyRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetTargetTcpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITargetTcpProxy, + protos.google.cloud.compute.v1.IGetTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetTargetTcpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITargetTcpProxy, + protos.google.cloud.compute.v1.IGetTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetTargetTcpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITargetTcpProxy, + protos.google.cloud.compute.v1.IGetTargetTcpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITargetTcpProxy, + protos.google.cloud.compute.v1.IGetTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITargetTcpProxy, + protos.google.cloud.compute.v1.IGetTargetTcpProxyRequest|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({ + 'project': request.project ?? '', + 'target_tcp_proxy': request.targetTcpProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a TargetTcpProxy resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetTcpProxy} request.targetTcpProxyResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_tcp_proxies.insert.js + * region_tag:compute_v1_generated_TargetTcpProxies_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertTargetTcpProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertTargetTcpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertTargetTcpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertTargetTcpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetTcpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes the BackendService for TargetTcpProxy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetTcpProxiesSetBackendServiceRequest} request.targetTcpProxiesSetBackendServiceRequestResource + * The body resource for this request + * @param {string} request.targetTcpProxy + * Name of the TargetTcpProxy resource whose BackendService resource is to be set. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_tcp_proxies.set_backend_service.js + * region_tag:compute_v1_generated_TargetTcpProxies_SetBackendService_async + */ + setBackendService( + request?: protos.google.cloud.compute.v1.ISetBackendServiceTargetTcpProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setBackendService( + request: protos.google.cloud.compute.v1.ISetBackendServiceTargetTcpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetBackendServiceTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): void; + setBackendService( + request: protos.google.cloud.compute.v1.ISetBackendServiceTargetTcpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetBackendServiceTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): void; + setBackendService( + request?: protos.google.cloud.compute.v1.ISetBackendServiceTargetTcpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetBackendServiceTargetTcpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetBackendServiceTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_tcp_proxy': request.targetTcpProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.setBackendService(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Changes the ProxyHeaderType for TargetTcpProxy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetTcpProxiesSetProxyHeaderRequest} request.targetTcpProxiesSetProxyHeaderRequestResource + * The body resource for this request + * @param {string} request.targetTcpProxy + * Name of the TargetTcpProxy resource whose ProxyHeader is to be set. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_tcp_proxies.set_proxy_header.js + * region_tag:compute_v1_generated_TargetTcpProxies_SetProxyHeader_async + */ + setProxyHeader( + request?: protos.google.cloud.compute.v1.ISetProxyHeaderTargetTcpProxyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setProxyHeader( + request: protos.google.cloud.compute.v1.ISetProxyHeaderTargetTcpProxyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetProxyHeaderTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): void; + setProxyHeader( + request: protos.google.cloud.compute.v1.ISetProxyHeaderTargetTcpProxyRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetProxyHeaderTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): void; + setProxyHeader( + request?: protos.google.cloud.compute.v1.ISetProxyHeaderTargetTcpProxyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetProxyHeaderTargetTcpProxyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetProxyHeaderTargetTcpProxyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'target_tcp_proxy': request.targetTcpProxy ?? '', + }); + this.initialize(); + return this.innerApiCalls.setProxyHeader(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves the list of all TargetTcpProxy resources, regional and global, available to the specified project. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Name of the project scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.TargetTcpProxiesScopedList | TargetTcpProxiesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/target_tcp_proxies.aggregated_list.js + * region_tag:compute_v1_generated_TargetTcpProxies_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListTargetTcpProxiesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.ITargetTcpProxiesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.ITargetTcpProxiesScopedList]>; + } + /** + * Retrieves the list of TargetTcpProxy resources available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetTcpProxy | TargetTcpProxy}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListTargetTcpProxiesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetTcpProxy[], + protos.google.cloud.compute.v1.IListTargetTcpProxiesRequest|null, + protos.google.cloud.compute.v1.ITargetTcpProxyList + ]>; + list( + request: protos.google.cloud.compute.v1.IListTargetTcpProxiesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetTcpProxiesRequest, + protos.google.cloud.compute.v1.ITargetTcpProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetTcpProxy>): void; + list( + request: protos.google.cloud.compute.v1.IListTargetTcpProxiesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetTcpProxiesRequest, + protos.google.cloud.compute.v1.ITargetTcpProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetTcpProxy>): void; + list( + request?: protos.google.cloud.compute.v1.IListTargetTcpProxiesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListTargetTcpProxiesRequest, + protos.google.cloud.compute.v1.ITargetTcpProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetTcpProxy>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetTcpProxiesRequest, + protos.google.cloud.compute.v1.ITargetTcpProxyList|null|undefined, + protos.google.cloud.compute.v1.ITargetTcpProxy>): + Promise<[ + protos.google.cloud.compute.v1.ITargetTcpProxy[], + protos.google.cloud.compute.v1.IListTargetTcpProxiesRequest|null, + protos.google.cloud.compute.v1.ITargetTcpProxyList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetTcpProxy | TargetTcpProxy} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListTargetTcpProxiesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.TargetTcpProxy | TargetTcpProxy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/target_tcp_proxies.list.js + * region_tag:compute_v1_generated_TargetTcpProxies_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListTargetTcpProxiesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.targetTcpProxiesStub && !this._terminated) { + return this.targetTcpProxiesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_tcp_proxies_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_tcp_proxies_client_config.json new file mode 100644 index 00000000000..929bd938cb6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_tcp_proxies_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.compute.v1.TargetTcpProxies": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetBackendService": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetProxyHeader": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_tcp_proxies_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_tcp_proxies_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_tcp_proxies_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_vpn_gateways_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_vpn_gateways_client.ts new file mode 100644 index 00000000000..a5ceff23139 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_vpn_gateways_client.ts @@ -0,0 +1,926 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/target_vpn_gateways_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './target_vpn_gateways_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The TargetVpnGateways API. + * @class + * @memberof v1 + */ +export class TargetVpnGatewaysClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + targetVpnGatewaysStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TargetVpnGatewaysClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new TargetVpnGatewaysClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof TargetVpnGatewaysClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.TargetVpnGateways', 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.targetVpnGatewaysStub) { + return this.targetVpnGatewaysStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.TargetVpnGateways. + this.targetVpnGatewaysStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.TargetVpnGateways') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.TargetVpnGateways, + 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 targetVpnGatewaysStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'list', 'setLabels']; + for (const methodName of targetVpnGatewaysStubMethods) { + const callPromise = this.targetVpnGatewaysStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.targetVpnGatewaysStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified target VPN gateway. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.targetVpnGateway + * Name of the target VPN gateway to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_vpn_gateways.delete.js + * region_tag:compute_v1_generated_TargetVpnGateways_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteTargetVpnGatewayRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteTargetVpnGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteTargetVpnGatewayRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteTargetVpnGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetVpnGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteTargetVpnGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_vpn_gateway': request.targetVpnGateway ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified target VPN gateway. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.targetVpnGateway + * Name of the target VPN gateway to return. + * @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.compute.v1.TargetVpnGateway | TargetVpnGateway}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/target_vpn_gateways.get.js + * region_tag:compute_v1_generated_TargetVpnGateways_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetTargetVpnGatewayRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetVpnGateway, + protos.google.cloud.compute.v1.IGetTargetVpnGatewayRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetTargetVpnGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITargetVpnGateway, + protos.google.cloud.compute.v1.IGetTargetVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetTargetVpnGatewayRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITargetVpnGateway, + protos.google.cloud.compute.v1.IGetTargetVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetTargetVpnGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITargetVpnGateway, + protos.google.cloud.compute.v1.IGetTargetVpnGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITargetVpnGateway, + protos.google.cloud.compute.v1.IGetTargetVpnGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITargetVpnGateway, + protos.google.cloud.compute.v1.IGetTargetVpnGatewayRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'target_vpn_gateway': request.targetVpnGateway ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a target VPN gateway in the specified project and region using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.TargetVpnGateway} request.targetVpnGatewayResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_vpn_gateways.insert.js + * region_tag:compute_v1_generated_TargetVpnGateways_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertTargetVpnGatewayRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertTargetVpnGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertTargetVpnGatewayRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertTargetVpnGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetVpnGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertTargetVpnGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the labels on a TargetVpnGateway. To learn more about labels, read the Labeling Resources documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The region for this request. + * @param {google.cloud.compute.v1.RegionSetLabelsRequest} request.regionSetLabelsRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.resource + * Name or id of the resource for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/target_vpn_gateways.set_labels.js + * region_tag:compute_v1_generated_TargetVpnGateways_SetLabels_async + */ + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsTargetVpnGatewayRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsTargetVpnGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsTargetVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsTargetVpnGatewayRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsTargetVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsTargetVpnGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsTargetVpnGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsTargetVpnGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setLabels(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves an aggregated list of target VPN gateways. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.TargetVpnGatewaysScopedList | TargetVpnGatewaysScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/target_vpn_gateways.aggregated_list.js + * region_tag:compute_v1_generated_TargetVpnGateways_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListTargetVpnGatewaysRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.ITargetVpnGatewaysScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.ITargetVpnGatewaysScopedList]>; + } + /** + * Retrieves a list of target VPN gateways available to the specified project and region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetVpnGateway | TargetVpnGateway}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListTargetVpnGatewaysRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITargetVpnGateway[], + protos.google.cloud.compute.v1.IListTargetVpnGatewaysRequest|null, + protos.google.cloud.compute.v1.ITargetVpnGatewayList + ]>; + list( + request: protos.google.cloud.compute.v1.IListTargetVpnGatewaysRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetVpnGatewaysRequest, + protos.google.cloud.compute.v1.ITargetVpnGatewayList|null|undefined, + protos.google.cloud.compute.v1.ITargetVpnGateway>): void; + list( + request: protos.google.cloud.compute.v1.IListTargetVpnGatewaysRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetVpnGatewaysRequest, + protos.google.cloud.compute.v1.ITargetVpnGatewayList|null|undefined, + protos.google.cloud.compute.v1.ITargetVpnGateway>): void; + list( + request?: protos.google.cloud.compute.v1.IListTargetVpnGatewaysRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListTargetVpnGatewaysRequest, + protos.google.cloud.compute.v1.ITargetVpnGatewayList|null|undefined, + protos.google.cloud.compute.v1.ITargetVpnGateway>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListTargetVpnGatewaysRequest, + protos.google.cloud.compute.v1.ITargetVpnGatewayList|null|undefined, + protos.google.cloud.compute.v1.ITargetVpnGateway>): + Promise<[ + protos.google.cloud.compute.v1.ITargetVpnGateway[], + protos.google.cloud.compute.v1.IListTargetVpnGatewaysRequest|null, + protos.google.cloud.compute.v1.ITargetVpnGatewayList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.TargetVpnGateway | TargetVpnGateway} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListTargetVpnGatewaysRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.TargetVpnGateway | TargetVpnGateway}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/target_vpn_gateways.list.js + * region_tag:compute_v1_generated_TargetVpnGateways_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListTargetVpnGatewaysRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.targetVpnGatewaysStub && !this._terminated) { + return this.targetVpnGatewaysStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_vpn_gateways_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_vpn_gateways_client_config.json new file mode 100644 index 00000000000..e16879a4f21 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_vpn_gateways_client_config.json @@ -0,0 +1,50 @@ +{ + "interfaces": { + "google.cloud.compute.v1.TargetVpnGateways": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetLabels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/target_vpn_gateways_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_vpn_gateways_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/target_vpn_gateways_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/url_maps_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/url_maps_client.ts new file mode 100644 index 00000000000..a7859928b88 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/url_maps_client.ts @@ -0,0 +1,1161 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/url_maps_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './url_maps_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The UrlMaps API. + * @class + * @memberof v1 + */ +export class UrlMapsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + urlMapsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of UrlMapsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new UrlMapsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof UrlMapsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.UrlMaps', 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.urlMapsStub) { + return this.urlMapsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.UrlMaps. + this.urlMapsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.UrlMaps') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.UrlMaps, + 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 urlMapsStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'invalidateCache', 'list', 'patch', 'update', 'validate']; + for (const methodName of urlMapsStubMethods) { + const callPromise = this.urlMapsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.urlMapsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified UrlMap resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.urlMap + * Name of the UrlMap resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/url_maps.delete.js + * region_tag:compute_v1_generated_UrlMaps_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteUrlMapRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteUrlMapRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteUrlMapRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteUrlMapRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteUrlMapRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteUrlMapRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteUrlMapRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteUrlMapRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'url_map': request.urlMap ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified UrlMap resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.urlMap + * Name of the UrlMap resource to return. + * @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.compute.v1.UrlMap | UrlMap}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/url_maps.get.js + * region_tag:compute_v1_generated_UrlMaps_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetUrlMapRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IUrlMap, + protos.google.cloud.compute.v1.IGetUrlMapRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetUrlMapRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IUrlMap, + protos.google.cloud.compute.v1.IGetUrlMapRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetUrlMapRequest, + callback: Callback< + protos.google.cloud.compute.v1.IUrlMap, + protos.google.cloud.compute.v1.IGetUrlMapRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetUrlMapRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IUrlMap, + protos.google.cloud.compute.v1.IGetUrlMapRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IUrlMap, + protos.google.cloud.compute.v1.IGetUrlMapRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IUrlMap, + protos.google.cloud.compute.v1.IGetUrlMapRequest|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({ + 'project': request.project ?? '', + 'url_map': request.urlMap ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a UrlMap resource in the specified project using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.UrlMap} request.urlMapResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/url_maps.insert.js + * region_tag:compute_v1_generated_UrlMaps_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertUrlMapRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertUrlMapRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertUrlMapRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertUrlMapRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertUrlMapRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertUrlMapRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertUrlMapRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertUrlMapRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Initiates a cache invalidation operation, invalidating the specified path, scoped to the specified UrlMap. For more information, see [Invalidating cached content](/cdn/docs/invalidating-cached-content). + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1.CacheInvalidationRule} request.cacheInvalidationRuleResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.urlMap + * Name of the UrlMap scoping this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/url_maps.invalidate_cache.js + * region_tag:compute_v1_generated_UrlMaps_InvalidateCache_async + */ + invalidateCache( + request?: protos.google.cloud.compute.v1.IInvalidateCacheUrlMapRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + invalidateCache( + request: protos.google.cloud.compute.v1.IInvalidateCacheUrlMapRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInvalidateCacheUrlMapRequest|null|undefined, + {}|null|undefined>): void; + invalidateCache( + request: protos.google.cloud.compute.v1.IInvalidateCacheUrlMapRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInvalidateCacheUrlMapRequest|null|undefined, + {}|null|undefined>): void; + invalidateCache( + request?: protos.google.cloud.compute.v1.IInvalidateCacheUrlMapRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInvalidateCacheUrlMapRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInvalidateCacheUrlMapRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'url_map': request.urlMap ?? '', + }); + this.initialize(); + return this.innerApiCalls.invalidateCache(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Patches the specified UrlMap resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.urlMap + * Name of the UrlMap resource to patch. + * @param {google.cloud.compute.v1.UrlMap} request.urlMapResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/url_maps.patch.js + * region_tag:compute_v1_generated_UrlMaps_Patch_async + */ + patch( + request?: protos.google.cloud.compute.v1.IPatchUrlMapRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + patch( + request: protos.google.cloud.compute.v1.IPatchUrlMapRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchUrlMapRequest|null|undefined, + {}|null|undefined>): void; + patch( + request: protos.google.cloud.compute.v1.IPatchUrlMapRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchUrlMapRequest|null|undefined, + {}|null|undefined>): void; + patch( + request?: protos.google.cloud.compute.v1.IPatchUrlMapRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchUrlMapRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IPatchUrlMapRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'url_map': request.urlMap ?? '', + }); + this.initialize(); + return this.innerApiCalls.patch(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Updates the specified UrlMap resource with the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.urlMap + * Name of the UrlMap resource to update. + * @param {google.cloud.compute.v1.UrlMap} request.urlMapResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/url_maps.update.js + * region_tag:compute_v1_generated_UrlMaps_Update_async + */ + update( + request?: protos.google.cloud.compute.v1.IUpdateUrlMapRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + update( + request: protos.google.cloud.compute.v1.IUpdateUrlMapRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateUrlMapRequest|null|undefined, + {}|null|undefined>): void; + update( + request: protos.google.cloud.compute.v1.IUpdateUrlMapRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateUrlMapRequest|null|undefined, + {}|null|undefined>): void; + update( + request?: protos.google.cloud.compute.v1.IUpdateUrlMapRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateUrlMapRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IUpdateUrlMapRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'url_map': request.urlMap ?? '', + }); + this.initialize(); + return this.innerApiCalls.update(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling this method does NOT create the UrlMap. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.urlMap + * Name of the UrlMap resource to be validated as. + * @param {google.cloud.compute.v1.UrlMapsValidateRequest} request.urlMapsValidateRequestResource + * The body resource for this request + * @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.compute.v1.UrlMapsValidateResponse | UrlMapsValidateResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/url_maps.validate.js + * region_tag:compute_v1_generated_UrlMaps_Validate_async + */ + validate( + request?: protos.google.cloud.compute.v1.IValidateUrlMapRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IUrlMapsValidateResponse, + protos.google.cloud.compute.v1.IValidateUrlMapRequest|undefined, {}|undefined + ]>; + validate( + request: protos.google.cloud.compute.v1.IValidateUrlMapRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IUrlMapsValidateResponse, + protos.google.cloud.compute.v1.IValidateUrlMapRequest|null|undefined, + {}|null|undefined>): void; + validate( + request: protos.google.cloud.compute.v1.IValidateUrlMapRequest, + callback: Callback< + protos.google.cloud.compute.v1.IUrlMapsValidateResponse, + protos.google.cloud.compute.v1.IValidateUrlMapRequest|null|undefined, + {}|null|undefined>): void; + validate( + request?: protos.google.cloud.compute.v1.IValidateUrlMapRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IUrlMapsValidateResponse, + protos.google.cloud.compute.v1.IValidateUrlMapRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IUrlMapsValidateResponse, + protos.google.cloud.compute.v1.IValidateUrlMapRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IUrlMapsValidateResponse, + protos.google.cloud.compute.v1.IValidateUrlMapRequest|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({ + 'project': request.project ?? '', + 'url_map': request.urlMap ?? '', + }); + this.initialize(); + return this.innerApiCalls.validate(request, options, callback); + } + + +/** + * Retrieves the list of all UrlMap resources, regional and global, available to the specified project. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Name of the project scoping this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.UrlMapsScopedList | UrlMapsScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/url_maps.aggregated_list.js + * region_tag:compute_v1_generated_UrlMaps_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListUrlMapsRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IUrlMapsScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IUrlMapsScopedList]>; + } + /** + * Retrieves the list of UrlMap resources available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.UrlMap | UrlMap}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListUrlMapsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IUrlMap[], + protos.google.cloud.compute.v1.IListUrlMapsRequest|null, + protos.google.cloud.compute.v1.IUrlMapList + ]>; + list( + request: protos.google.cloud.compute.v1.IListUrlMapsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListUrlMapsRequest, + protos.google.cloud.compute.v1.IUrlMapList|null|undefined, + protos.google.cloud.compute.v1.IUrlMap>): void; + list( + request: protos.google.cloud.compute.v1.IListUrlMapsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListUrlMapsRequest, + protos.google.cloud.compute.v1.IUrlMapList|null|undefined, + protos.google.cloud.compute.v1.IUrlMap>): void; + list( + request?: protos.google.cloud.compute.v1.IListUrlMapsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListUrlMapsRequest, + protos.google.cloud.compute.v1.IUrlMapList|null|undefined, + protos.google.cloud.compute.v1.IUrlMap>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListUrlMapsRequest, + protos.google.cloud.compute.v1.IUrlMapList|null|undefined, + protos.google.cloud.compute.v1.IUrlMap>): + Promise<[ + protos.google.cloud.compute.v1.IUrlMap[], + protos.google.cloud.compute.v1.IListUrlMapsRequest|null, + protos.google.cloud.compute.v1.IUrlMapList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.UrlMap | UrlMap} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListUrlMapsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.UrlMap | UrlMap}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/url_maps.list.js + * region_tag:compute_v1_generated_UrlMaps_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListUrlMapsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.urlMapsStub && !this._terminated) { + return this.urlMapsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/url_maps_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/url_maps_client_config.json new file mode 100644 index 00000000000..2bd3852aa48 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/url_maps_client_config.json @@ -0,0 +1,62 @@ +{ + "interfaces": { + "google.cloud.compute.v1.UrlMaps": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "InvalidateCache": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Patch": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Update": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Validate": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/url_maps_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/url_maps_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/url_maps_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_gateways_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_gateways_client.ts new file mode 100644 index 00000000000..32f880fd296 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_gateways_client.ts @@ -0,0 +1,1082 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/vpn_gateways_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './vpn_gateways_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The VpnGateways API. + * @class + * @memberof v1 + */ +export class VpnGatewaysClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + vpnGatewaysStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of VpnGatewaysClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new VpnGatewaysClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof VpnGatewaysClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.VpnGateways', 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.vpnGatewaysStub) { + return this.vpnGatewaysStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.VpnGateways. + this.vpnGatewaysStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.VpnGateways') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.VpnGateways, + 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 vpnGatewaysStubMethods = + ['aggregatedList', 'delete', 'get', 'getStatus', 'insert', 'list', 'setLabels', 'testIamPermissions']; + for (const methodName of vpnGatewaysStubMethods) { + const callPromise = this.vpnGatewaysStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.vpnGatewaysStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified VPN gateway. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.vpnGateway + * Name of the VPN gateway to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/vpn_gateways.delete.js + * region_tag:compute_v1_generated_VpnGateways_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteVpnGatewayRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteVpnGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteVpnGatewayRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteVpnGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteVpnGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteVpnGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'vpn_gateway': request.vpnGateway ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified VPN gateway. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.vpnGateway + * Name of the VPN gateway to return. + * @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.compute.v1.VpnGateway | VpnGateway}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/vpn_gateways.get.js + * region_tag:compute_v1_generated_VpnGateways_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetVpnGatewayRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IVpnGateway, + protos.google.cloud.compute.v1.IGetVpnGatewayRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetVpnGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IVpnGateway, + protos.google.cloud.compute.v1.IGetVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetVpnGatewayRequest, + callback: Callback< + protos.google.cloud.compute.v1.IVpnGateway, + protos.google.cloud.compute.v1.IGetVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetVpnGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IVpnGateway, + protos.google.cloud.compute.v1.IGetVpnGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IVpnGateway, + protos.google.cloud.compute.v1.IGetVpnGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IVpnGateway, + protos.google.cloud.compute.v1.IGetVpnGatewayRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'vpn_gateway': request.vpnGateway ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Returns the status for the specified VPN gateway. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.vpnGateway + * Name of the VPN gateway to return. + * @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.compute.v1.VpnGatewaysGetStatusResponse | VpnGatewaysGetStatusResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/vpn_gateways.get_status.js + * region_tag:compute_v1_generated_VpnGateways_GetStatus_async + */ + getStatus( + request?: protos.google.cloud.compute.v1.IGetStatusVpnGatewayRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IVpnGatewaysGetStatusResponse, + protos.google.cloud.compute.v1.IGetStatusVpnGatewayRequest|undefined, {}|undefined + ]>; + getStatus( + request: protos.google.cloud.compute.v1.IGetStatusVpnGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IVpnGatewaysGetStatusResponse, + protos.google.cloud.compute.v1.IGetStatusVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + getStatus( + request: protos.google.cloud.compute.v1.IGetStatusVpnGatewayRequest, + callback: Callback< + protos.google.cloud.compute.v1.IVpnGatewaysGetStatusResponse, + protos.google.cloud.compute.v1.IGetStatusVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + getStatus( + request?: protos.google.cloud.compute.v1.IGetStatusVpnGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IVpnGatewaysGetStatusResponse, + protos.google.cloud.compute.v1.IGetStatusVpnGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IVpnGatewaysGetStatusResponse, + protos.google.cloud.compute.v1.IGetStatusVpnGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IVpnGatewaysGetStatusResponse, + protos.google.cloud.compute.v1.IGetStatusVpnGatewayRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'vpn_gateway': request.vpnGateway ?? '', + }); + this.initialize(); + return this.innerApiCalls.getStatus(request, options, callback); + } +/** + * Creates a VPN gateway in the specified project and region using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.VpnGateway} request.vpnGatewayResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/vpn_gateways.insert.js + * region_tag:compute_v1_generated_VpnGateways_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertVpnGatewayRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertVpnGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertVpnGatewayRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertVpnGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertVpnGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertVpnGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the labels on a VpnGateway. To learn more about labels, read the Labeling Resources documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The region for this request. + * @param {google.cloud.compute.v1.RegionSetLabelsRequest} request.regionSetLabelsRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.resource + * Name or id of the resource for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/vpn_gateways.set_labels.js + * region_tag:compute_v1_generated_VpnGateways_SetLabels_async + */ + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsVpnGatewayRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsVpnGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsVpnGatewayRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsVpnGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsVpnGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsVpnGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setLabels(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns permissions that a caller has on the specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The name of the region for this request. + * @param {string} request.resource + * Name or id of the resource for this request. + * @param {google.cloud.compute.v1.TestPermissionsRequest} request.testPermissionsRequestResource + * The body resource for this request + * @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.compute.v1.TestPermissionsResponse | TestPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/vpn_gateways.test_iam_permissions.js + * region_tag:compute_v1_generated_VpnGateways_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsVpnGatewayRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsVpnGatewayRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsVpnGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.cloud.compute.v1.ITestIamPermissionsVpnGatewayRequest, + callback: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsVpnGatewayRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.cloud.compute.v1.ITestIamPermissionsVpnGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsVpnGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsVpnGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.ITestPermissionsResponse, + protos.google.cloud.compute.v1.ITestIamPermissionsVpnGatewayRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + +/** + * Retrieves an aggregated list of VPN gateways. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.VpnGatewaysScopedList | VpnGatewaysScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/vpn_gateways.aggregated_list.js + * region_tag:compute_v1_generated_VpnGateways_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListVpnGatewaysRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IVpnGatewaysScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IVpnGatewaysScopedList]>; + } + /** + * Retrieves a list of VPN gateways available to the specified project and region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.VpnGateway | VpnGateway}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListVpnGatewaysRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IVpnGateway[], + protos.google.cloud.compute.v1.IListVpnGatewaysRequest|null, + protos.google.cloud.compute.v1.IVpnGatewayList + ]>; + list( + request: protos.google.cloud.compute.v1.IListVpnGatewaysRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListVpnGatewaysRequest, + protos.google.cloud.compute.v1.IVpnGatewayList|null|undefined, + protos.google.cloud.compute.v1.IVpnGateway>): void; + list( + request: protos.google.cloud.compute.v1.IListVpnGatewaysRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListVpnGatewaysRequest, + protos.google.cloud.compute.v1.IVpnGatewayList|null|undefined, + protos.google.cloud.compute.v1.IVpnGateway>): void; + list( + request?: protos.google.cloud.compute.v1.IListVpnGatewaysRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListVpnGatewaysRequest, + protos.google.cloud.compute.v1.IVpnGatewayList|null|undefined, + protos.google.cloud.compute.v1.IVpnGateway>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListVpnGatewaysRequest, + protos.google.cloud.compute.v1.IVpnGatewayList|null|undefined, + protos.google.cloud.compute.v1.IVpnGateway>): + Promise<[ + protos.google.cloud.compute.v1.IVpnGateway[], + protos.google.cloud.compute.v1.IListVpnGatewaysRequest|null, + protos.google.cloud.compute.v1.IVpnGatewayList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.VpnGateway | VpnGateway} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListVpnGatewaysRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.VpnGateway | VpnGateway}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/vpn_gateways.list.js + * region_tag:compute_v1_generated_VpnGateways_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListVpnGatewaysRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.vpnGatewaysStub && !this._terminated) { + return this.vpnGatewaysStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_gateways_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_gateways_client_config.json new file mode 100644 index 00000000000..16eec6819a7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_gateways_client_config.json @@ -0,0 +1,58 @@ +{ + "interfaces": { + "google.cloud.compute.v1.VpnGateways": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetStatus": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetLabels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_gateways_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_gateways_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_gateways_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_tunnels_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_tunnels_client.ts new file mode 100644 index 00000000000..e1e14d59747 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_tunnels_client.ts @@ -0,0 +1,926 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/vpn_tunnels_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './vpn_tunnels_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The VpnTunnels API. + * @class + * @memberof v1 + */ +export class VpnTunnelsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + vpnTunnelsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of VpnTunnelsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new VpnTunnelsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof VpnTunnelsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.VpnTunnels', 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.vpnTunnelsStub) { + return this.vpnTunnelsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.VpnTunnels. + this.vpnTunnelsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.VpnTunnels') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.VpnTunnels, + 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 vpnTunnelsStubMethods = + ['aggregatedList', 'delete', 'get', 'insert', 'list', 'setLabels']; + for (const methodName of vpnTunnelsStubMethods) { + const callPromise = this.vpnTunnelsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.vpnTunnelsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified VpnTunnel resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.vpnTunnel + * Name of the VpnTunnel resource to delete. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/vpn_tunnels.delete.js + * region_tag:compute_v1_generated_VpnTunnels_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteVpnTunnelRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteVpnTunnelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteVpnTunnelRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteVpnTunnelRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteVpnTunnelRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteVpnTunnelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteVpnTunnelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IDeleteVpnTunnelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'vpn_tunnel': request.vpnTunnel ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Returns the specified VpnTunnel resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.vpnTunnel + * Name of the VpnTunnel resource to return. + * @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.compute.v1.VpnTunnel | VpnTunnel}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/vpn_tunnels.get.js + * region_tag:compute_v1_generated_VpnTunnels_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetVpnTunnelRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IVpnTunnel, + protos.google.cloud.compute.v1.IGetVpnTunnelRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetVpnTunnelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IVpnTunnel, + protos.google.cloud.compute.v1.IGetVpnTunnelRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetVpnTunnelRequest, + callback: Callback< + protos.google.cloud.compute.v1.IVpnTunnel, + protos.google.cloud.compute.v1.IGetVpnTunnelRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetVpnTunnelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IVpnTunnel, + protos.google.cloud.compute.v1.IGetVpnTunnelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IVpnTunnel, + protos.google.cloud.compute.v1.IGetVpnTunnelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IVpnTunnel, + protos.google.cloud.compute.v1.IGetVpnTunnelRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'vpn_tunnel': request.vpnTunnel ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Creates a VpnTunnel resource in the specified project and region using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {google.cloud.compute.v1.VpnTunnel} request.vpnTunnelResource + * The body resource for this request + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/vpn_tunnels.insert.js + * region_tag:compute_v1_generated_VpnTunnels_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1.IInsertVpnTunnelRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1.IInsertVpnTunnelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertVpnTunnelRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1.IInsertVpnTunnelRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertVpnTunnelRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1.IInsertVpnTunnelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertVpnTunnelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IInsertVpnTunnelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Sets the labels on a VpnTunnel. To learn more about labels, read the Labeling Resources documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * The region for this request. + * @param {google.cloud.compute.v1.RegionSetLabelsRequest} request.regionSetLabelsRequestResource + * The body resource for this request + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + * @param {string} request.resource + * Name or id of the resource for this request. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1/vpn_tunnels.set_labels.js + * region_tag:compute_v1_generated_VpnTunnels_SetLabels_async + */ + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsVpnTunnelRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined + ]>; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsVpnTunnelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsVpnTunnelRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request: protos.google.cloud.compute.v1.ISetLabelsVpnTunnelRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsVpnTunnelRequest|null|undefined, + {}|null|undefined>): void; + setLabels( + request?: protos.google.cloud.compute.v1.ISetLabelsVpnTunnelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsVpnTunnelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.ISetLabelsVpnTunnelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setLabels(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves an aggregated list of VPN tunnels. + * + * `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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1.VpnTunnelsScopedList | VpnTunnelsScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/vpn_tunnels.aggregated_list.js + * region_tag:compute_v1_generated_VpnTunnels_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1.IAggregatedListVpnTunnelsRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1.IVpnTunnelsScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1.IVpnTunnelsScopedList]>; + } + /** + * Retrieves a list of VpnTunnel resources contained in the specified project and region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.VpnTunnel | VpnTunnel}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListVpnTunnelsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IVpnTunnel[], + protos.google.cloud.compute.v1.IListVpnTunnelsRequest|null, + protos.google.cloud.compute.v1.IVpnTunnelList + ]>; + list( + request: protos.google.cloud.compute.v1.IListVpnTunnelsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListVpnTunnelsRequest, + protos.google.cloud.compute.v1.IVpnTunnelList|null|undefined, + protos.google.cloud.compute.v1.IVpnTunnel>): void; + list( + request: protos.google.cloud.compute.v1.IListVpnTunnelsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListVpnTunnelsRequest, + protos.google.cloud.compute.v1.IVpnTunnelList|null|undefined, + protos.google.cloud.compute.v1.IVpnTunnel>): void; + list( + request?: protos.google.cloud.compute.v1.IListVpnTunnelsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListVpnTunnelsRequest, + protos.google.cloud.compute.v1.IVpnTunnelList|null|undefined, + protos.google.cloud.compute.v1.IVpnTunnel>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListVpnTunnelsRequest, + protos.google.cloud.compute.v1.IVpnTunnelList|null|undefined, + protos.google.cloud.compute.v1.IVpnTunnel>): + Promise<[ + protos.google.cloud.compute.v1.IVpnTunnel[], + protos.google.cloud.compute.v1.IListVpnTunnelsRequest|null, + protos.google.cloud.compute.v1.IVpnTunnelList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.VpnTunnel | VpnTunnel} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListVpnTunnelsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.VpnTunnel | VpnTunnel}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/vpn_tunnels.list.js + * region_tag:compute_v1_generated_VpnTunnels_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListVpnTunnelsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.vpnTunnelsStub && !this._terminated) { + return this.vpnTunnelsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_tunnels_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_tunnels_client_config.json new file mode 100644 index 00000000000..c4f707f64e5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_tunnels_client_config.json @@ -0,0 +1,50 @@ +{ + "interfaces": { + "google.cloud.compute.v1.VpnTunnels": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetLabels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_tunnels_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_tunnels_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/vpn_tunnels_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/zone_operations_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/zone_operations_client.ts new file mode 100644 index 00000000000..99dd9a6f8b1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/zone_operations_client.ts @@ -0,0 +1,748 @@ +// Copyright 2023 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/zone_operations_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './zone_operations_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The ZoneOperations API. + * @class + * @memberof v1 + */ +export class ZoneOperationsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + zoneOperationsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ZoneOperationsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ZoneOperationsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ZoneOperationsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.ZoneOperations', 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.zoneOperationsStub) { + return this.zoneOperationsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.ZoneOperations. + this.zoneOperationsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.ZoneOperations') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.ZoneOperations, + 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 zoneOperationsStubMethods = + ['delete', 'get', 'list', 'wait']; + for (const methodName of zoneOperationsStubMethods) { + const callPromise = this.zoneOperationsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.zoneOperationsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified zone-specific Operations resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Name of the Operations resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * Name of the zone for this request. + * @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.compute.v1.DeleteZoneOperationResponse | DeleteZoneOperationResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/zone_operations.delete.js + * region_tag:compute_v1_generated_ZoneOperations_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1.IDeleteZoneOperationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IDeleteZoneOperationResponse, + protos.google.cloud.compute.v1.IDeleteZoneOperationRequest|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1.IDeleteZoneOperationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IDeleteZoneOperationResponse, + protos.google.cloud.compute.v1.IDeleteZoneOperationRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1.IDeleteZoneOperationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IDeleteZoneOperationResponse, + protos.google.cloud.compute.v1.IDeleteZoneOperationRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1.IDeleteZoneOperationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IDeleteZoneOperationResponse, + protos.google.cloud.compute.v1.IDeleteZoneOperationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IDeleteZoneOperationResponse, + protos.google.cloud.compute.v1.IDeleteZoneOperationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IDeleteZoneOperationResponse, + protos.google.cloud.compute.v1.IDeleteZoneOperationRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'operation': request.operation ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback); + } +/** + * Retrieves the specified zone-specific Operations resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Name of the Operations resource to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * Name of the zone for this request. + * @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.compute.v1.Operation | Operation}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/zone_operations.get.js + * region_tag:compute_v1_generated_ZoneOperations_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetZoneOperationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetZoneOperationRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetZoneOperationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetZoneOperationRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetZoneOperationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetZoneOperationRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetZoneOperationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetZoneOperationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetZoneOperationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IGetZoneOperationRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'operation': request.operation ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method waits for no more than the 2 minutes and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Name of the Operations resource to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * Name of the zone for this request. + * @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.compute.v1.Operation | Operation}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/zone_operations.wait.js + * region_tag:compute_v1_generated_ZoneOperations_Wait_async + */ + wait( + request?: protos.google.cloud.compute.v1.IWaitZoneOperationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitZoneOperationRequest|undefined, {}|undefined + ]>; + wait( + request: protos.google.cloud.compute.v1.IWaitZoneOperationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitZoneOperationRequest|null|undefined, + {}|null|undefined>): void; + wait( + request: protos.google.cloud.compute.v1.IWaitZoneOperationRequest, + callback: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitZoneOperationRequest|null|undefined, + {}|null|undefined>): void; + wait( + request?: protos.google.cloud.compute.v1.IWaitZoneOperationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitZoneOperationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitZoneOperationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IOperation, + protos.google.cloud.compute.v1.IWaitZoneOperationRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + 'operation': request.operation ?? '', + }); + this.initialize(); + return this.innerApiCalls.wait(request, options, callback); + } + + /** + * Retrieves a list of Operation resources contained within the specified zone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * Name of the zone for request. + * @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 google.cloud.compute.v1.Operation | Operation}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListZoneOperationsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IOperation[], + protos.google.cloud.compute.v1.IListZoneOperationsRequest|null, + protos.google.cloud.compute.v1.IOperationList + ]>; + list( + request: protos.google.cloud.compute.v1.IListZoneOperationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListZoneOperationsRequest, + protos.google.cloud.compute.v1.IOperationList|null|undefined, + protos.google.cloud.compute.v1.IOperation>): void; + list( + request: protos.google.cloud.compute.v1.IListZoneOperationsRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListZoneOperationsRequest, + protos.google.cloud.compute.v1.IOperationList|null|undefined, + protos.google.cloud.compute.v1.IOperation>): void; + list( + request?: protos.google.cloud.compute.v1.IListZoneOperationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListZoneOperationsRequest, + protos.google.cloud.compute.v1.IOperationList|null|undefined, + protos.google.cloud.compute.v1.IOperation>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListZoneOperationsRequest, + protos.google.cloud.compute.v1.IOperationList|null|undefined, + protos.google.cloud.compute.v1.IOperation>): + Promise<[ + protos.google.cloud.compute.v1.IOperation[], + protos.google.cloud.compute.v1.IListZoneOperationsRequest|null, + protos.google.cloud.compute.v1.IOperationList + ]>|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * Name of the zone for request. + * @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 google.cloud.compute.v1.Operation | Operation} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListZoneOperationsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {string} request.zone + * Name of the zone for request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Operation | Operation}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/zone_operations.list.js + * region_tag:compute_v1_generated_ZoneOperations_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListZoneOperationsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.zoneOperationsStub && !this._terminated) { + return this.zoneOperationsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/zone_operations_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/zone_operations_client_config.json new file mode 100644 index 00000000000..f6cca7223a9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/zone_operations_client_config.json @@ -0,0 +1,42 @@ +{ + "interfaces": { + "google.cloud.compute.v1.ZoneOperations": { + "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": { + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Wait": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/zone_operations_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/zone_operations_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/zone_operations_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/zones_client.ts b/owl-bot-staging/google-cloud-compute/v1/src/v1/zones_client.ts new file mode 100644 index 00000000000..a61ffe45a6c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/zones_client.ts @@ -0,0 +1,583 @@ +// Copyright 2023 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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/zones_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './zones_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Zones API. + * @class + * @memberof v1 + */ +export class ZonesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + zonesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ZonesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ZonesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ZonesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1.Zones', 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.zonesStub) { + return this.zonesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1.Zones. + this.zonesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1.Zones') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1.Zones, + 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 zonesStubMethods = + ['get', 'list']; + for (const methodName of zonesStubMethods) { + const callPromise = this.zonesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.zonesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute.readonly', + 'https://www.googleapis.com/auth/compute', + '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 -- + // ------------------- +/** + * Returns the specified Zone resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.zone + * Name of the zone resource to return. + * @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.compute.v1.Zone | Zone}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/zones.get.js + * region_tag:compute_v1_generated_Zones_Get_async + */ + get( + request?: protos.google.cloud.compute.v1.IGetZoneRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IZone, + protos.google.cloud.compute.v1.IGetZoneRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1.IGetZoneRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1.IZone, + protos.google.cloud.compute.v1.IGetZoneRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1.IGetZoneRequest, + callback: Callback< + protos.google.cloud.compute.v1.IZone, + protos.google.cloud.compute.v1.IGetZoneRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1.IGetZoneRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1.IZone, + protos.google.cloud.compute.v1.IGetZoneRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1.IZone, + protos.google.cloud.compute.v1.IGetZoneRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1.IZone, + protos.google.cloud.compute.v1.IGetZoneRequest|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({ + 'project': request.project ?? '', + 'zone': request.zone ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } + + /** + * Retrieves the list of Zone resources available to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Zone | Zone}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1.IListZonesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1.IZone[], + protos.google.cloud.compute.v1.IListZonesRequest|null, + protos.google.cloud.compute.v1.IZoneList + ]>; + list( + request: protos.google.cloud.compute.v1.IListZonesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListZonesRequest, + protos.google.cloud.compute.v1.IZoneList|null|undefined, + protos.google.cloud.compute.v1.IZone>): void; + list( + request: protos.google.cloud.compute.v1.IListZonesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1.IListZonesRequest, + protos.google.cloud.compute.v1.IZoneList|null|undefined, + protos.google.cloud.compute.v1.IZone>): void; + list( + request?: protos.google.cloud.compute.v1.IListZonesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1.IListZonesRequest, + protos.google.cloud.compute.v1.IZoneList|null|undefined, + protos.google.cloud.compute.v1.IZone>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1.IListZonesRequest, + protos.google.cloud.compute.v1.IZoneList|null|undefined, + protos.google.cloud.compute.v1.IZone>): + Promise<[ + protos.google.cloud.compute.v1.IZone[], + protos.google.cloud.compute.v1.IListZonesRequest|null, + protos.google.cloud.compute.v1.IZoneList + ]>|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({ + 'project': request.project ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @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 google.cloud.compute.v1.Zone | Zone} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1.IListZonesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:` operator can be used with string fields to match substrings. For non-string fields it is equivalent to the `=` operator. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {boolean} request.returnPartialSuccess + * Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1.Zone | Zone}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/zones.list.js + * region_tag:compute_v1_generated_Zones_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1.IListZonesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.zonesStub && !this._terminated) { + return this.zonesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/zones_client_config.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/zones_client_config.json new file mode 100644 index 00000000000..c2ada1e465e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/zones_client_config.json @@ -0,0 +1,34 @@ +{ + "interfaces": { + "google.cloud.compute.v1.Zones": { + "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": { + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1/src/v1/zones_proto_list.json b/owl-bot-staging/google-cloud-compute/v1/src/v1/zones_proto_list.json new file mode 100644 index 00000000000..4ad01aef24b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/src/v1/zones_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1/compute.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-compute/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..d316af30fae --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,115 @@ +// Copyright 2023 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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const compute = require('@google-cloud/compute'); + +function main() { + const acceleratorTypesClient = new compute.AcceleratorTypesClient(); + const addressesClient = new compute.AddressesClient(); + const autoscalersClient = new compute.AutoscalersClient(); + const backendBucketsClient = new compute.BackendBucketsClient(); + const backendServicesClient = new compute.BackendServicesClient(); + const disksClient = new compute.DisksClient(); + const diskTypesClient = new compute.DiskTypesClient(); + const externalVpnGatewaysClient = new compute.ExternalVpnGatewaysClient(); + const firewallPoliciesClient = new compute.FirewallPoliciesClient(); + const firewallsClient = new compute.FirewallsClient(); + const forwardingRulesClient = new compute.ForwardingRulesClient(); + const globalAddressesClient = new compute.GlobalAddressesClient(); + const globalForwardingRulesClient = new compute.GlobalForwardingRulesClient(); + const globalNetworkEndpointGroupsClient = new compute.GlobalNetworkEndpointGroupsClient(); + const globalOperationsClient = new compute.GlobalOperationsClient(); + const globalOrganizationOperationsClient = new compute.GlobalOrganizationOperationsClient(); + const globalPublicDelegatedPrefixesClient = new compute.GlobalPublicDelegatedPrefixesClient(); + const healthChecksClient = new compute.HealthChecksClient(); + const imageFamilyViewsClient = new compute.ImageFamilyViewsClient(); + const imagesClient = new compute.ImagesClient(); + const instanceGroupManagersClient = new compute.InstanceGroupManagersClient(); + const instanceGroupsClient = new compute.InstanceGroupsClient(); + const instancesClient = new compute.InstancesClient(); + const instanceTemplatesClient = new compute.InstanceTemplatesClient(); + const interconnectAttachmentsClient = new compute.InterconnectAttachmentsClient(); + const interconnectLocationsClient = new compute.InterconnectLocationsClient(); + const interconnectsClient = new compute.InterconnectsClient(); + const licenseCodesClient = new compute.LicenseCodesClient(); + const licensesClient = new compute.LicensesClient(); + const machineImagesClient = new compute.MachineImagesClient(); + const machineTypesClient = new compute.MachineTypesClient(); + const networkAttachmentsClient = new compute.NetworkAttachmentsClient(); + const networkEdgeSecurityServicesClient = new compute.NetworkEdgeSecurityServicesClient(); + const networkEndpointGroupsClient = new compute.NetworkEndpointGroupsClient(); + const networkFirewallPoliciesClient = new compute.NetworkFirewallPoliciesClient(); + const networksClient = new compute.NetworksClient(); + const nodeGroupsClient = new compute.NodeGroupsClient(); + const nodeTemplatesClient = new compute.NodeTemplatesClient(); + const nodeTypesClient = new compute.NodeTypesClient(); + const packetMirroringsClient = new compute.PacketMirroringsClient(); + const projectsClient = new compute.ProjectsClient(); + const publicAdvertisedPrefixesClient = new compute.PublicAdvertisedPrefixesClient(); + const publicDelegatedPrefixesClient = new compute.PublicDelegatedPrefixesClient(); + const regionAutoscalersClient = new compute.RegionAutoscalersClient(); + const regionBackendServicesClient = new compute.RegionBackendServicesClient(); + const regionCommitmentsClient = new compute.RegionCommitmentsClient(); + const regionDisksClient = new compute.RegionDisksClient(); + const regionDiskTypesClient = new compute.RegionDiskTypesClient(); + const regionHealthChecksClient = new compute.RegionHealthChecksClient(); + const regionHealthCheckServicesClient = new compute.RegionHealthCheckServicesClient(); + const regionInstanceGroupManagersClient = new compute.RegionInstanceGroupManagersClient(); + const regionInstanceGroupsClient = new compute.RegionInstanceGroupsClient(); + const regionInstancesClient = new compute.RegionInstancesClient(); + const regionInstanceTemplatesClient = new compute.RegionInstanceTemplatesClient(); + const regionNetworkEndpointGroupsClient = new compute.RegionNetworkEndpointGroupsClient(); + const regionNetworkFirewallPoliciesClient = new compute.RegionNetworkFirewallPoliciesClient(); + const regionNotificationEndpointsClient = new compute.RegionNotificationEndpointsClient(); + const regionOperationsClient = new compute.RegionOperationsClient(); + const regionsClient = new compute.RegionsClient(); + const regionSecurityPoliciesClient = new compute.RegionSecurityPoliciesClient(); + const regionSslCertificatesClient = new compute.RegionSslCertificatesClient(); + const regionSslPoliciesClient = new compute.RegionSslPoliciesClient(); + const regionTargetHttpProxiesClient = new compute.RegionTargetHttpProxiesClient(); + const regionTargetHttpsProxiesClient = new compute.RegionTargetHttpsProxiesClient(); + const regionTargetTcpProxiesClient = new compute.RegionTargetTcpProxiesClient(); + const regionUrlMapsClient = new compute.RegionUrlMapsClient(); + const reservationsClient = new compute.ReservationsClient(); + const resourcePoliciesClient = new compute.ResourcePoliciesClient(); + const routersClient = new compute.RoutersClient(); + const routesClient = new compute.RoutesClient(); + const securityPoliciesClient = new compute.SecurityPoliciesClient(); + const serviceAttachmentsClient = new compute.ServiceAttachmentsClient(); + const snapshotsClient = new compute.SnapshotsClient(); + const sslCertificatesClient = new compute.SslCertificatesClient(); + const sslPoliciesClient = new compute.SslPoliciesClient(); + const subnetworksClient = new compute.SubnetworksClient(); + const targetGrpcProxiesClient = new compute.TargetGrpcProxiesClient(); + const targetHttpProxiesClient = new compute.TargetHttpProxiesClient(); + const targetHttpsProxiesClient = new compute.TargetHttpsProxiesClient(); + const targetInstancesClient = new compute.TargetInstancesClient(); + const targetPoolsClient = new compute.TargetPoolsClient(); + const targetSslProxiesClient = new compute.TargetSslProxiesClient(); + const targetTcpProxiesClient = new compute.TargetTcpProxiesClient(); + const targetVpnGatewaysClient = new compute.TargetVpnGatewaysClient(); + const urlMapsClient = new compute.UrlMapsClient(); + const vpnGatewaysClient = new compute.VpnGatewaysClient(); + const vpnTunnelsClient = new compute.VpnTunnelsClient(); + const zoneOperationsClient = new compute.ZoneOperationsClient(); + const zonesClient = new compute.ZonesClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-compute/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-compute/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..edd0d6da97b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,560 @@ +// Copyright 2023 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 {AcceleratorTypesClient, AddressesClient, AutoscalersClient, BackendBucketsClient, BackendServicesClient, DisksClient, DiskTypesClient, ExternalVpnGatewaysClient, FirewallPoliciesClient, FirewallsClient, ForwardingRulesClient, GlobalAddressesClient, GlobalForwardingRulesClient, GlobalNetworkEndpointGroupsClient, GlobalOperationsClient, GlobalOrganizationOperationsClient, GlobalPublicDelegatedPrefixesClient, HealthChecksClient, ImageFamilyViewsClient, ImagesClient, InstanceGroupManagersClient, InstanceGroupsClient, InstancesClient, InstanceTemplatesClient, InterconnectAttachmentsClient, InterconnectLocationsClient, InterconnectsClient, LicenseCodesClient, LicensesClient, MachineImagesClient, MachineTypesClient, NetworkAttachmentsClient, NetworkEdgeSecurityServicesClient, NetworkEndpointGroupsClient, NetworkFirewallPoliciesClient, NetworksClient, NodeGroupsClient, NodeTemplatesClient, NodeTypesClient, PacketMirroringsClient, ProjectsClient, PublicAdvertisedPrefixesClient, PublicDelegatedPrefixesClient, RegionAutoscalersClient, RegionBackendServicesClient, RegionCommitmentsClient, RegionDisksClient, RegionDiskTypesClient, RegionHealthChecksClient, RegionHealthCheckServicesClient, RegionInstanceGroupManagersClient, RegionInstanceGroupsClient, RegionInstancesClient, RegionInstanceTemplatesClient, RegionNetworkEndpointGroupsClient, RegionNetworkFirewallPoliciesClient, RegionNotificationEndpointsClient, RegionOperationsClient, RegionsClient, RegionSecurityPoliciesClient, RegionSslCertificatesClient, RegionSslPoliciesClient, RegionTargetHttpProxiesClient, RegionTargetHttpsProxiesClient, RegionTargetTcpProxiesClient, RegionUrlMapsClient, ReservationsClient, ResourcePoliciesClient, RoutersClient, RoutesClient, SecurityPoliciesClient, ServiceAttachmentsClient, SnapshotsClient, SslCertificatesClient, SslPoliciesClient, SubnetworksClient, TargetGrpcProxiesClient, TargetHttpProxiesClient, TargetHttpsProxiesClient, TargetInstancesClient, TargetPoolsClient, TargetSslProxiesClient, TargetTcpProxiesClient, TargetVpnGatewaysClient, UrlMapsClient, VpnGatewaysClient, VpnTunnelsClient, ZoneOperationsClient, ZonesClient} from '@google-cloud/compute'; + +// check that the client class type name can be used +function doStuffWithAcceleratorTypesClient(client: AcceleratorTypesClient) { + client.close(); +} +function doStuffWithAddressesClient(client: AddressesClient) { + client.close(); +} +function doStuffWithAutoscalersClient(client: AutoscalersClient) { + client.close(); +} +function doStuffWithBackendBucketsClient(client: BackendBucketsClient) { + client.close(); +} +function doStuffWithBackendServicesClient(client: BackendServicesClient) { + client.close(); +} +function doStuffWithDisksClient(client: DisksClient) { + client.close(); +} +function doStuffWithDiskTypesClient(client: DiskTypesClient) { + client.close(); +} +function doStuffWithExternalVpnGatewaysClient(client: ExternalVpnGatewaysClient) { + client.close(); +} +function doStuffWithFirewallPoliciesClient(client: FirewallPoliciesClient) { + client.close(); +} +function doStuffWithFirewallsClient(client: FirewallsClient) { + client.close(); +} +function doStuffWithForwardingRulesClient(client: ForwardingRulesClient) { + client.close(); +} +function doStuffWithGlobalAddressesClient(client: GlobalAddressesClient) { + client.close(); +} +function doStuffWithGlobalForwardingRulesClient(client: GlobalForwardingRulesClient) { + client.close(); +} +function doStuffWithGlobalNetworkEndpointGroupsClient(client: GlobalNetworkEndpointGroupsClient) { + client.close(); +} +function doStuffWithGlobalOperationsClient(client: GlobalOperationsClient) { + client.close(); +} +function doStuffWithGlobalOrganizationOperationsClient(client: GlobalOrganizationOperationsClient) { + client.close(); +} +function doStuffWithGlobalPublicDelegatedPrefixesClient(client: GlobalPublicDelegatedPrefixesClient) { + client.close(); +} +function doStuffWithHealthChecksClient(client: HealthChecksClient) { + client.close(); +} +function doStuffWithImageFamilyViewsClient(client: ImageFamilyViewsClient) { + client.close(); +} +function doStuffWithImagesClient(client: ImagesClient) { + client.close(); +} +function doStuffWithInstanceGroupManagersClient(client: InstanceGroupManagersClient) { + client.close(); +} +function doStuffWithInstanceGroupsClient(client: InstanceGroupsClient) { + client.close(); +} +function doStuffWithInstancesClient(client: InstancesClient) { + client.close(); +} +function doStuffWithInstanceTemplatesClient(client: InstanceTemplatesClient) { + client.close(); +} +function doStuffWithInterconnectAttachmentsClient(client: InterconnectAttachmentsClient) { + client.close(); +} +function doStuffWithInterconnectLocationsClient(client: InterconnectLocationsClient) { + client.close(); +} +function doStuffWithInterconnectsClient(client: InterconnectsClient) { + client.close(); +} +function doStuffWithLicenseCodesClient(client: LicenseCodesClient) { + client.close(); +} +function doStuffWithLicensesClient(client: LicensesClient) { + client.close(); +} +function doStuffWithMachineImagesClient(client: MachineImagesClient) { + client.close(); +} +function doStuffWithMachineTypesClient(client: MachineTypesClient) { + client.close(); +} +function doStuffWithNetworkAttachmentsClient(client: NetworkAttachmentsClient) { + client.close(); +} +function doStuffWithNetworkEdgeSecurityServicesClient(client: NetworkEdgeSecurityServicesClient) { + client.close(); +} +function doStuffWithNetworkEndpointGroupsClient(client: NetworkEndpointGroupsClient) { + client.close(); +} +function doStuffWithNetworkFirewallPoliciesClient(client: NetworkFirewallPoliciesClient) { + client.close(); +} +function doStuffWithNetworksClient(client: NetworksClient) { + client.close(); +} +function doStuffWithNodeGroupsClient(client: NodeGroupsClient) { + client.close(); +} +function doStuffWithNodeTemplatesClient(client: NodeTemplatesClient) { + client.close(); +} +function doStuffWithNodeTypesClient(client: NodeTypesClient) { + client.close(); +} +function doStuffWithPacketMirroringsClient(client: PacketMirroringsClient) { + client.close(); +} +function doStuffWithProjectsClient(client: ProjectsClient) { + client.close(); +} +function doStuffWithPublicAdvertisedPrefixesClient(client: PublicAdvertisedPrefixesClient) { + client.close(); +} +function doStuffWithPublicDelegatedPrefixesClient(client: PublicDelegatedPrefixesClient) { + client.close(); +} +function doStuffWithRegionAutoscalersClient(client: RegionAutoscalersClient) { + client.close(); +} +function doStuffWithRegionBackendServicesClient(client: RegionBackendServicesClient) { + client.close(); +} +function doStuffWithRegionCommitmentsClient(client: RegionCommitmentsClient) { + client.close(); +} +function doStuffWithRegionDisksClient(client: RegionDisksClient) { + client.close(); +} +function doStuffWithRegionDiskTypesClient(client: RegionDiskTypesClient) { + client.close(); +} +function doStuffWithRegionHealthChecksClient(client: RegionHealthChecksClient) { + client.close(); +} +function doStuffWithRegionHealthCheckServicesClient(client: RegionHealthCheckServicesClient) { + client.close(); +} +function doStuffWithRegionInstanceGroupManagersClient(client: RegionInstanceGroupManagersClient) { + client.close(); +} +function doStuffWithRegionInstanceGroupsClient(client: RegionInstanceGroupsClient) { + client.close(); +} +function doStuffWithRegionInstancesClient(client: RegionInstancesClient) { + client.close(); +} +function doStuffWithRegionInstanceTemplatesClient(client: RegionInstanceTemplatesClient) { + client.close(); +} +function doStuffWithRegionNetworkEndpointGroupsClient(client: RegionNetworkEndpointGroupsClient) { + client.close(); +} +function doStuffWithRegionNetworkFirewallPoliciesClient(client: RegionNetworkFirewallPoliciesClient) { + client.close(); +} +function doStuffWithRegionNotificationEndpointsClient(client: RegionNotificationEndpointsClient) { + client.close(); +} +function doStuffWithRegionOperationsClient(client: RegionOperationsClient) { + client.close(); +} +function doStuffWithRegionsClient(client: RegionsClient) { + client.close(); +} +function doStuffWithRegionSecurityPoliciesClient(client: RegionSecurityPoliciesClient) { + client.close(); +} +function doStuffWithRegionSslCertificatesClient(client: RegionSslCertificatesClient) { + client.close(); +} +function doStuffWithRegionSslPoliciesClient(client: RegionSslPoliciesClient) { + client.close(); +} +function doStuffWithRegionTargetHttpProxiesClient(client: RegionTargetHttpProxiesClient) { + client.close(); +} +function doStuffWithRegionTargetHttpsProxiesClient(client: RegionTargetHttpsProxiesClient) { + client.close(); +} +function doStuffWithRegionTargetTcpProxiesClient(client: RegionTargetTcpProxiesClient) { + client.close(); +} +function doStuffWithRegionUrlMapsClient(client: RegionUrlMapsClient) { + client.close(); +} +function doStuffWithReservationsClient(client: ReservationsClient) { + client.close(); +} +function doStuffWithResourcePoliciesClient(client: ResourcePoliciesClient) { + client.close(); +} +function doStuffWithRoutersClient(client: RoutersClient) { + client.close(); +} +function doStuffWithRoutesClient(client: RoutesClient) { + client.close(); +} +function doStuffWithSecurityPoliciesClient(client: SecurityPoliciesClient) { + client.close(); +} +function doStuffWithServiceAttachmentsClient(client: ServiceAttachmentsClient) { + client.close(); +} +function doStuffWithSnapshotsClient(client: SnapshotsClient) { + client.close(); +} +function doStuffWithSslCertificatesClient(client: SslCertificatesClient) { + client.close(); +} +function doStuffWithSslPoliciesClient(client: SslPoliciesClient) { + client.close(); +} +function doStuffWithSubnetworksClient(client: SubnetworksClient) { + client.close(); +} +function doStuffWithTargetGrpcProxiesClient(client: TargetGrpcProxiesClient) { + client.close(); +} +function doStuffWithTargetHttpProxiesClient(client: TargetHttpProxiesClient) { + client.close(); +} +function doStuffWithTargetHttpsProxiesClient(client: TargetHttpsProxiesClient) { + client.close(); +} +function doStuffWithTargetInstancesClient(client: TargetInstancesClient) { + client.close(); +} +function doStuffWithTargetPoolsClient(client: TargetPoolsClient) { + client.close(); +} +function doStuffWithTargetSslProxiesClient(client: TargetSslProxiesClient) { + client.close(); +} +function doStuffWithTargetTcpProxiesClient(client: TargetTcpProxiesClient) { + client.close(); +} +function doStuffWithTargetVpnGatewaysClient(client: TargetVpnGatewaysClient) { + client.close(); +} +function doStuffWithUrlMapsClient(client: UrlMapsClient) { + client.close(); +} +function doStuffWithVpnGatewaysClient(client: VpnGatewaysClient) { + client.close(); +} +function doStuffWithVpnTunnelsClient(client: VpnTunnelsClient) { + client.close(); +} +function doStuffWithZoneOperationsClient(client: ZoneOperationsClient) { + client.close(); +} +function doStuffWithZonesClient(client: ZonesClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const acceleratorTypesClient = new AcceleratorTypesClient(); + doStuffWithAcceleratorTypesClient(acceleratorTypesClient); + // check that the client instance can be created + const addressesClient = new AddressesClient(); + doStuffWithAddressesClient(addressesClient); + // check that the client instance can be created + const autoscalersClient = new AutoscalersClient(); + doStuffWithAutoscalersClient(autoscalersClient); + // check that the client instance can be created + const backendBucketsClient = new BackendBucketsClient(); + doStuffWithBackendBucketsClient(backendBucketsClient); + // check that the client instance can be created + const backendServicesClient = new BackendServicesClient(); + doStuffWithBackendServicesClient(backendServicesClient); + // check that the client instance can be created + const disksClient = new DisksClient(); + doStuffWithDisksClient(disksClient); + // check that the client instance can be created + const diskTypesClient = new DiskTypesClient(); + doStuffWithDiskTypesClient(diskTypesClient); + // check that the client instance can be created + const externalVpnGatewaysClient = new ExternalVpnGatewaysClient(); + doStuffWithExternalVpnGatewaysClient(externalVpnGatewaysClient); + // check that the client instance can be created + const firewallPoliciesClient = new FirewallPoliciesClient(); + doStuffWithFirewallPoliciesClient(firewallPoliciesClient); + // check that the client instance can be created + const firewallsClient = new FirewallsClient(); + doStuffWithFirewallsClient(firewallsClient); + // check that the client instance can be created + const forwardingRulesClient = new ForwardingRulesClient(); + doStuffWithForwardingRulesClient(forwardingRulesClient); + // check that the client instance can be created + const globalAddressesClient = new GlobalAddressesClient(); + doStuffWithGlobalAddressesClient(globalAddressesClient); + // check that the client instance can be created + const globalForwardingRulesClient = new GlobalForwardingRulesClient(); + doStuffWithGlobalForwardingRulesClient(globalForwardingRulesClient); + // check that the client instance can be created + const globalNetworkEndpointGroupsClient = new GlobalNetworkEndpointGroupsClient(); + doStuffWithGlobalNetworkEndpointGroupsClient(globalNetworkEndpointGroupsClient); + // check that the client instance can be created + const globalOperationsClient = new GlobalOperationsClient(); + doStuffWithGlobalOperationsClient(globalOperationsClient); + // check that the client instance can be created + const globalOrganizationOperationsClient = new GlobalOrganizationOperationsClient(); + doStuffWithGlobalOrganizationOperationsClient(globalOrganizationOperationsClient); + // check that the client instance can be created + const globalPublicDelegatedPrefixesClient = new GlobalPublicDelegatedPrefixesClient(); + doStuffWithGlobalPublicDelegatedPrefixesClient(globalPublicDelegatedPrefixesClient); + // check that the client instance can be created + const healthChecksClient = new HealthChecksClient(); + doStuffWithHealthChecksClient(healthChecksClient); + // check that the client instance can be created + const imageFamilyViewsClient = new ImageFamilyViewsClient(); + doStuffWithImageFamilyViewsClient(imageFamilyViewsClient); + // check that the client instance can be created + const imagesClient = new ImagesClient(); + doStuffWithImagesClient(imagesClient); + // check that the client instance can be created + const instanceGroupManagersClient = new InstanceGroupManagersClient(); + doStuffWithInstanceGroupManagersClient(instanceGroupManagersClient); + // check that the client instance can be created + const instanceGroupsClient = new InstanceGroupsClient(); + doStuffWithInstanceGroupsClient(instanceGroupsClient); + // check that the client instance can be created + const instancesClient = new InstancesClient(); + doStuffWithInstancesClient(instancesClient); + // check that the client instance can be created + const instanceTemplatesClient = new InstanceTemplatesClient(); + doStuffWithInstanceTemplatesClient(instanceTemplatesClient); + // check that the client instance can be created + const interconnectAttachmentsClient = new InterconnectAttachmentsClient(); + doStuffWithInterconnectAttachmentsClient(interconnectAttachmentsClient); + // check that the client instance can be created + const interconnectLocationsClient = new InterconnectLocationsClient(); + doStuffWithInterconnectLocationsClient(interconnectLocationsClient); + // check that the client instance can be created + const interconnectsClient = new InterconnectsClient(); + doStuffWithInterconnectsClient(interconnectsClient); + // check that the client instance can be created + const licenseCodesClient = new LicenseCodesClient(); + doStuffWithLicenseCodesClient(licenseCodesClient); + // check that the client instance can be created + const licensesClient = new LicensesClient(); + doStuffWithLicensesClient(licensesClient); + // check that the client instance can be created + const machineImagesClient = new MachineImagesClient(); + doStuffWithMachineImagesClient(machineImagesClient); + // check that the client instance can be created + const machineTypesClient = new MachineTypesClient(); + doStuffWithMachineTypesClient(machineTypesClient); + // check that the client instance can be created + const networkAttachmentsClient = new NetworkAttachmentsClient(); + doStuffWithNetworkAttachmentsClient(networkAttachmentsClient); + // check that the client instance can be created + const networkEdgeSecurityServicesClient = new NetworkEdgeSecurityServicesClient(); + doStuffWithNetworkEdgeSecurityServicesClient(networkEdgeSecurityServicesClient); + // check that the client instance can be created + const networkEndpointGroupsClient = new NetworkEndpointGroupsClient(); + doStuffWithNetworkEndpointGroupsClient(networkEndpointGroupsClient); + // check that the client instance can be created + const networkFirewallPoliciesClient = new NetworkFirewallPoliciesClient(); + doStuffWithNetworkFirewallPoliciesClient(networkFirewallPoliciesClient); + // check that the client instance can be created + const networksClient = new NetworksClient(); + doStuffWithNetworksClient(networksClient); + // check that the client instance can be created + const nodeGroupsClient = new NodeGroupsClient(); + doStuffWithNodeGroupsClient(nodeGroupsClient); + // check that the client instance can be created + const nodeTemplatesClient = new NodeTemplatesClient(); + doStuffWithNodeTemplatesClient(nodeTemplatesClient); + // check that the client instance can be created + const nodeTypesClient = new NodeTypesClient(); + doStuffWithNodeTypesClient(nodeTypesClient); + // check that the client instance can be created + const packetMirroringsClient = new PacketMirroringsClient(); + doStuffWithPacketMirroringsClient(packetMirroringsClient); + // check that the client instance can be created + const projectsClient = new ProjectsClient(); + doStuffWithProjectsClient(projectsClient); + // check that the client instance can be created + const publicAdvertisedPrefixesClient = new PublicAdvertisedPrefixesClient(); + doStuffWithPublicAdvertisedPrefixesClient(publicAdvertisedPrefixesClient); + // check that the client instance can be created + const publicDelegatedPrefixesClient = new PublicDelegatedPrefixesClient(); + doStuffWithPublicDelegatedPrefixesClient(publicDelegatedPrefixesClient); + // check that the client instance can be created + const regionAutoscalersClient = new RegionAutoscalersClient(); + doStuffWithRegionAutoscalersClient(regionAutoscalersClient); + // check that the client instance can be created + const regionBackendServicesClient = new RegionBackendServicesClient(); + doStuffWithRegionBackendServicesClient(regionBackendServicesClient); + // check that the client instance can be created + const regionCommitmentsClient = new RegionCommitmentsClient(); + doStuffWithRegionCommitmentsClient(regionCommitmentsClient); + // check that the client instance can be created + const regionDisksClient = new RegionDisksClient(); + doStuffWithRegionDisksClient(regionDisksClient); + // check that the client instance can be created + const regionDiskTypesClient = new RegionDiskTypesClient(); + doStuffWithRegionDiskTypesClient(regionDiskTypesClient); + // check that the client instance can be created + const regionHealthChecksClient = new RegionHealthChecksClient(); + doStuffWithRegionHealthChecksClient(regionHealthChecksClient); + // check that the client instance can be created + const regionHealthCheckServicesClient = new RegionHealthCheckServicesClient(); + doStuffWithRegionHealthCheckServicesClient(regionHealthCheckServicesClient); + // check that the client instance can be created + const regionInstanceGroupManagersClient = new RegionInstanceGroupManagersClient(); + doStuffWithRegionInstanceGroupManagersClient(regionInstanceGroupManagersClient); + // check that the client instance can be created + const regionInstanceGroupsClient = new RegionInstanceGroupsClient(); + doStuffWithRegionInstanceGroupsClient(regionInstanceGroupsClient); + // check that the client instance can be created + const regionInstancesClient = new RegionInstancesClient(); + doStuffWithRegionInstancesClient(regionInstancesClient); + // check that the client instance can be created + const regionInstanceTemplatesClient = new RegionInstanceTemplatesClient(); + doStuffWithRegionInstanceTemplatesClient(regionInstanceTemplatesClient); + // check that the client instance can be created + const regionNetworkEndpointGroupsClient = new RegionNetworkEndpointGroupsClient(); + doStuffWithRegionNetworkEndpointGroupsClient(regionNetworkEndpointGroupsClient); + // check that the client instance can be created + const regionNetworkFirewallPoliciesClient = new RegionNetworkFirewallPoliciesClient(); + doStuffWithRegionNetworkFirewallPoliciesClient(regionNetworkFirewallPoliciesClient); + // check that the client instance can be created + const regionNotificationEndpointsClient = new RegionNotificationEndpointsClient(); + doStuffWithRegionNotificationEndpointsClient(regionNotificationEndpointsClient); + // check that the client instance can be created + const regionOperationsClient = new RegionOperationsClient(); + doStuffWithRegionOperationsClient(regionOperationsClient); + // check that the client instance can be created + const regionsClient = new RegionsClient(); + doStuffWithRegionsClient(regionsClient); + // check that the client instance can be created + const regionSecurityPoliciesClient = new RegionSecurityPoliciesClient(); + doStuffWithRegionSecurityPoliciesClient(regionSecurityPoliciesClient); + // check that the client instance can be created + const regionSslCertificatesClient = new RegionSslCertificatesClient(); + doStuffWithRegionSslCertificatesClient(regionSslCertificatesClient); + // check that the client instance can be created + const regionSslPoliciesClient = new RegionSslPoliciesClient(); + doStuffWithRegionSslPoliciesClient(regionSslPoliciesClient); + // check that the client instance can be created + const regionTargetHttpProxiesClient = new RegionTargetHttpProxiesClient(); + doStuffWithRegionTargetHttpProxiesClient(regionTargetHttpProxiesClient); + // check that the client instance can be created + const regionTargetHttpsProxiesClient = new RegionTargetHttpsProxiesClient(); + doStuffWithRegionTargetHttpsProxiesClient(regionTargetHttpsProxiesClient); + // check that the client instance can be created + const regionTargetTcpProxiesClient = new RegionTargetTcpProxiesClient(); + doStuffWithRegionTargetTcpProxiesClient(regionTargetTcpProxiesClient); + // check that the client instance can be created + const regionUrlMapsClient = new RegionUrlMapsClient(); + doStuffWithRegionUrlMapsClient(regionUrlMapsClient); + // check that the client instance can be created + const reservationsClient = new ReservationsClient(); + doStuffWithReservationsClient(reservationsClient); + // check that the client instance can be created + const resourcePoliciesClient = new ResourcePoliciesClient(); + doStuffWithResourcePoliciesClient(resourcePoliciesClient); + // check that the client instance can be created + const routersClient = new RoutersClient(); + doStuffWithRoutersClient(routersClient); + // check that the client instance can be created + const routesClient = new RoutesClient(); + doStuffWithRoutesClient(routesClient); + // check that the client instance can be created + const securityPoliciesClient = new SecurityPoliciesClient(); + doStuffWithSecurityPoliciesClient(securityPoliciesClient); + // check that the client instance can be created + const serviceAttachmentsClient = new ServiceAttachmentsClient(); + doStuffWithServiceAttachmentsClient(serviceAttachmentsClient); + // check that the client instance can be created + const snapshotsClient = new SnapshotsClient(); + doStuffWithSnapshotsClient(snapshotsClient); + // check that the client instance can be created + const sslCertificatesClient = new SslCertificatesClient(); + doStuffWithSslCertificatesClient(sslCertificatesClient); + // check that the client instance can be created + const sslPoliciesClient = new SslPoliciesClient(); + doStuffWithSslPoliciesClient(sslPoliciesClient); + // check that the client instance can be created + const subnetworksClient = new SubnetworksClient(); + doStuffWithSubnetworksClient(subnetworksClient); + // check that the client instance can be created + const targetGrpcProxiesClient = new TargetGrpcProxiesClient(); + doStuffWithTargetGrpcProxiesClient(targetGrpcProxiesClient); + // check that the client instance can be created + const targetHttpProxiesClient = new TargetHttpProxiesClient(); + doStuffWithTargetHttpProxiesClient(targetHttpProxiesClient); + // check that the client instance can be created + const targetHttpsProxiesClient = new TargetHttpsProxiesClient(); + doStuffWithTargetHttpsProxiesClient(targetHttpsProxiesClient); + // check that the client instance can be created + const targetInstancesClient = new TargetInstancesClient(); + doStuffWithTargetInstancesClient(targetInstancesClient); + // check that the client instance can be created + const targetPoolsClient = new TargetPoolsClient(); + doStuffWithTargetPoolsClient(targetPoolsClient); + // check that the client instance can be created + const targetSslProxiesClient = new TargetSslProxiesClient(); + doStuffWithTargetSslProxiesClient(targetSslProxiesClient); + // check that the client instance can be created + const targetTcpProxiesClient = new TargetTcpProxiesClient(); + doStuffWithTargetTcpProxiesClient(targetTcpProxiesClient); + // check that the client instance can be created + const targetVpnGatewaysClient = new TargetVpnGatewaysClient(); + doStuffWithTargetVpnGatewaysClient(targetVpnGatewaysClient); + // check that the client instance can be created + const urlMapsClient = new UrlMapsClient(); + doStuffWithUrlMapsClient(urlMapsClient); + // check that the client instance can be created + const vpnGatewaysClient = new VpnGatewaysClient(); + doStuffWithVpnGatewaysClient(vpnGatewaysClient); + // check that the client instance can be created + const vpnTunnelsClient = new VpnTunnelsClient(); + doStuffWithVpnTunnelsClient(vpnTunnelsClient); + // check that the client instance can be created + const zoneOperationsClient = new ZoneOperationsClient(); + doStuffWithZoneOperationsClient(zoneOperationsClient); + // check that the client instance can be created + const zonesClient = new ZonesClient(); + doStuffWithZonesClient(zonesClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-compute/v1/system-test/install.ts b/owl-bot-staging/google-cloud-compute/v1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2023 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 {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_accelerator_types_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_accelerator_types_v1.ts new file mode 100644 index 00000000000..1d74a86d751 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_accelerator_types_v1.ts @@ -0,0 +1,678 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as acceleratortypesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.AcceleratorTypesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = acceleratortypesModule.v1.AcceleratorTypesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = acceleratortypesModule.v1.AcceleratorTypesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = acceleratortypesModule.v1.AcceleratorTypesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.acceleratorTypesStub, undefined); + await client.initialize(); + assert(client.acceleratorTypesStub); + }); + + it('has close method for the initialized client', done => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.acceleratorTypesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.acceleratorTypesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + auth: googleAuth, + 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 acceleratortypesModule.v1.AcceleratorTypesClient({ + auth: googleAuth, + 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('get', () => { + it('invokes get without error', async () => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAcceleratorTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAcceleratorTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAcceleratorTypeRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAcceleratorTypeRequest', ['acceleratorType']); + request.acceleratorType = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&accelerator_type=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.AcceleratorType() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAcceleratorTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAcceleratorTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAcceleratorTypeRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAcceleratorTypeRequest', ['acceleratorType']); + request.acceleratorType = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&accelerator_type=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.AcceleratorType() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IAcceleratorType|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAcceleratorTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAcceleratorTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAcceleratorTypeRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAcceleratorTypeRequest', ['acceleratorType']); + request.acceleratorType = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&accelerator_type=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAcceleratorTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAcceleratorTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAcceleratorTypeRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAcceleratorTypeRequest', ['acceleratorType']); + request.acceleratorType = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListAcceleratorTypesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.AcceleratorTypesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.AcceleratorTypesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.AcceleratorTypesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IAcceleratorTypesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListAcceleratorTypesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IAcceleratorTypesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAcceleratorTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAcceleratorTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.compute.v1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.compute.v1.AcceleratorType()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAcceleratorTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAcceleratorTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.compute.v1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.compute.v1.AcceleratorType()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IAcceleratorType[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAcceleratorTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAcceleratorTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAcceleratorTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAcceleratorTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.compute.v1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.compute.v1.AcceleratorType()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.AcceleratorType[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.AcceleratorType) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAcceleratorTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAcceleratorTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.AcceleratorType[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.AcceleratorType) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAcceleratorTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAcceleratorTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.compute.v1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.compute.v1.AcceleratorType()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IAcceleratorType[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new acceleratortypesModule.v1.AcceleratorTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAcceleratorTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAcceleratorTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IAcceleratorType[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_addresses_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_addresses_v1.ts new file mode 100644 index 00000000000..2150354e326 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_addresses_v1.ts @@ -0,0 +1,1062 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as addressesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.AddressesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = addressesModule.v1.AddressesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = addressesModule.v1.AddressesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = addressesModule.v1.AddressesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new addressesModule.v1.AddressesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new addressesModule.v1.AddressesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.addressesStub, undefined); + await client.initialize(); + assert(client.addressesStub); + }); + + it('has close method for the initialized client', done => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.addressesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.addressesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + 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 addressesModule.v1.AddressesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAddressRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAddressRequest', ['address']); + request.address = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&address=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAddressRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAddressRequest', ['address']); + request.address = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&address=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAddressRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAddressRequest', ['address']); + request.address = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&address=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAddressRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAddressRequest', ['address']); + request.address = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAddressRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAddressRequest', ['address']); + request.address = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&address=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Address() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAddressRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAddressRequest', ['address']); + request.address = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&address=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Address() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IAddress|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAddressRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAddressRequest', ['address']); + request.address = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&address=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAddressRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAddressRequest', ['address']); + request.address = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertAddressRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertAddressRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertAddressRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertAddressRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('setLabels', () => { + it('invokes setLabels without error', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsAddressRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsAddressRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCall(expectedResponse); + const [response] = await client.setLabels(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels without error using callback', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsAddressRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsAddressRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setLabels( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with error', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsAddressRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsAddressRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setLabels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with closed client', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsAddressRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsAddressRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setLabels(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListAddressesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.AddressesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.AddressesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.AddressesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IAddressesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new addressesModule.v1.AddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListAddressesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IAddressesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new addressesModule.v1.AddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAddressesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAddressesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new addressesModule.v1.AddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAddressesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAddressesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IAddress[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new addressesModule.v1.AddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAddressesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAddressesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new addressesModule.v1.AddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAddressesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAddressesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Address[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Address) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new addressesModule.v1.AddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAddressesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAddressesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Address[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Address) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new addressesModule.v1.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAddressesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAddressesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IAddress[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new addressesModule.v1.AddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAddressesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAddressesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IAddress[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_autoscalers_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_autoscalers_v1.ts new file mode 100644 index 00000000000..93687d86c47 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_autoscalers_v1.ts @@ -0,0 +1,1170 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as autoscalersModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.AutoscalersClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = autoscalersModule.v1.AutoscalersClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = autoscalersModule.v1.AutoscalersClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = autoscalersModule.v1.AutoscalersClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new autoscalersModule.v1.AutoscalersClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.autoscalersStub, undefined); + await client.initialize(); + assert(client.autoscalersStub); + }); + + it('has close method for the initialized client', done => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.autoscalersStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.autoscalersStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + 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 autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAutoscalerRequest', ['autoscaler']); + request.autoscaler = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&autoscaler=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAutoscalerRequest', ['autoscaler']); + request.autoscaler = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&autoscaler=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAutoscalerRequest', ['autoscaler']); + request.autoscaler = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&autoscaler=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAutoscalerRequest', ['autoscaler']); + request.autoscaler = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAutoscalerRequest', ['autoscaler']); + request.autoscaler = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&autoscaler=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Autoscaler() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAutoscalerRequest', ['autoscaler']); + request.autoscaler = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&autoscaler=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Autoscaler() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IAutoscaler|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAutoscalerRequest', ['autoscaler']); + request.autoscaler = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&autoscaler=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAutoscalerRequest', ['autoscaler']); + request.autoscaler = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAutoscalerRequest', ['zone']); + request.zone = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListAutoscalersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListAutoscalersRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.AutoscalersScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.AutoscalersScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.AutoscalersScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IAutoscalersScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListAutoscalersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListAutoscalersRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IAutoscalersScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAutoscalersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAutoscalersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAutoscalersRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAutoscalersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAutoscalersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAutoscalersRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IAutoscaler[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAutoscalersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAutoscalersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAutoscalersRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAutoscalersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAutoscalersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAutoscalersRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Autoscaler[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Autoscaler) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAutoscalersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAutoscalersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAutoscalersRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Autoscaler[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Autoscaler) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAutoscalersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAutoscalersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAutoscalersRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IAutoscaler[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new autoscalersModule.v1.AutoscalersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAutoscalersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAutoscalersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAutoscalersRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IAutoscaler[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_backend_buckets_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_backend_buckets_v1.ts new file mode 100644 index 00000000000..a8b508c67b7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_backend_buckets_v1.ts @@ -0,0 +1,1401 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as backendbucketsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.BackendBucketsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = backendbucketsModule.v1.BackendBucketsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = backendbucketsModule.v1.BackendBucketsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = backendbucketsModule.v1.BackendBucketsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new backendbucketsModule.v1.BackendBucketsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.backendBucketsStub, undefined); + await client.initialize(); + assert(client.backendBucketsStub); + }); + + it('has close method for the initialized client', done => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.backendBucketsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.backendBucketsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + 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 backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + 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('addSignedUrlKey', () => { + it('invokes addSignedUrlKey without error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddSignedUrlKeyBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddSignedUrlKeyBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddSignedUrlKeyBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addSignedUrlKey = stubSimpleCall(expectedResponse); + const [response] = await client.addSignedUrlKey(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addSignedUrlKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addSignedUrlKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addSignedUrlKey without error using callback', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddSignedUrlKeyBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddSignedUrlKeyBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddSignedUrlKeyBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addSignedUrlKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addSignedUrlKey( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addSignedUrlKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addSignedUrlKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addSignedUrlKey with error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddSignedUrlKeyBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddSignedUrlKeyBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddSignedUrlKeyBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addSignedUrlKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addSignedUrlKey(request), expectedError); + const actualRequest = (client.innerApiCalls.addSignedUrlKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addSignedUrlKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addSignedUrlKey with closed client', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddSignedUrlKeyBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddSignedUrlKeyBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddSignedUrlKeyBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addSignedUrlKey(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('deleteSignedUrlKey', () => { + it('invokes deleteSignedUrlKey without error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSignedUrlKeyBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSignedUrlKeyBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSignedUrlKeyBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deleteSignedUrlKey = stubSimpleCall(expectedResponse); + const [response] = await client.deleteSignedUrlKey(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteSignedUrlKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSignedUrlKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSignedUrlKey without error using callback', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSignedUrlKeyBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSignedUrlKeyBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSignedUrlKeyBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deleteSignedUrlKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSignedUrlKey( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteSignedUrlKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSignedUrlKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSignedUrlKey with error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSignedUrlKeyBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSignedUrlKeyBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSignedUrlKeyBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSignedUrlKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteSignedUrlKey(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteSignedUrlKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSignedUrlKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSignedUrlKey with closed client', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSignedUrlKeyBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSignedUrlKeyBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSignedUrlKeyBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteSignedUrlKey(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.BackendBucket() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.BackendBucket() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IBackendBucket|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertBackendBucketRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertBackendBucketRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertBackendBucketRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertBackendBucketRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('setEdgeSecurityPolicy', () => { + it('invokes setEdgeSecurityPolicy without error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setEdgeSecurityPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setEdgeSecurityPolicy(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setEdgeSecurityPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setEdgeSecurityPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setEdgeSecurityPolicy without error using callback', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setEdgeSecurityPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setEdgeSecurityPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setEdgeSecurityPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setEdgeSecurityPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setEdgeSecurityPolicy with error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setEdgeSecurityPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setEdgeSecurityPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setEdgeSecurityPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setEdgeSecurityPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setEdgeSecurityPolicy with closed client', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setEdgeSecurityPolicy(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_bucket=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateBackendBucketRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateBackendBucketRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateBackendBucketRequest', ['backendBucket']); + request.backendBucket = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListBackendBucketsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListBackendBucketsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.BackendBucket()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendBucket()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendBucket()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListBackendBucketsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListBackendBucketsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.BackendBucket()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendBucket()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendBucket()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IBackendBucket[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListBackendBucketsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListBackendBucketsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListBackendBucketsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListBackendBucketsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.BackendBucket()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendBucket()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendBucket()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.BackendBucket[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.BackendBucket) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListBackendBucketsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListBackendBucketsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.BackendBucket[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.BackendBucket) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListBackendBucketsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListBackendBucketsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.BackendBucket()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendBucket()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendBucket()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IBackendBucket[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new backendbucketsModule.v1.BackendBucketsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListBackendBucketsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListBackendBucketsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IBackendBucket[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_backend_services_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_backend_services_v1.ts new file mode 100644 index 00000000000..7d00c089460 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_backend_services_v1.ts @@ -0,0 +1,1953 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as backendservicesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.BackendServicesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = backendservicesModule.v1.BackendServicesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = backendservicesModule.v1.BackendServicesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = backendservicesModule.v1.BackendServicesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new backendservicesModule.v1.BackendServicesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.backendServicesStub, undefined); + await client.initialize(); + assert(client.backendServicesStub); + }); + + it('has close method for the initialized client', done => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.backendServicesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.backendServicesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + 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 backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + 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('addSignedUrlKey', () => { + it('invokes addSignedUrlKey without error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddSignedUrlKeyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddSignedUrlKeyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddSignedUrlKeyBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addSignedUrlKey = stubSimpleCall(expectedResponse); + const [response] = await client.addSignedUrlKey(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addSignedUrlKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addSignedUrlKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addSignedUrlKey without error using callback', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddSignedUrlKeyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddSignedUrlKeyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddSignedUrlKeyBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addSignedUrlKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addSignedUrlKey( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addSignedUrlKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addSignedUrlKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addSignedUrlKey with error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddSignedUrlKeyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddSignedUrlKeyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddSignedUrlKeyBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addSignedUrlKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addSignedUrlKey(request), expectedError); + const actualRequest = (client.innerApiCalls.addSignedUrlKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addSignedUrlKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addSignedUrlKey with closed client', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddSignedUrlKeyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddSignedUrlKeyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddSignedUrlKeyBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addSignedUrlKey(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('deleteSignedUrlKey', () => { + it('invokes deleteSignedUrlKey without error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSignedUrlKeyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSignedUrlKeyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSignedUrlKeyBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deleteSignedUrlKey = stubSimpleCall(expectedResponse); + const [response] = await client.deleteSignedUrlKey(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteSignedUrlKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSignedUrlKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSignedUrlKey without error using callback', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSignedUrlKeyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSignedUrlKeyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSignedUrlKeyBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deleteSignedUrlKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSignedUrlKey( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteSignedUrlKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSignedUrlKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSignedUrlKey with error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSignedUrlKeyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSignedUrlKeyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSignedUrlKeyBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSignedUrlKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteSignedUrlKey(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteSignedUrlKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSignedUrlKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSignedUrlKey with closed client', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSignedUrlKeyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSignedUrlKeyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSignedUrlKeyBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteSignedUrlKey(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.BackendService() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.BackendService() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IBackendService|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getHealth', () => { + it('invokes getHealth without error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetHealthBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.BackendServiceGroupHealth() + ); + client.innerApiCalls.getHealth = stubSimpleCall(expectedResponse); + const [response] = await client.getHealth(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getHealth without error using callback', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetHealthBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.BackendServiceGroupHealth() + ); + client.innerApiCalls.getHealth = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getHealth( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IBackendServiceGroupHealth|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getHealth with error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetHealthBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getHealth = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getHealth(request), expectedError); + const actualRequest = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getHealth with closed client', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetHealthBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getHealth(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyBackendServiceRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyBackendServiceRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyBackendServiceRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyBackendServiceRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertBackendServiceRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertBackendServiceRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertBackendServiceRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertBackendServiceRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('setEdgeSecurityPolicy', () => { + it('invokes setEdgeSecurityPolicy without error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setEdgeSecurityPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setEdgeSecurityPolicy(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setEdgeSecurityPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setEdgeSecurityPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setEdgeSecurityPolicy without error using callback', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setEdgeSecurityPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setEdgeSecurityPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setEdgeSecurityPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setEdgeSecurityPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setEdgeSecurityPolicy with error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setEdgeSecurityPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setEdgeSecurityPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setEdgeSecurityPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setEdgeSecurityPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setEdgeSecurityPolicy with closed client', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetEdgeSecurityPolicyBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setEdgeSecurityPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyBackendServiceRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyBackendServiceRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyBackendServiceRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyBackendServiceRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('setSecurityPolicy', () => { + it('invokes setSecurityPolicy without error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSecurityPolicyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSecurityPolicyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSecurityPolicyBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setSecurityPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setSecurityPolicy(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setSecurityPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSecurityPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSecurityPolicy without error using callback', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSecurityPolicyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSecurityPolicyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSecurityPolicyBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setSecurityPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setSecurityPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setSecurityPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSecurityPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSecurityPolicy with error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSecurityPolicyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSecurityPolicyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSecurityPolicyBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setSecurityPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setSecurityPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setSecurityPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSecurityPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSecurityPolicy with closed client', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSecurityPolicyBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSecurityPolicyBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSecurityPolicyBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setSecurityPolicy(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&backend_service=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateBackendServiceRequest', ['backendService']); + request.backendService = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListBackendServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListBackendServicesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.BackendServicesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.BackendServicesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.BackendServicesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IBackendServicesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListBackendServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListBackendServicesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IBackendServicesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListBackendServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListBackendServicesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListBackendServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListBackendServicesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IBackendService[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListBackendServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListBackendServicesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListBackendServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListBackendServicesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.BackendService[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.BackendService) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListBackendServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListBackendServicesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.BackendService[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.BackendService) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListBackendServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListBackendServicesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IBackendService[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new backendservicesModule.v1.BackendServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListBackendServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListBackendServicesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IBackendService[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_disk_types_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_disk_types_v1.ts new file mode 100644 index 00000000000..7f85f470b77 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_disk_types_v1.ts @@ -0,0 +1,678 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as disktypesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.DiskTypesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = disktypesModule.v1.DiskTypesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = disktypesModule.v1.DiskTypesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = disktypesModule.v1.DiskTypesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new disktypesModule.v1.DiskTypesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new disktypesModule.v1.DiskTypesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new disktypesModule.v1.DiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.diskTypesStub, undefined); + await client.initialize(); + assert(client.diskTypesStub); + }); + + it('has close method for the initialized client', done => { + const client = new disktypesModule.v1.DiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.diskTypesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new disktypesModule.v1.DiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.diskTypesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new disktypesModule.v1.DiskTypesClient({ + auth: googleAuth, + 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 disktypesModule.v1.DiskTypesClient({ + auth: googleAuth, + 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('get', () => { + it('invokes get without error', async () => { + const client = new disktypesModule.v1.DiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetDiskTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskTypeRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskTypeRequest', ['diskType']); + request.diskType = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk_type=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.DiskType() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new disktypesModule.v1.DiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetDiskTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskTypeRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskTypeRequest', ['diskType']); + request.diskType = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk_type=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.DiskType() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IDiskType|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new disktypesModule.v1.DiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetDiskTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskTypeRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskTypeRequest', ['diskType']); + request.diskType = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk_type=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new disktypesModule.v1.DiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetDiskTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskTypeRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskTypeRequest', ['diskType']); + request.diskType = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new disktypesModule.v1.DiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListDiskTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListDiskTypesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.DiskTypesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.DiskTypesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.DiskTypesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IDiskTypesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new disktypesModule.v1.DiskTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListDiskTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListDiskTypesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IDiskTypesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new disktypesModule.v1.DiskTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListDiskTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDiskTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDiskTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new disktypesModule.v1.DiskTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListDiskTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDiskTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDiskTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IDiskType[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new disktypesModule.v1.DiskTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListDiskTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDiskTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDiskTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new disktypesModule.v1.DiskTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListDiskTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDiskTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDiskTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.DiskType[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.DiskType) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new disktypesModule.v1.DiskTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListDiskTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDiskTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDiskTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.DiskType[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.DiskType) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new disktypesModule.v1.DiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListDiskTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDiskTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDiskTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IDiskType[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new disktypesModule.v1.DiskTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListDiskTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDiskTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDiskTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IDiskType[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_disks_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_disks_v1.ts new file mode 100644 index 00000000000..2fe72765400 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_disks_v1.ts @@ -0,0 +1,2118 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as disksModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.DisksClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = disksModule.v1.DisksClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = disksModule.v1.DisksClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = disksModule.v1.DisksClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new disksModule.v1.DisksClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new disksModule.v1.DisksClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.disksStub, undefined); + await client.initialize(); + assert(client.disksStub); + }); + + it('has close method for the initialized client', done => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.disksStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.disksStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + 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 disksModule.v1.DisksClient({ + auth: googleAuth, + 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('addResourcePolicies', () => { + it('invokes addResourcePolicies without error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddResourcePoliciesDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addResourcePolicies = stubSimpleCall(expectedResponse); + const [response] = await client.addResourcePolicies(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addResourcePolicies without error using callback', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddResourcePoliciesDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addResourcePolicies = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addResourcePolicies( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addResourcePolicies with error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddResourcePoliciesDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addResourcePolicies = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addResourcePolicies(request), expectedError); + const actualRequest = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addResourcePolicies with closed client', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddResourcePoliciesDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addResourcePolicies(request), expectedError); + }); + }); + + describe('createSnapshot', () => { + it('invokes createSnapshot without error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CreateSnapshotDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.createSnapshot = stubSimpleCall(expectedResponse); + const [response] = await client.createSnapshot(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.createSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSnapshot without error using callback', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CreateSnapshotDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.createSnapshot = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSnapshot( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSnapshot with error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CreateSnapshotDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSnapshot = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createSnapshot(request), expectedError); + const actualRequest = (client.innerApiCalls.createSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSnapshot with closed client', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CreateSnapshotDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createSnapshot(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Disk() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Disk() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IDisk|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertDiskRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertDiskRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertDiskRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertDiskRequest', ['zone']); + request.zone = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('removeResourcePolicies', () => { + it('invokes removeResourcePolicies without error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveResourcePoliciesDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeResourcePolicies = stubSimpleCall(expectedResponse); + const [response] = await client.removeResourcePolicies(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeResourcePolicies without error using callback', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveResourcePoliciesDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeResourcePolicies = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeResourcePolicies( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeResourcePolicies with error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveResourcePoliciesDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeResourcePolicies = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeResourcePolicies(request), expectedError); + const actualRequest = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeResourcePolicies with closed client', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveResourcePoliciesDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeResourcePolicies(request), expectedError); + }); + }); + + describe('resize', () => { + it('invokes resize without error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.resize = stubSimpleCall(expectedResponse); + const [response] = await client.resize(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resize without error using callback', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.resize = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resize( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resize with error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resize = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.resize(request), expectedError); + const actualRequest = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resize with closed client', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resize(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('setLabels', () => { + it('invokes setLabels without error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCall(expectedResponse); + const [response] = await client.setLabels(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels without error using callback', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setLabels( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setLabels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with closed client', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setLabels(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&disk=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDiskRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListDisksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListDisksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.DisksScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.DisksScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.DisksScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IDisksScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new disksModule.v1.DisksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListDisksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListDisksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IDisksScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new disksModule.v1.DisksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListDisksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDisksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDisksRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new disksModule.v1.DisksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListDisksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDisksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDisksRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IDisk[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new disksModule.v1.DisksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListDisksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDisksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDisksRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new disksModule.v1.DisksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListDisksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDisksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDisksRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Disk[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Disk) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new disksModule.v1.DisksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListDisksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDisksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDisksRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Disk[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Disk) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new disksModule.v1.DisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListDisksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDisksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDisksRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IDisk[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new disksModule.v1.DisksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListDisksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDisksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListDisksRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IDisk[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_external_vpn_gateways_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_external_vpn_gateways_v1.ts new file mode 100644 index 00000000000..dfa40118cc9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_external_vpn_gateways_v1.ts @@ -0,0 +1,1041 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as externalvpngatewaysModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.ExternalVpnGatewaysClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = externalvpngatewaysModule.v1.ExternalVpnGatewaysClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = externalvpngatewaysModule.v1.ExternalVpnGatewaysClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = externalvpngatewaysModule.v1.ExternalVpnGatewaysClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.externalVpnGatewaysStub, undefined); + await client.initialize(); + assert(client.externalVpnGatewaysStub); + }); + + it('has close method for the initialized client', done => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.externalVpnGatewaysStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.externalVpnGatewaysStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + 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 externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteExternalVpnGatewayRequest', ['externalVpnGateway']); + request.externalVpnGateway = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&external_vpn_gateway=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteExternalVpnGatewayRequest', ['externalVpnGateway']); + request.externalVpnGateway = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&external_vpn_gateway=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteExternalVpnGatewayRequest', ['externalVpnGateway']); + request.externalVpnGateway = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&external_vpn_gateway=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteExternalVpnGatewayRequest', ['externalVpnGateway']); + request.externalVpnGateway = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetExternalVpnGatewayRequest', ['externalVpnGateway']); + request.externalVpnGateway = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&external_vpn_gateway=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.ExternalVpnGateway() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetExternalVpnGatewayRequest', ['externalVpnGateway']); + request.externalVpnGateway = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&external_vpn_gateway=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.ExternalVpnGateway() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IExternalVpnGateway|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetExternalVpnGatewayRequest', ['externalVpnGateway']); + request.externalVpnGateway = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&external_vpn_gateway=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetExternalVpnGatewayRequest', ['externalVpnGateway']); + request.externalVpnGateway = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('setLabels', () => { + it('invokes setLabels without error', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsExternalVpnGatewayRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCall(expectedResponse); + const [response] = await client.setLabels(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels without error using callback', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsExternalVpnGatewayRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setLabels( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with error', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsExternalVpnGatewayRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setLabels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with closed client', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsExternalVpnGatewayRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setLabels(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsExternalVpnGatewayRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsExternalVpnGatewayRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsExternalVpnGatewayRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsExternalVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsExternalVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsExternalVpnGatewayRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListExternalVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListExternalVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ExternalVpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.ExternalVpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.ExternalVpnGateway()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListExternalVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListExternalVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ExternalVpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.ExternalVpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.ExternalVpnGateway()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IExternalVpnGateway[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListExternalVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListExternalVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListExternalVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListExternalVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ExternalVpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.ExternalVpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.ExternalVpnGateway()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.ExternalVpnGateway[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.ExternalVpnGateway) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListExternalVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListExternalVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.ExternalVpnGateway[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.ExternalVpnGateway) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListExternalVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListExternalVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ExternalVpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.ExternalVpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.ExternalVpnGateway()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IExternalVpnGateway[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new externalvpngatewaysModule.v1.ExternalVpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListExternalVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListExternalVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IExternalVpnGateway[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_firewall_policies_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_firewall_policies_v1.ts new file mode 100644 index 00000000000..186374275db --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_firewall_policies_v1.ts @@ -0,0 +1,2153 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as firewallpoliciesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.FirewallPoliciesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = firewallpoliciesModule.v1.FirewallPoliciesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = firewallpoliciesModule.v1.FirewallPoliciesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = firewallpoliciesModule.v1.FirewallPoliciesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.firewallPoliciesStub, undefined); + await client.initialize(); + assert(client.firewallPoliciesStub); + }); + + it('has close method for the initialized client', done => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.firewallPoliciesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.firewallPoliciesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + 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 firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + 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('addAssociation', () => { + it('invokes addAssociation without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddAssociationFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addAssociation = stubSimpleCall(expectedResponse); + const [response] = await client.addAssociation(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addAssociation without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddAssociationFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addAssociation = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addAssociation( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addAssociation with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddAssociationFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addAssociation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addAssociation(request), expectedError); + const actualRequest = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addAssociation with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddAssociationFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addAssociation(request), expectedError); + }); + }); + + describe('addRule', () => { + it('invokes addRule without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddRuleFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addRule = stubSimpleCall(expectedResponse); + const [response] = await client.addRule(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addRule without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddRuleFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addRule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addRule( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addRule with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddRuleFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addRule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addRule(request), expectedError); + const actualRequest = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addRule with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddRuleFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addRule(request), expectedError); + }); + }); + + describe('cloneRules', () => { + it('invokes cloneRules without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CloneRulesFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.cloneRules = stubSimpleCall(expectedResponse); + const [response] = await client.cloneRules(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cloneRules without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CloneRulesFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.cloneRules = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.cloneRules( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cloneRules with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CloneRulesFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.cloneRules = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.cloneRules(request), expectedError); + const actualRequest = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cloneRules with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CloneRulesFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.cloneRules(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicy() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicy() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IFirewallPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getAssociation', () => { + it('invokes getAssociation without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAssociationFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicyAssociation() + ); + client.innerApiCalls.getAssociation = stubSimpleCall(expectedResponse); + const [response] = await client.getAssociation(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAssociation without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAssociationFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicyAssociation() + ); + client.innerApiCalls.getAssociation = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAssociation( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IFirewallPolicyAssociation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAssociation with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAssociationFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAssociation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAssociation(request), expectedError); + const actualRequest = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAssociation with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAssociationFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getAssociation(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyFirewallPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyFirewallPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyFirewallPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyFirewallPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('getRule', () => { + it('invokes getRule without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRuleFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicyRule() + ); + client.innerApiCalls.getRule = stubSimpleCall(expectedResponse); + const [response] = await client.getRule(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRule without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRuleFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicyRule() + ); + client.innerApiCalls.getRule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRule( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IFirewallPolicyRule|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRule with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRuleFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRule(request), expectedError); + const actualRequest = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRule with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRuleFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getRule(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertFirewallPolicyRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + }); + + it('invokes insert without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertFirewallPolicyRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes insert with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertFirewallPolicyRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + }); + + it('invokes insert with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertFirewallPolicyRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('listAssociations', () => { + it('invokes listAssociations without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAssociationsFirewallPolicyRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPoliciesListAssociationsResponse() + ); + client.innerApiCalls.listAssociations = stubSimpleCall(expectedResponse); + const [response] = await client.listAssociations(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listAssociations without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAssociationsFirewallPolicyRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPoliciesListAssociationsResponse() + ); + client.innerApiCalls.listAssociations = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAssociations( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IFirewallPoliciesListAssociationsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listAssociations with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAssociationsFirewallPolicyRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.listAssociations = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listAssociations(request), expectedError); + }); + + it('invokes listAssociations with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAssociationsFirewallPolicyRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.listAssociations(request), expectedError); + }); + }); + + describe('move', () => { + it('invokes move without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.MoveFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.MoveFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.move = stubSimpleCall(expectedResponse); + const [response] = await client.move(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.move as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.move as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes move without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.MoveFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.MoveFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.move = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.move( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.move as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.move as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes move with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.MoveFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.MoveFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.move = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.move(request), expectedError); + const actualRequest = (client.innerApiCalls.move as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.move as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes move with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.MoveFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.MoveFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.move(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('patchRule', () => { + it('invokes patchRule without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRuleFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patchRule = stubSimpleCall(expectedResponse); + const [response] = await client.patchRule(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchRule without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRuleFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patchRule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patchRule( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchRule with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRuleFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patchRule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patchRule(request), expectedError); + const actualRequest = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchRule with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRuleFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patchRule(request), expectedError); + }); + }); + + describe('removeAssociation', () => { + it('invokes removeAssociation without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveAssociationFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeAssociation = stubSimpleCall(expectedResponse); + const [response] = await client.removeAssociation(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeAssociation without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveAssociationFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeAssociation = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeAssociation( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeAssociation with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveAssociationFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeAssociation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeAssociation(request), expectedError); + const actualRequest = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeAssociation with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveAssociationFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeAssociation(request), expectedError); + }); + }); + + describe('removeRule', () => { + it('invokes removeRule without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeRule = stubSimpleCall(expectedResponse); + const [response] = await client.removeRule(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeRule without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeRule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeRule( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeRule with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedHeaderRequestParams = `firewall_policy=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeRule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeRule(request), expectedError); + const actualRequest = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeRule with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeRule(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyFirewallPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyFirewallPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyFirewallPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyFirewallPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsFirewallPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsFirewallPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsFirewallPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsFirewallPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListFirewallPoliciesRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes list without error using callback', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListFirewallPoliciesRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IFirewallPolicy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes list with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListFirewallPoliciesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + }); + + it('invokes listStream without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListFirewallPoliciesRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.FirewallPolicy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.FirewallPolicy) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + }); + + it('invokes listStream with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListFirewallPoliciesRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.FirewallPolicy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.FirewallPolicy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + }); + + it('uses async iteration with list without error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListFirewallPoliciesRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IFirewallPolicy[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with list with error', async () => { + const client = new firewallpoliciesModule.v1.FirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListFirewallPoliciesRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IFirewallPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_firewalls_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_firewalls_v1.ts new file mode 100644 index 00000000000..ffe7fa636fe --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_firewalls_v1.ts @@ -0,0 +1,1041 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as firewallsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.FirewallsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = firewallsModule.v1.FirewallsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = firewallsModule.v1.FirewallsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = firewallsModule.v1.FirewallsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new firewallsModule.v1.FirewallsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new firewallsModule.v1.FirewallsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.firewallsStub, undefined); + await client.initialize(); + assert(client.firewallsStub); + }); + + it('has close method for the initialized client', done => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.firewallsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.firewallsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + 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 firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteFirewallRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteFirewallRequest', ['firewall']); + request.firewall = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteFirewallRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteFirewallRequest', ['firewall']); + request.firewall = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteFirewallRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteFirewallRequest', ['firewall']); + request.firewall = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteFirewallRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteFirewallRequest', ['firewall']); + request.firewall = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFirewallRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFirewallRequest', ['firewall']); + request.firewall = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Firewall() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFirewallRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFirewallRequest', ['firewall']); + request.firewall = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Firewall() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IFirewall|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFirewallRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFirewallRequest', ['firewall']); + request.firewall = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFirewallRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFirewallRequest', ['firewall']); + request.firewall = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertFirewallRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertFirewallRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertFirewallRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertFirewallRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchFirewallRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchFirewallRequest', ['firewall']); + request.firewall = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchFirewallRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchFirewallRequest', ['firewall']); + request.firewall = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchFirewallRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchFirewallRequest', ['firewall']); + request.firewall = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchFirewallRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchFirewallRequest', ['firewall']); + request.firewall = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateFirewallRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateFirewallRequest', ['firewall']); + request.firewall = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateFirewallRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateFirewallRequest', ['firewall']); + request.firewall = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateFirewallRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateFirewallRequest', ['firewall']); + request.firewall = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateFirewallRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateFirewallRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateFirewallRequest', ['firewall']); + request.firewall = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListFirewallsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListFirewallsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Firewall()), + generateSampleMessage(new protos.google.cloud.compute.v1.Firewall()), + generateSampleMessage(new protos.google.cloud.compute.v1.Firewall()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListFirewallsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListFirewallsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Firewall()), + generateSampleMessage(new protos.google.cloud.compute.v1.Firewall()), + generateSampleMessage(new protos.google.cloud.compute.v1.Firewall()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IFirewall[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListFirewallsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListFirewallsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListFirewallsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListFirewallsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Firewall()), + generateSampleMessage(new protos.google.cloud.compute.v1.Firewall()), + generateSampleMessage(new protos.google.cloud.compute.v1.Firewall()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Firewall[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Firewall) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListFirewallsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListFirewallsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Firewall[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Firewall) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListFirewallsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListFirewallsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Firewall()), + generateSampleMessage(new protos.google.cloud.compute.v1.Firewall()), + generateSampleMessage(new protos.google.cloud.compute.v1.Firewall()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IFirewall[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new firewallsModule.v1.FirewallsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListFirewallsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListFirewallsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IFirewall[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_forwarding_rules_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_forwarding_rules_v1.ts new file mode 100644 index 00000000000..96a8f13bd12 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_forwarding_rules_v1.ts @@ -0,0 +1,1326 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as forwardingrulesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.ForwardingRulesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = forwardingrulesModule.v1.ForwardingRulesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = forwardingrulesModule.v1.ForwardingRulesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = forwardingrulesModule.v1.ForwardingRulesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.forwardingRulesStub, undefined); + await client.initialize(); + assert(client.forwardingRulesStub); + }); + + it('has close method for the initialized client', done => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.forwardingRulesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.forwardingRulesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + 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 forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&forwarding_rule=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&forwarding_rule=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&forwarding_rule=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&forwarding_rule=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.ForwardingRule() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&forwarding_rule=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.ForwardingRule() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IForwardingRule|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&forwarding_rule=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&forwarding_rule=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&forwarding_rule=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&forwarding_rule=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('setLabels', () => { + it('invokes setLabels without error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsForwardingRuleRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCall(expectedResponse); + const [response] = await client.setLabels(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels without error using callback', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsForwardingRuleRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setLabels( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsForwardingRuleRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setLabels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with closed client', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsForwardingRuleRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setLabels(request), expectedError); + }); + }); + + describe('setTarget', () => { + it('invokes setTarget without error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTargetForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&forwarding_rule=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setTarget = stubSimpleCall(expectedResponse); + const [response] = await client.setTarget(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setTarget as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setTarget as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setTarget without error using callback', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTargetForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&forwarding_rule=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setTarget = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setTarget( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setTarget as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setTarget as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setTarget with error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTargetForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&forwarding_rule=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setTarget = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setTarget(request), expectedError); + const actualRequest = (client.innerApiCalls.setTarget as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setTarget as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setTarget with closed client', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTargetForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetForwardingRuleRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setTarget(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListForwardingRulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListForwardingRulesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRulesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRulesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRulesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IForwardingRulesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListForwardingRulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListForwardingRulesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IForwardingRulesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListForwardingRulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListForwardingRulesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListForwardingRulesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListForwardingRulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListForwardingRulesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListForwardingRulesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IForwardingRule[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListForwardingRulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListForwardingRulesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListForwardingRulesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListForwardingRulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListForwardingRulesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListForwardingRulesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.ForwardingRule[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.ForwardingRule) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListForwardingRulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListForwardingRulesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListForwardingRulesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.ForwardingRule[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.ForwardingRule) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListForwardingRulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListForwardingRulesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListForwardingRulesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IForwardingRule[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new forwardingrulesModule.v1.ForwardingRulesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListForwardingRulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListForwardingRulesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListForwardingRulesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IForwardingRule[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_addresses_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_addresses_v1.ts new file mode 100644 index 00000000000..e96d5458ed2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_addresses_v1.ts @@ -0,0 +1,921 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as globaladdressesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.GlobalAddressesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = globaladdressesModule.v1.GlobalAddressesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = globaladdressesModule.v1.GlobalAddressesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = globaladdressesModule.v1.GlobalAddressesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.globalAddressesStub, undefined); + await client.initialize(); + assert(client.globalAddressesStub); + }); + + it('has close method for the initialized client', done => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.globalAddressesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.globalAddressesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + 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 globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalAddressRequest', ['address']); + request.address = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&address=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalAddressRequest', ['address']); + request.address = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&address=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalAddressRequest', ['address']); + request.address = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&address=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalAddressRequest', ['address']); + request.address = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalAddressRequest', ['address']); + request.address = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&address=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Address() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalAddressRequest', ['address']); + request.address = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&address=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Address() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IAddress|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalAddressRequest', ['address']); + request.address = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&address=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalAddressRequest', ['address']); + request.address = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertGlobalAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertGlobalAddressRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertGlobalAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertGlobalAddressRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertGlobalAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertGlobalAddressRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertGlobalAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertGlobalAddressRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('setLabels', () => { + it('invokes setLabels without error', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsGlobalAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsGlobalAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsGlobalAddressRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCall(expectedResponse); + const [response] = await client.setLabels(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels without error using callback', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsGlobalAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsGlobalAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsGlobalAddressRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setLabels( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with error', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsGlobalAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsGlobalAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsGlobalAddressRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setLabels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with closed client', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsGlobalAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsGlobalAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsGlobalAddressRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setLabels(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalAddressesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalAddressesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IAddress[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalAddressesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalAddressesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Address[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Address) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalAddressesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Address[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Address) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalAddressesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1.Address()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IAddress[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new globaladdressesModule.v1.GlobalAddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalAddressesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IAddress[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_forwarding_rules_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_forwarding_rules_v1.ts new file mode 100644 index 00000000000..cc525fb5003 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_forwarding_rules_v1.ts @@ -0,0 +1,1161 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as globalforwardingrulesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.GlobalForwardingRulesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = globalforwardingrulesModule.v1.GlobalForwardingRulesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = globalforwardingrulesModule.v1.GlobalForwardingRulesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = globalforwardingrulesModule.v1.GlobalForwardingRulesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.globalForwardingRulesStub, undefined); + await client.initialize(); + assert(client.globalForwardingRulesStub); + }); + + it('has close method for the initialized client', done => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.globalForwardingRulesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.globalForwardingRulesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + 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 globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&forwarding_rule=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&forwarding_rule=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&forwarding_rule=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&forwarding_rule=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.ForwardingRule() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&forwarding_rule=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.ForwardingRule() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IForwardingRule|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&forwarding_rule=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchGlobalForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&forwarding_rule=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchGlobalForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&forwarding_rule=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchGlobalForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&forwarding_rule=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchGlobalForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('setLabels', () => { + it('invokes setLabels without error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsGlobalForwardingRuleRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCall(expectedResponse); + const [response] = await client.setLabels(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels without error using callback', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsGlobalForwardingRuleRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setLabels( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsGlobalForwardingRuleRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setLabels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with closed client', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsGlobalForwardingRuleRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setLabels(request), expectedError); + }); + }); + + describe('setTarget', () => { + it('invokes setTarget without error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTargetGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetGlobalForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&forwarding_rule=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setTarget = stubSimpleCall(expectedResponse); + const [response] = await client.setTarget(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setTarget as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setTarget as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setTarget without error using callback', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTargetGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetGlobalForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&forwarding_rule=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setTarget = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setTarget( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setTarget as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setTarget as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setTarget with error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTargetGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetGlobalForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&forwarding_rule=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setTarget = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setTarget(request), expectedError); + const actualRequest = (client.innerApiCalls.setTarget as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setTarget as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setTarget with closed client', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTargetGlobalForwardingRuleRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetGlobalForwardingRuleRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetGlobalForwardingRuleRequest', ['forwardingRule']); + request.forwardingRule = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setTarget(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalForwardingRulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalForwardingRulesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalForwardingRulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalForwardingRulesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IForwardingRule[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalForwardingRulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalForwardingRulesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalForwardingRulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalForwardingRulesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.ForwardingRule[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.ForwardingRule) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalForwardingRulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalForwardingRulesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.ForwardingRule[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.ForwardingRule) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalForwardingRulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalForwardingRulesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + generateSampleMessage(new protos.google.cloud.compute.v1.ForwardingRule()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IForwardingRule[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new globalforwardingrulesModule.v1.GlobalForwardingRulesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalForwardingRulesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalForwardingRulesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IForwardingRule[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_network_endpoint_groups_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_network_endpoint_groups_v1.ts new file mode 100644 index 00000000000..be092acb4d7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_network_endpoint_groups_v1.ts @@ -0,0 +1,1307 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as globalnetworkendpointgroupsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.GlobalNetworkEndpointGroupsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.globalNetworkEndpointGroupsStub, undefined); + await client.initialize(); + assert(client.globalNetworkEndpointGroupsStub); + }); + + it('has close method for the initialized client', done => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.globalNetworkEndpointGroupsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.globalNetworkEndpointGroupsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + 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 globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + 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('attachNetworkEndpoints', () => { + it('invokes attachNetworkEndpoints without error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.attachNetworkEndpoints = stubSimpleCall(expectedResponse); + const [response] = await client.attachNetworkEndpoints(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.attachNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.attachNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes attachNetworkEndpoints without error using callback', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.attachNetworkEndpoints = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.attachNetworkEndpoints( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.attachNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.attachNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes attachNetworkEndpoints with error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.attachNetworkEndpoints = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.attachNetworkEndpoints(request), expectedError); + const actualRequest = (client.innerApiCalls.attachNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.attachNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes attachNetworkEndpoints with closed client', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.attachNetworkEndpoints(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('detachNetworkEndpoints', () => { + it('invokes detachNetworkEndpoints without error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.detachNetworkEndpoints = stubSimpleCall(expectedResponse); + const [response] = await client.detachNetworkEndpoints(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.detachNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.detachNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes detachNetworkEndpoints without error using callback', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.detachNetworkEndpoints = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.detachNetworkEndpoints( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.detachNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.detachNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes detachNetworkEndpoints with error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.detachNetworkEndpoints = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.detachNetworkEndpoints(request), expectedError); + const actualRequest = (client.innerApiCalls.detachNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.detachNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes detachNetworkEndpoints with closed client', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.detachNetworkEndpoints(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NetworkEndpointGroup() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NetworkEndpointGroup() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INetworkEndpointGroup|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertGlobalNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertGlobalNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INetworkEndpointGroup[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NetworkEndpointGroup[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NetworkEndpointGroup) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NetworkEndpointGroup[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NetworkEndpointGroup) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.INetworkEndpointGroup[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.INetworkEndpointGroup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listNetworkEndpoints', () => { + it('invokes listNetworkEndpoints without error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + ]; + client.innerApiCalls.listNetworkEndpoints = stubSimpleCall(expectedResponse); + const [response] = await client.listNetworkEndpoints(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNetworkEndpoints without error using callback', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + ]; + client.innerApiCalls.listNetworkEndpoints = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listNetworkEndpoints( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNetworkEndpoints with error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listNetworkEndpoints = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listNetworkEndpoints(request), expectedError); + const actualRequest = (client.innerApiCalls.listNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNetworkEndpointsStream without error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + ]; + client.descriptors.page.listNetworkEndpoints.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listNetworkEndpointsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus) => { + 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.listNetworkEndpoints.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNetworkEndpoints, request)); + assert( + (client.descriptors.page.listNetworkEndpoints.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listNetworkEndpointsStream with error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.listNetworkEndpoints.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listNetworkEndpointsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listNetworkEndpoints.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNetworkEndpoints, request)); + assert( + (client.descriptors.page.listNetworkEndpoints.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listNetworkEndpoints without error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + ]; + client.descriptors.page.listNetworkEndpoints.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus[] = []; + const iterable = client.listNetworkEndpointsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listNetworkEndpoints.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listNetworkEndpoints.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listNetworkEndpoints with error', async () => { + const client = new globalnetworkendpointgroupsModule.v1.GlobalNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network_endpoint_group=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.listNetworkEndpoints.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listNetworkEndpointsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listNetworkEndpoints.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listNetworkEndpoints.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_operations_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_operations_v1.ts new file mode 100644 index 00000000000..5536748bc08 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_operations_v1.ts @@ -0,0 +1,885 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as globaloperationsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.GlobalOperationsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = globaloperationsModule.v1.GlobalOperationsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = globaloperationsModule.v1.GlobalOperationsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = globaloperationsModule.v1.GlobalOperationsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.globalOperationsStub, undefined); + await client.initialize(); + assert(client.globalOperationsStub); + }); + + it('has close method for the initialized client', done => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.globalOperationsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.globalOperationsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + 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 globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalOperationRequest', ['operation']); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&operation=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalOperationResponse() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalOperationRequest', ['operation']); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&operation=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalOperationResponse() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IDeleteGlobalOperationResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalOperationRequest', ['operation']); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&operation=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalOperationRequest', ['operation']); + request.operation = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalOperationRequest', ['operation']); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&operation=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalOperationRequest', ['operation']); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&operation=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalOperationRequest', ['operation']); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&operation=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalOperationRequest', ['operation']); + request.operation = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('wait', () => { + it('invokes wait without error', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.WaitGlobalOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitGlobalOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitGlobalOperationRequest', ['operation']); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&operation=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.wait = stubSimpleCall(expectedResponse); + const [response] = await client.wait(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes wait without error using callback', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.WaitGlobalOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitGlobalOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitGlobalOperationRequest', ['operation']); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&operation=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.wait = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.wait( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes wait with error', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.WaitGlobalOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitGlobalOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitGlobalOperationRequest', ['operation']); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&operation=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.wait = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.wait(request), expectedError); + const actualRequest = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes wait with closed client', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.WaitGlobalOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitGlobalOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitGlobalOperationRequest', ['operation']); + request.operation = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.wait(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListGlobalOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListGlobalOperationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.OperationsScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.OperationsScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.OperationsScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IOperationsScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListGlobalOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListGlobalOperationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IOperationsScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalOperationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalOperationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalOperationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalOperationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Operation[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Operation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalOperationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Operation[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Operation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalOperationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IOperation[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new globaloperationsModule.v1.GlobalOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalOperationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_organization_operations_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_organization_operations_v1.ts new file mode 100644 index 00000000000..e98759ba2c8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_organization_operations_v1.ts @@ -0,0 +1,599 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as globalorganizationoperationsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.GlobalOrganizationOperationsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.globalOrganizationOperationsStub, undefined); + await client.initialize(); + assert(client.globalOrganizationOperationsStub); + }); + + it('has close method for the initialized client', done => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.globalOrganizationOperationsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.globalOrganizationOperationsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + auth: googleAuth, + 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 globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalOrganizationOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalOrganizationOperationRequest', ['operation']); + request.operation = defaultValue1; + const expectedHeaderRequestParams = `operation=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalOrganizationOperationResponse() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalOrganizationOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalOrganizationOperationRequest', ['operation']); + request.operation = defaultValue1; + const expectedHeaderRequestParams = `operation=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalOrganizationOperationResponse() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IDeleteGlobalOrganizationOperationResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalOrganizationOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalOrganizationOperationRequest', ['operation']); + request.operation = defaultValue1; + const expectedHeaderRequestParams = `operation=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalOrganizationOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalOrganizationOperationRequest', ['operation']); + request.operation = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalOrganizationOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalOrganizationOperationRequest', ['operation']); + request.operation = defaultValue1; + const expectedHeaderRequestParams = `operation=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalOrganizationOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalOrganizationOperationRequest', ['operation']); + request.operation = defaultValue1; + const expectedHeaderRequestParams = `operation=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalOrganizationOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalOrganizationOperationRequest', ['operation']); + request.operation = defaultValue1; + const expectedHeaderRequestParams = `operation=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalOrganizationOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalOrganizationOperationRequest', ['operation']); + request.operation = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalOrganizationOperationsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes list without error using callback', async () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalOrganizationOperationsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes list with error', async () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalOrganizationOperationsRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + }); + + it('invokes listStream without error', async () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalOrganizationOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Operation[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Operation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + }); + + it('invokes listStream with error', async () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalOrganizationOperationsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Operation[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Operation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + }); + + it('uses async iteration with list without error', async () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalOrganizationOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IOperation[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with list with error', async () => { + const client = new globalorganizationoperationsModule.v1.GlobalOrganizationOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalOrganizationOperationsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_public_delegated_prefixes_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_public_delegated_prefixes_v1.ts new file mode 100644 index 00000000000..1f7cdafabb6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_global_public_delegated_prefixes_v1.ts @@ -0,0 +1,921 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as globalpublicdelegatedprefixesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.GlobalPublicDelegatedPrefixesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.globalPublicDelegatedPrefixesStub, undefined); + await client.initialize(); + assert(client.globalPublicDelegatedPrefixesStub); + }); + + it('has close method for the initialized client', done => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.globalPublicDelegatedPrefixesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.globalPublicDelegatedPrefixesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + 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 globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_delegated_prefix=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_delegated_prefix=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_delegated_prefix=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteGlobalPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteGlobalPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_delegated_prefix=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.PublicDelegatedPrefix() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_delegated_prefix=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.PublicDelegatedPrefix() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPublicDelegatedPrefix|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_delegated_prefix=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGlobalPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGlobalPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertGlobalPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertGlobalPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertGlobalPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertGlobalPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertGlobalPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertGlobalPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertGlobalPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertGlobalPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchGlobalPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchGlobalPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchGlobalPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_delegated_prefix=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchGlobalPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchGlobalPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchGlobalPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_delegated_prefix=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchGlobalPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchGlobalPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchGlobalPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_delegated_prefix=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchGlobalPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchGlobalPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchGlobalPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalPublicDelegatedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalPublicDelegatedPrefixesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalPublicDelegatedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalPublicDelegatedPrefixesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPublicDelegatedPrefix[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalPublicDelegatedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalPublicDelegatedPrefixesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalPublicDelegatedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalPublicDelegatedPrefixesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.PublicDelegatedPrefix[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.PublicDelegatedPrefix) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalPublicDelegatedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalPublicDelegatedPrefixesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.PublicDelegatedPrefix[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.PublicDelegatedPrefix) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalPublicDelegatedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalPublicDelegatedPrefixesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IPublicDelegatedPrefix[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new globalpublicdelegatedprefixesModule.v1.GlobalPublicDelegatedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListGlobalPublicDelegatedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListGlobalPublicDelegatedPrefixesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IPublicDelegatedPrefix[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_health_checks_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_health_checks_v1.ts new file mode 100644 index 00000000000..337363d52e8 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_health_checks_v1.ts @@ -0,0 +1,1113 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as healthchecksModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.HealthChecksClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = healthchecksModule.v1.HealthChecksClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = healthchecksModule.v1.HealthChecksClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = healthchecksModule.v1.HealthChecksClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new healthchecksModule.v1.HealthChecksClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.healthChecksStub, undefined); + await client.initialize(); + assert(client.healthChecksStub); + }); + + it('has close method for the initialized client', done => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.healthChecksStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.healthChecksStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + 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 healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&health_check=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&health_check=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&health_check=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&health_check=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.HealthCheck() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&health_check=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.HealthCheck() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IHealthCheck|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&health_check=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertHealthCheckRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertHealthCheckRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertHealthCheckRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertHealthCheckRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&health_check=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&health_check=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&health_check=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&health_check=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&health_check=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&health_check=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListHealthChecksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListHealthChecksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.HealthChecksScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.HealthChecksScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.HealthChecksScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IHealthChecksScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListHealthChecksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListHealthChecksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IHealthChecksScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListHealthChecksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListHealthChecksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListHealthChecksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListHealthChecksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IHealthCheck[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListHealthChecksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListHealthChecksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListHealthChecksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListHealthChecksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.HealthCheck[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.HealthCheck) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListHealthChecksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListHealthChecksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.HealthCheck[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.HealthCheck) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListHealthChecksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListHealthChecksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IHealthCheck[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new healthchecksModule.v1.HealthChecksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListHealthChecksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListHealthChecksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IHealthCheck[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_image_family_views_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_image_family_views_v1.ts new file mode 100644 index 00000000000..a57e65975a6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_image_family_views_v1.ts @@ -0,0 +1,293 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as imagefamilyviewsModule from '../src'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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); +} + +describe('v1.ImageFamilyViewsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imagefamilyviewsModule.v1.ImageFamilyViewsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imagefamilyviewsModule.v1.ImageFamilyViewsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imagefamilyviewsModule.v1.ImageFamilyViewsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imagefamilyviewsModule.v1.ImageFamilyViewsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imagefamilyviewsModule.v1.ImageFamilyViewsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imagefamilyviewsModule.v1.ImageFamilyViewsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.imageFamilyViewsStub, undefined); + await client.initialize(); + assert(client.imageFamilyViewsStub); + }); + + it('has close method for the initialized client', done => { + const client = new imagefamilyviewsModule.v1.ImageFamilyViewsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageFamilyViewsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imagefamilyviewsModule.v1.ImageFamilyViewsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.imageFamilyViewsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imagefamilyviewsModule.v1.ImageFamilyViewsClient({ + auth: googleAuth, + 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 imagefamilyviewsModule.v1.ImageFamilyViewsClient({ + auth: googleAuth, + 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('get', () => { + it('invokes get without error', async () => { + const client = new imagefamilyviewsModule.v1.ImageFamilyViewsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetImageFamilyViewRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageFamilyViewRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageFamilyViewRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageFamilyViewRequest', ['family']); + request.family = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&family=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.ImageFamilyView() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new imagefamilyviewsModule.v1.ImageFamilyViewsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetImageFamilyViewRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageFamilyViewRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageFamilyViewRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageFamilyViewRequest', ['family']); + request.family = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&family=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.ImageFamilyView() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IImageFamilyView|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new imagefamilyviewsModule.v1.ImageFamilyViewsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetImageFamilyViewRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageFamilyViewRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageFamilyViewRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageFamilyViewRequest', ['family']); + request.family = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&family=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new imagefamilyviewsModule.v1.ImageFamilyViewsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetImageFamilyViewRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageFamilyViewRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageFamilyViewRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageFamilyViewRequest', ['family']); + request.family = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_images_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_images_v1.ts new file mode 100644 index 00000000000..fed12b1903c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_images_v1.ts @@ -0,0 +1,1641 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as imagesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.ImagesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imagesModule.v1.ImagesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imagesModule.v1.ImagesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imagesModule.v1.ImagesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imagesModule.v1.ImagesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imagesModule.v1.ImagesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.imagesStub, undefined); + await client.initialize(); + assert(client.imagesStub); + }); + + it('has close method for the initialized client', done => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imagesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.imagesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + 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 imagesModule.v1.ImagesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteImageRequest', ['image']); + request.image = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&image=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteImageRequest', ['image']); + request.image = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&image=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteImageRequest', ['image']); + request.image = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&image=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteImageRequest', ['image']); + request.image = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('deprecate', () => { + it('invokes deprecate without error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeprecateImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeprecateImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeprecateImageRequest', ['image']); + request.image = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&image=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deprecate = stubSimpleCall(expectedResponse); + const [response] = await client.deprecate(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.deprecate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deprecate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deprecate without error using callback', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeprecateImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeprecateImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeprecateImageRequest', ['image']); + request.image = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&image=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deprecate = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deprecate( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deprecate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deprecate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deprecate with error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeprecateImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeprecateImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeprecateImageRequest', ['image']); + request.image = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&image=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deprecate = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deprecate(request), expectedError); + const actualRequest = (client.innerApiCalls.deprecate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deprecate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deprecate with closed client', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeprecateImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeprecateImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeprecateImageRequest', ['image']); + request.image = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deprecate(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageRequest', ['image']); + request.image = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&image=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Image() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageRequest', ['image']); + request.image = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&image=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Image() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageRequest', ['image']); + request.image = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&image=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetImageRequest', ['image']); + request.image = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getFromFamily', () => { + it('invokes getFromFamily without error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetFromFamilyImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFromFamilyImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFromFamilyImageRequest', ['family']); + request.family = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&family=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Image() + ); + client.innerApiCalls.getFromFamily = stubSimpleCall(expectedResponse); + const [response] = await client.getFromFamily(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getFromFamily as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getFromFamily as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getFromFamily without error using callback', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetFromFamilyImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFromFamilyImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFromFamilyImageRequest', ['family']); + request.family = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&family=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Image() + ); + client.innerApiCalls.getFromFamily = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getFromFamily( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getFromFamily as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getFromFamily as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getFromFamily with error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetFromFamilyImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFromFamilyImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFromFamilyImageRequest', ['family']); + request.family = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&family=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getFromFamily = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getFromFamily(request), expectedError); + const actualRequest = (client.innerApiCalls.getFromFamily as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getFromFamily as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getFromFamily with closed client', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetFromFamilyImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFromFamilyImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetFromFamilyImageRequest', ['family']); + request.family = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getFromFamily(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertImageRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertImageRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertImageRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertImageRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchImageRequest', ['image']); + request.image = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&image=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchImageRequest', ['image']); + request.image = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&image=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchImageRequest', ['image']); + request.image = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&image=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchImageRequest', ['image']); + request.image = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('setLabels', () => { + it('invokes setLabels without error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCall(expectedResponse); + const [response] = await client.setLabels(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels without error using callback', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setLabels( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setLabels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with closed client', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setLabels(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new imagesModule.v1.ImagesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListImagesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Image()), + generateSampleMessage(new protos.google.cloud.compute.v1.Image()), + generateSampleMessage(new protos.google.cloud.compute.v1.Image()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new imagesModule.v1.ImagesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListImagesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Image()), + generateSampleMessage(new protos.google.cloud.compute.v1.Image()), + generateSampleMessage(new protos.google.cloud.compute.v1.Image()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IImage[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new imagesModule.v1.ImagesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListImagesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new imagesModule.v1.ImagesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListImagesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Image()), + generateSampleMessage(new protos.google.cloud.compute.v1.Image()), + generateSampleMessage(new protos.google.cloud.compute.v1.Image()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Image[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Image) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new imagesModule.v1.ImagesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListImagesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Image[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Image) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new imagesModule.v1.ImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListImagesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Image()), + generateSampleMessage(new protos.google.cloud.compute.v1.Image()), + generateSampleMessage(new protos.google.cloud.compute.v1.Image()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IImage[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new imagesModule.v1.ImagesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListImagesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IImage[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_instance_group_managers_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_instance_group_managers_v1.ts new file mode 100644 index 00000000000..61bcbe949f4 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_instance_group_managers_v1.ts @@ -0,0 +1,3375 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as instancegroupmanagersModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.InstanceGroupManagersClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = instancegroupmanagersModule.v1.InstanceGroupManagersClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = instancegroupmanagersModule.v1.InstanceGroupManagersClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = instancegroupmanagersModule.v1.InstanceGroupManagersClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.instanceGroupManagersStub, undefined); + await client.initialize(); + assert(client.instanceGroupManagersStub); + }); + + it('has close method for the initialized client', done => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.instanceGroupManagersStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.instanceGroupManagersStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + 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 instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + 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('abandonInstances', () => { + it('invokes abandonInstances without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AbandonInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.abandonInstances = stubSimpleCall(expectedResponse); + const [response] = await client.abandonInstances(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.abandonInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.abandonInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes abandonInstances without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AbandonInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.abandonInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.abandonInstances( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.abandonInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.abandonInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes abandonInstances with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AbandonInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.abandonInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.abandonInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.abandonInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.abandonInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes abandonInstances with closed client', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AbandonInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.abandonInstances(request), expectedError); + }); + }); + + describe('applyUpdatesToInstances', () => { + it('invokes applyUpdatesToInstances without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ApplyUpdatesToInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.applyUpdatesToInstances = stubSimpleCall(expectedResponse); + const [response] = await client.applyUpdatesToInstances(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.applyUpdatesToInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.applyUpdatesToInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes applyUpdatesToInstances without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ApplyUpdatesToInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.applyUpdatesToInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.applyUpdatesToInstances( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.applyUpdatesToInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.applyUpdatesToInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes applyUpdatesToInstances with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ApplyUpdatesToInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.applyUpdatesToInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.applyUpdatesToInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.applyUpdatesToInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.applyUpdatesToInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes applyUpdatesToInstances with closed client', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ApplyUpdatesToInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.applyUpdatesToInstances(request), expectedError); + }); + }); + + describe('createInstances', () => { + it('invokes createInstances without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CreateInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.createInstances = stubSimpleCall(expectedResponse); + const [response] = await client.createInstances(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.createInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstances without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CreateInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.createInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstances( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstances with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CreateInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.createInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstances with closed client', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CreateInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createInstances(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('deleteInstances', () => { + it('invokes deleteInstances without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deleteInstances = stubSimpleCall(expectedResponse); + const [response] = await client.deleteInstances(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstances without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deleteInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstances( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstances with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstances with closed client', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteInstances(request), expectedError); + }); + }); + + describe('deletePerInstanceConfigs', () => { + it('invokes deletePerInstanceConfigs without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePerInstanceConfigsInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deletePerInstanceConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.deletePerInstanceConfigs(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.deletePerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePerInstanceConfigs without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePerInstanceConfigsInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deletePerInstanceConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePerInstanceConfigs( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deletePerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePerInstanceConfigs with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePerInstanceConfigsInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePerInstanceConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deletePerInstanceConfigs(request), expectedError); + const actualRequest = (client.innerApiCalls.deletePerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePerInstanceConfigs with closed client', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePerInstanceConfigsInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deletePerInstanceConfigs(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InstanceGroupManager() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InstanceGroupManager() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstanceGroupManager|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('patchPerInstanceConfigs', () => { + it('invokes patchPerInstanceConfigs without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPerInstanceConfigsInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patchPerInstanceConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.patchPerInstanceConfigs(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patchPerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchPerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchPerInstanceConfigs without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPerInstanceConfigsInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patchPerInstanceConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patchPerInstanceConfigs( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patchPerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchPerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchPerInstanceConfigs with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPerInstanceConfigsInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patchPerInstanceConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patchPerInstanceConfigs(request), expectedError); + const actualRequest = (client.innerApiCalls.patchPerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchPerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchPerInstanceConfigs with closed client', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPerInstanceConfigsInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patchPerInstanceConfigs(request), expectedError); + }); + }); + + describe('recreateInstances', () => { + it('invokes recreateInstances without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RecreateInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.recreateInstances = stubSimpleCall(expectedResponse); + const [response] = await client.recreateInstances(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.recreateInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.recreateInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes recreateInstances without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RecreateInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.recreateInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.recreateInstances( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.recreateInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.recreateInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes recreateInstances with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RecreateInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.recreateInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.recreateInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.recreateInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.recreateInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes recreateInstances with closed client', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RecreateInstancesInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.recreateInstances(request), expectedError); + }); + }); + + describe('resize', () => { + it('invokes resize without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.resize = stubSimpleCall(expectedResponse); + const [response] = await client.resize(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resize without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.resize = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resize( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resize with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resize = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.resize(request), expectedError); + const actualRequest = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resize with closed client', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resize(request), expectedError); + }); + }); + + describe('setInstanceTemplate', () => { + it('invokes setInstanceTemplate without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetInstanceTemplateInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setInstanceTemplate = stubSimpleCall(expectedResponse); + const [response] = await client.setInstanceTemplate(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setInstanceTemplate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceTemplate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceTemplate without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetInstanceTemplateInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setInstanceTemplate = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInstanceTemplate( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setInstanceTemplate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceTemplate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceTemplate with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetInstanceTemplateInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceTemplate = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setInstanceTemplate(request), expectedError); + const actualRequest = (client.innerApiCalls.setInstanceTemplate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceTemplate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceTemplate with closed client', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetInstanceTemplateInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setInstanceTemplate(request), expectedError); + }); + }); + + describe('setTargetPools', () => { + it('invokes setTargetPools without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTargetPoolsInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setTargetPools = stubSimpleCall(expectedResponse); + const [response] = await client.setTargetPools(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setTargetPools as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setTargetPools as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setTargetPools without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTargetPoolsInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setTargetPools = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setTargetPools( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setTargetPools as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setTargetPools as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setTargetPools with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTargetPoolsInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setTargetPools = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setTargetPools(request), expectedError); + const actualRequest = (client.innerApiCalls.setTargetPools as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setTargetPools as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setTargetPools with closed client', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTargetPoolsInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setTargetPools(request), expectedError); + }); + }); + + describe('updatePerInstanceConfigs', () => { + it('invokes updatePerInstanceConfigs without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdatePerInstanceConfigsInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.updatePerInstanceConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.updatePerInstanceConfigs(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.updatePerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePerInstanceConfigs without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdatePerInstanceConfigsInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.updatePerInstanceConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updatePerInstanceConfigs( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updatePerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePerInstanceConfigs with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdatePerInstanceConfigsInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePerInstanceConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updatePerInstanceConfigs(request), expectedError); + const actualRequest = (client.innerApiCalls.updatePerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePerInstanceConfigs with closed client', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdatePerInstanceConfigsInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsInstanceGroupManagerRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updatePerInstanceConfigs(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManagersScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManagersScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManagersScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IInstanceGroupManagersScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IInstanceGroupManagersScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstanceGroupManager[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceGroupManager[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceGroupManager) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceGroupManager[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceGroupManager) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IInstanceGroupManager[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IInstanceGroupManager[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listErrors', () => { + it('invokes listErrors without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + ]; + client.innerApiCalls.listErrors = stubSimpleCall(expectedResponse); + const [response] = await client.listErrors(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listErrors as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listErrors as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listErrors without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + ]; + client.innerApiCalls.listErrors = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listErrors( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstanceManagedByIgmError[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listErrors as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listErrors as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listErrors with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listErrors = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listErrors(request), expectedError); + const actualRequest = (client.innerApiCalls.listErrors as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listErrors as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listErrorsStream without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + ]; + client.descriptors.page.listErrors.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listErrorsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceManagedByIgmError[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceManagedByIgmError) => { + 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.listErrors.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listErrors, request)); + assert( + (client.descriptors.page.listErrors.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listErrorsStream with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listErrors.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listErrorsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceManagedByIgmError[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceManagedByIgmError) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listErrors.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listErrors, request)); + assert( + (client.descriptors.page.listErrors.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listErrors without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + ]; + client.descriptors.page.listErrors.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IInstanceManagedByIgmError[] = []; + const iterable = client.listErrorsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listErrors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listErrors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listErrors with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listErrors.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listErrorsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IInstanceManagedByIgmError[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listErrors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listErrors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listManagedInstances', () => { + it('invokes listManagedInstances without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + ]; + client.innerApiCalls.listManagedInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listManagedInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listManagedInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listManagedInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listManagedInstances without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + ]; + client.innerApiCalls.listManagedInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listManagedInstances( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IManagedInstance[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listManagedInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listManagedInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listManagedInstances with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listManagedInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listManagedInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.listManagedInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listManagedInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listManagedInstancesStream without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + ]; + client.descriptors.page.listManagedInstances.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listManagedInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.ManagedInstance[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.ManagedInstance) => { + 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.listManagedInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listManagedInstances, request)); + assert( + (client.descriptors.page.listManagedInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listManagedInstancesStream with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listManagedInstances.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listManagedInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.ManagedInstance[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.ManagedInstance) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listManagedInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listManagedInstances, request)); + assert( + (client.descriptors.page.listManagedInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listManagedInstances without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + ]; + client.descriptors.page.listManagedInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IManagedInstance[] = []; + const iterable = client.listManagedInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listManagedInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listManagedInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listManagedInstances with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listManagedInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listManagedInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IManagedInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listManagedInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listManagedInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listPerInstanceConfigs', () => { + it('invokes listPerInstanceConfigs without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + ]; + client.innerApiCalls.listPerInstanceConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.listPerInstanceConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPerInstanceConfigs without error using callback', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + ]; + client.innerApiCalls.listPerInstanceConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPerInstanceConfigs( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPerInstanceConfig[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPerInstanceConfigs with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPerInstanceConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listPerInstanceConfigs(request), expectedError); + const actualRequest = (client.innerApiCalls.listPerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPerInstanceConfigsStream without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + ]; + client.descriptors.page.listPerInstanceConfigs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listPerInstanceConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.PerInstanceConfig[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.PerInstanceConfig) => { + 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.listPerInstanceConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPerInstanceConfigs, request)); + assert( + (client.descriptors.page.listPerInstanceConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listPerInstanceConfigsStream with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPerInstanceConfigs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listPerInstanceConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.PerInstanceConfig[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.PerInstanceConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listPerInstanceConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPerInstanceConfigs, request)); + assert( + (client.descriptors.page.listPerInstanceConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPerInstanceConfigs without error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + ]; + client.descriptors.page.listPerInstanceConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IPerInstanceConfig[] = []; + const iterable = client.listPerInstanceConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listPerInstanceConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPerInstanceConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPerInstanceConfigs with error', async () => { + const client = new instancegroupmanagersModule.v1.InstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPerInstanceConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPerInstanceConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IPerInstanceConfig[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listPerInstanceConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPerInstanceConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_instance_groups_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_instance_groups_v1.ts new file mode 100644 index 00000000000..0fc43bdbe0c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_instance_groups_v1.ts @@ -0,0 +1,1613 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as instancegroupsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.InstanceGroupsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = instancegroupsModule.v1.InstanceGroupsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = instancegroupsModule.v1.InstanceGroupsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = instancegroupsModule.v1.InstanceGroupsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.instanceGroupsStub, undefined); + await client.initialize(); + assert(client.instanceGroupsStub); + }); + + it('has close method for the initialized client', done => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.instanceGroupsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.instanceGroupsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + 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 instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + 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('addInstances', () => { + it('invokes addInstances without error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddInstancesInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstancesInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstancesInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstancesInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addInstances = stubSimpleCall(expectedResponse); + const [response] = await client.addInstances(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addInstances without error using callback', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddInstancesInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstancesInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstancesInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstancesInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addInstances( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addInstances with error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddInstancesInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstancesInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstancesInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstancesInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.addInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addInstances with closed client', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddInstancesInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstancesInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstancesInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstancesInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addInstances(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InstanceGroup() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InstanceGroup() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstanceGroup|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('removeInstances', () => { + it('invokes removeInstances without error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveInstancesInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstancesInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstancesInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstancesInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeInstances = stubSimpleCall(expectedResponse); + const [response] = await client.removeInstances(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.removeInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeInstances without error using callback', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveInstancesInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstancesInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstancesInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstancesInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeInstances( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeInstances with error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveInstancesInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstancesInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstancesInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstancesInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.removeInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeInstances with closed client', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveInstancesInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstancesInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstancesInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstancesInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeInstances(request), expectedError); + }); + }); + + describe('setNamedPorts', () => { + it('invokes setNamedPorts without error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetNamedPortsInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setNamedPorts = stubSimpleCall(expectedResponse); + const [response] = await client.setNamedPorts(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setNamedPorts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setNamedPorts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setNamedPorts without error using callback', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetNamedPortsInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setNamedPorts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setNamedPorts( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setNamedPorts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setNamedPorts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setNamedPorts with error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetNamedPortsInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setNamedPorts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setNamedPorts(request), expectedError); + const actualRequest = (client.innerApiCalls.setNamedPorts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setNamedPorts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setNamedPorts with closed client', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetNamedPortsInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsInstanceGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setNamedPorts(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupsScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupsScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupsScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IInstanceGroupsScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IInstanceGroupsScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstanceGroup[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceGroup[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceGroup) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceGroup[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceGroup) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IInstanceGroup[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IInstanceGroup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new instancegroupsModule.v1.InstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + ]; + 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 instancegroupsModule.v1.InstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + ]; + client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstanceWithNamedPorts[]|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 instancegroupsModule.v1.InstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + 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 instancegroupsModule.v1.InstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + ]; + client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceWithNamedPorts[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceWithNamedPorts) => { + 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 instancegroupsModule.v1.InstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + 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.compute.v1.InstanceWithNamedPorts[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceWithNamedPorts) => { + 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 instancegroupsModule.v1.InstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + ]; + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IInstanceWithNamedPorts[] = []; + 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 instancegroupsModule.v1.InstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesInstanceGroupsRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance_group=${defaultValue3}`; + 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.compute.v1.IInstanceWithNamedPorts[] = []; + 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 + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_instance_templates_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_instance_templates_v1.ts new file mode 100644 index 00000000000..ce5d55808a5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_instance_templates_v1.ts @@ -0,0 +1,1233 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as instancetemplatesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.InstanceTemplatesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = instancetemplatesModule.v1.InstanceTemplatesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = instancetemplatesModule.v1.InstanceTemplatesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = instancetemplatesModule.v1.InstanceTemplatesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.instanceTemplatesStub, undefined); + await client.initialize(); + assert(client.instanceTemplatesStub); + }); + + it('has close method for the initialized client', done => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.instanceTemplatesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.instanceTemplatesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + 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 instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceTemplateRequest', ['instanceTemplate']); + request.instanceTemplate = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&instance_template=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceTemplateRequest', ['instanceTemplate']); + request.instanceTemplate = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&instance_template=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceTemplateRequest', ['instanceTemplate']); + request.instanceTemplate = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&instance_template=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceTemplateRequest', ['instanceTemplate']); + request.instanceTemplate = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceTemplateRequest', ['instanceTemplate']); + request.instanceTemplate = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&instance_template=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InstanceTemplate() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceTemplateRequest', ['instanceTemplate']); + request.instanceTemplate = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&instance_template=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InstanceTemplate() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstanceTemplate|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceTemplateRequest', ['instanceTemplate']); + request.instanceTemplate = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&instance_template=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceTemplateRequest', ['instanceTemplate']); + request.instanceTemplate = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceTemplateRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceTemplateRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceTemplateRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceTemplateRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceTemplateRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceTemplateRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceTemplateRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceTemplateRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceTemplateRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceTemplateRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceTemplateRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceTemplateRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListInstanceTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListInstanceTemplatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplatesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplatesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplatesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IInstanceTemplatesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListInstanceTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListInstanceTemplatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IInstanceTemplatesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceTemplatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceTemplatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstanceTemplate[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceTemplatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceTemplatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceTemplate[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceTemplate) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceTemplatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceTemplate[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceTemplate) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceTemplatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IInstanceTemplate[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new instancetemplatesModule.v1.InstanceTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstanceTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstanceTemplatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IInstanceTemplate[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_instances_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_instances_v1.ts new file mode 100644 index 00000000000..4b5416ba7e6 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_instances_v1.ts @@ -0,0 +1,6485 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as instancesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.InstancesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = instancesModule.v1.InstancesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = instancesModule.v1.InstancesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = instancesModule.v1.InstancesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new instancesModule.v1.InstancesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new instancesModule.v1.InstancesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + 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.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.instancesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.instancesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + 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.v1.InstancesClient({ + auth: googleAuth, + 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('addAccessConfig', () => { + it('invokes addAccessConfig without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddAccessConfigInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAccessConfigInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAccessConfigInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAccessConfigInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addAccessConfig = stubSimpleCall(expectedResponse); + const [response] = await client.addAccessConfig(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addAccessConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addAccessConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addAccessConfig without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddAccessConfigInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAccessConfigInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAccessConfigInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAccessConfigInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addAccessConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addAccessConfig( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addAccessConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addAccessConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addAccessConfig with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddAccessConfigInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAccessConfigInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAccessConfigInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAccessConfigInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addAccessConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addAccessConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.addAccessConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addAccessConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addAccessConfig with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddAccessConfigInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAccessConfigInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAccessConfigInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAccessConfigInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addAccessConfig(request), expectedError); + }); + }); + + describe('addResourcePolicies', () => { + it('invokes addResourcePolicies without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddResourcePoliciesInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addResourcePolicies = stubSimpleCall(expectedResponse); + const [response] = await client.addResourcePolicies(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addResourcePolicies without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddResourcePoliciesInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addResourcePolicies = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addResourcePolicies( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addResourcePolicies with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddResourcePoliciesInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addResourcePolicies = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addResourcePolicies(request), expectedError); + const actualRequest = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addResourcePolicies with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddResourcePoliciesInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addResourcePolicies(request), expectedError); + }); + }); + + describe('attachDisk', () => { + it('invokes attachDisk without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AttachDiskInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachDiskInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachDiskInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachDiskInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.attachDisk = stubSimpleCall(expectedResponse); + const [response] = await client.attachDisk(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.attachDisk as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.attachDisk as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes attachDisk without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AttachDiskInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachDiskInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachDiskInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachDiskInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.attachDisk = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.attachDisk( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.attachDisk as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.attachDisk as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes attachDisk with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AttachDiskInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachDiskInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachDiskInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachDiskInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.attachDisk = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.attachDisk(request), expectedError); + const actualRequest = (client.innerApiCalls.attachDisk as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.attachDisk as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes attachDisk with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AttachDiskInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachDiskInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachDiskInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachDiskInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.attachDisk(request), expectedError); + }); + }); + + describe('bulkInsert', () => { + it('invokes bulkInsert without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.BulkInsertInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.BulkInsertInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.BulkInsertInstanceRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.bulkInsert = stubSimpleCall(expectedResponse); + const [response] = await client.bulkInsert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.bulkInsert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.bulkInsert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes bulkInsert without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.BulkInsertInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.BulkInsertInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.BulkInsertInstanceRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.bulkInsert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.bulkInsert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.bulkInsert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.bulkInsert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes bulkInsert with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.BulkInsertInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.BulkInsertInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.BulkInsertInstanceRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.bulkInsert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.bulkInsert(request), expectedError); + const actualRequest = (client.innerApiCalls.bulkInsert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.bulkInsert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes bulkInsert with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.BulkInsertInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.BulkInsertInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.BulkInsertInstanceRequest', ['zone']); + request.zone = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.bulkInsert(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('deleteAccessConfig', () => { + it('invokes deleteAccessConfig without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteAccessConfigInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAccessConfigInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAccessConfigInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAccessConfigInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deleteAccessConfig = stubSimpleCall(expectedResponse); + const [response] = await client.deleteAccessConfig(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteAccessConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteAccessConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteAccessConfig without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteAccessConfigInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAccessConfigInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAccessConfigInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAccessConfigInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deleteAccessConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteAccessConfig( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteAccessConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteAccessConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteAccessConfig with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteAccessConfigInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAccessConfigInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAccessConfigInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAccessConfigInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteAccessConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteAccessConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteAccessConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteAccessConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteAccessConfig with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteAccessConfigInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAccessConfigInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAccessConfigInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteAccessConfigInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteAccessConfig(request), expectedError); + }); + }); + + describe('detachDisk', () => { + it('invokes detachDisk without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DetachDiskInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachDiskInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachDiskInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachDiskInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.detachDisk = stubSimpleCall(expectedResponse); + const [response] = await client.detachDisk(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.detachDisk as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.detachDisk as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes detachDisk without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DetachDiskInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachDiskInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachDiskInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachDiskInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.detachDisk = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.detachDisk( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.detachDisk as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.detachDisk as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes detachDisk with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DetachDiskInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachDiskInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachDiskInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachDiskInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.detachDisk = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.detachDisk(request), expectedError); + const actualRequest = (client.innerApiCalls.detachDisk as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.detachDisk as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes detachDisk with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DetachDiskInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachDiskInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachDiskInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachDiskInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.detachDisk(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Instance() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Instance() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstance|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getEffectiveFirewalls', () => { + it('invokes getEffectiveFirewalls without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetEffectiveFirewallsInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InstancesGetEffectiveFirewallsResponse() + ); + client.innerApiCalls.getEffectiveFirewalls = stubSimpleCall(expectedResponse); + const [response] = await client.getEffectiveFirewalls(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEffectiveFirewalls without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetEffectiveFirewallsInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InstancesGetEffectiveFirewallsResponse() + ); + client.innerApiCalls.getEffectiveFirewalls = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEffectiveFirewalls( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstancesGetEffectiveFirewallsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEffectiveFirewalls with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetEffectiveFirewallsInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEffectiveFirewalls = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getEffectiveFirewalls(request), expectedError); + const actualRequest = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEffectiveFirewalls with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetEffectiveFirewallsInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getEffectiveFirewalls(request), expectedError); + }); + }); + + describe('getGuestAttributes', () => { + it('invokes getGuestAttributes without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGuestAttributesInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGuestAttributesInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGuestAttributesInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGuestAttributesInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.GuestAttributes() + ); + client.innerApiCalls.getGuestAttributes = stubSimpleCall(expectedResponse); + const [response] = await client.getGuestAttributes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getGuestAttributes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getGuestAttributes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getGuestAttributes without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGuestAttributesInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGuestAttributesInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGuestAttributesInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGuestAttributesInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.GuestAttributes() + ); + client.innerApiCalls.getGuestAttributes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getGuestAttributes( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IGuestAttributes|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getGuestAttributes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getGuestAttributes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getGuestAttributes with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGuestAttributesInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGuestAttributesInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGuestAttributesInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGuestAttributesInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getGuestAttributes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getGuestAttributes(request), expectedError); + const actualRequest = (client.innerApiCalls.getGuestAttributes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getGuestAttributes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getGuestAttributes with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetGuestAttributesInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGuestAttributesInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGuestAttributesInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetGuestAttributesInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getGuestAttributes(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyInstanceRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('getScreenshot', () => { + it('invokes getScreenshot without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetScreenshotInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetScreenshotInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetScreenshotInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetScreenshotInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Screenshot() + ); + client.innerApiCalls.getScreenshot = stubSimpleCall(expectedResponse); + const [response] = await client.getScreenshot(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getScreenshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getScreenshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getScreenshot without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetScreenshotInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetScreenshotInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetScreenshotInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetScreenshotInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Screenshot() + ); + client.innerApiCalls.getScreenshot = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getScreenshot( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IScreenshot|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getScreenshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getScreenshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getScreenshot with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetScreenshotInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetScreenshotInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetScreenshotInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetScreenshotInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getScreenshot = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getScreenshot(request), expectedError); + const actualRequest = (client.innerApiCalls.getScreenshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getScreenshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getScreenshot with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetScreenshotInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetScreenshotInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetScreenshotInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetScreenshotInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getScreenshot(request), expectedError); + }); + }); + + describe('getSerialPortOutput', () => { + it('invokes getSerialPortOutput without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSerialPortOutputInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSerialPortOutputInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSerialPortOutputInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSerialPortOutputInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SerialPortOutput() + ); + client.innerApiCalls.getSerialPortOutput = stubSimpleCall(expectedResponse); + const [response] = await client.getSerialPortOutput(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSerialPortOutput as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSerialPortOutput as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSerialPortOutput without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSerialPortOutputInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSerialPortOutputInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSerialPortOutputInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSerialPortOutputInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SerialPortOutput() + ); + client.innerApiCalls.getSerialPortOutput = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSerialPortOutput( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISerialPortOutput|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSerialPortOutput as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSerialPortOutput as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSerialPortOutput with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSerialPortOutputInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSerialPortOutputInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSerialPortOutputInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSerialPortOutputInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSerialPortOutput = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getSerialPortOutput(request), expectedError); + const actualRequest = (client.innerApiCalls.getSerialPortOutput as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSerialPortOutput as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSerialPortOutput with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSerialPortOutputInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSerialPortOutputInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSerialPortOutputInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSerialPortOutputInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getSerialPortOutput(request), expectedError); + }); + }); + + describe('getShieldedInstanceIdentity', () => { + it('invokes getShieldedInstanceIdentity without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetShieldedInstanceIdentityInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetShieldedInstanceIdentityInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetShieldedInstanceIdentityInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetShieldedInstanceIdentityInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.ShieldedInstanceIdentity() + ); + client.innerApiCalls.getShieldedInstanceIdentity = stubSimpleCall(expectedResponse); + const [response] = await client.getShieldedInstanceIdentity(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getShieldedInstanceIdentity as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getShieldedInstanceIdentity as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getShieldedInstanceIdentity without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetShieldedInstanceIdentityInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetShieldedInstanceIdentityInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetShieldedInstanceIdentityInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetShieldedInstanceIdentityInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.ShieldedInstanceIdentity() + ); + client.innerApiCalls.getShieldedInstanceIdentity = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getShieldedInstanceIdentity( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IShieldedInstanceIdentity|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getShieldedInstanceIdentity as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getShieldedInstanceIdentity as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getShieldedInstanceIdentity with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetShieldedInstanceIdentityInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetShieldedInstanceIdentityInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetShieldedInstanceIdentityInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetShieldedInstanceIdentityInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getShieldedInstanceIdentity = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getShieldedInstanceIdentity(request), expectedError); + const actualRequest = (client.innerApiCalls.getShieldedInstanceIdentity as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getShieldedInstanceIdentity as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getShieldedInstanceIdentity with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetShieldedInstanceIdentityInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetShieldedInstanceIdentityInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetShieldedInstanceIdentityInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetShieldedInstanceIdentityInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getShieldedInstanceIdentity(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInstanceRequest', ['zone']); + request.zone = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('removeResourcePolicies', () => { + it('invokes removeResourcePolicies without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveResourcePoliciesInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeResourcePolicies = stubSimpleCall(expectedResponse); + const [response] = await client.removeResourcePolicies(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeResourcePolicies without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveResourcePoliciesInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeResourcePolicies = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeResourcePolicies( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeResourcePolicies with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveResourcePoliciesInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeResourcePolicies = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeResourcePolicies(request), expectedError); + const actualRequest = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeResourcePolicies with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveResourcePoliciesInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeResourcePolicies(request), expectedError); + }); + }); + + describe('reset', () => { + it('invokes reset without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResetInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.reset = stubSimpleCall(expectedResponse); + const [response] = await client.reset(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.reset as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reset as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reset without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResetInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.reset = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reset( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.reset as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reset as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reset with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResetInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reset = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.reset(request), expectedError); + const actualRequest = (client.innerApiCalls.reset as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reset as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reset with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResetInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.reset(request), expectedError); + }); + }); + + describe('resume', () => { + it('invokes resume without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResumeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResumeInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResumeInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResumeInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.resume = stubSimpleCall(expectedResponse); + const [response] = await client.resume(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.resume as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resume as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resume without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResumeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResumeInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResumeInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResumeInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.resume = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resume( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resume as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resume as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resume with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResumeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResumeInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResumeInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResumeInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resume = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.resume(request), expectedError); + const actualRequest = (client.innerApiCalls.resume as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resume as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resume with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResumeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResumeInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResumeInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResumeInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resume(request), expectedError); + }); + }); + + describe('sendDiagnosticInterrupt', () => { + it('invokes sendDiagnosticInterrupt without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SendDiagnosticInterruptInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SendDiagnosticInterruptInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SendDiagnosticInterruptInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SendDiagnosticInterruptInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SendDiagnosticInterruptInstanceResponse() + ); + client.innerApiCalls.sendDiagnosticInterrupt = stubSimpleCall(expectedResponse); + const [response] = await client.sendDiagnosticInterrupt(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.sendDiagnosticInterrupt as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.sendDiagnosticInterrupt as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes sendDiagnosticInterrupt without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SendDiagnosticInterruptInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SendDiagnosticInterruptInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SendDiagnosticInterruptInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SendDiagnosticInterruptInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SendDiagnosticInterruptInstanceResponse() + ); + client.innerApiCalls.sendDiagnosticInterrupt = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.sendDiagnosticInterrupt( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISendDiagnosticInterruptInstanceResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.sendDiagnosticInterrupt as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.sendDiagnosticInterrupt as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes sendDiagnosticInterrupt with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SendDiagnosticInterruptInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SendDiagnosticInterruptInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SendDiagnosticInterruptInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SendDiagnosticInterruptInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.sendDiagnosticInterrupt = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.sendDiagnosticInterrupt(request), expectedError); + const actualRequest = (client.innerApiCalls.sendDiagnosticInterrupt as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.sendDiagnosticInterrupt as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes sendDiagnosticInterrupt with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SendDiagnosticInterruptInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SendDiagnosticInterruptInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SendDiagnosticInterruptInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SendDiagnosticInterruptInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.sendDiagnosticInterrupt(request), expectedError); + }); + }); + + describe('setDeletionProtection', () => { + it('invokes setDeletionProtection without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setDeletionProtection = stubSimpleCall(expectedResponse); + const [response] = await client.setDeletionProtection(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setDeletionProtection as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDeletionProtection as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDeletionProtection without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setDeletionProtection = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setDeletionProtection( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setDeletionProtection as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDeletionProtection as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDeletionProtection with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setDeletionProtection = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setDeletionProtection(request), expectedError); + const actualRequest = (client.innerApiCalls.setDeletionProtection as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDeletionProtection as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDeletionProtection with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setDeletionProtection(request), expectedError); + }); + }); + + describe('setDiskAutoDelete', () => { + it('invokes setDiskAutoDelete without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetDiskAutoDeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDiskAutoDeleteInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDiskAutoDeleteInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDiskAutoDeleteInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setDiskAutoDelete = stubSimpleCall(expectedResponse); + const [response] = await client.setDiskAutoDelete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setDiskAutoDelete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDiskAutoDelete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDiskAutoDelete without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetDiskAutoDeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDiskAutoDeleteInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDiskAutoDeleteInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDiskAutoDeleteInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setDiskAutoDelete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setDiskAutoDelete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setDiskAutoDelete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDiskAutoDelete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDiskAutoDelete with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetDiskAutoDeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDiskAutoDeleteInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDiskAutoDeleteInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDiskAutoDeleteInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setDiskAutoDelete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setDiskAutoDelete(request), expectedError); + const actualRequest = (client.innerApiCalls.setDiskAutoDelete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDiskAutoDelete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDiskAutoDelete with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetDiskAutoDeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDiskAutoDeleteInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDiskAutoDeleteInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDiskAutoDeleteInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setDiskAutoDelete(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyInstanceRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('setLabels', () => { + it('invokes setLabels without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCall(expectedResponse); + const [response] = await client.setLabels(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setLabels( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setLabels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setLabels(request), expectedError); + }); + }); + + describe('setMachineResources', () => { + it('invokes setMachineResources without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetMachineResourcesInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineResourcesInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineResourcesInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineResourcesInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setMachineResources = stubSimpleCall(expectedResponse); + const [response] = await client.setMachineResources(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setMachineResources as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setMachineResources as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setMachineResources without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetMachineResourcesInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineResourcesInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineResourcesInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineResourcesInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setMachineResources = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setMachineResources( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setMachineResources as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setMachineResources as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setMachineResources with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetMachineResourcesInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineResourcesInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineResourcesInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineResourcesInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setMachineResources = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setMachineResources(request), expectedError); + const actualRequest = (client.innerApiCalls.setMachineResources as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setMachineResources as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setMachineResources with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetMachineResourcesInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineResourcesInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineResourcesInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineResourcesInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setMachineResources(request), expectedError); + }); + }); + + describe('setMachineType', () => { + it('invokes setMachineType without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetMachineTypeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineTypeInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineTypeInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineTypeInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setMachineType = stubSimpleCall(expectedResponse); + const [response] = await client.setMachineType(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setMachineType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setMachineType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setMachineType without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetMachineTypeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineTypeInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineTypeInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineTypeInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setMachineType = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setMachineType( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setMachineType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setMachineType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setMachineType with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetMachineTypeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineTypeInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineTypeInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineTypeInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setMachineType = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setMachineType(request), expectedError); + const actualRequest = (client.innerApiCalls.setMachineType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setMachineType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setMachineType with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetMachineTypeInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineTypeInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineTypeInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMachineTypeInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setMachineType(request), expectedError); + }); + }); + + describe('setMetadata', () => { + it('invokes setMetadata without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetMetadataInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMetadataInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMetadataInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMetadataInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setMetadata = stubSimpleCall(expectedResponse); + const [response] = await client.setMetadata(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setMetadata as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setMetadata as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setMetadata without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetMetadataInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMetadataInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMetadataInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMetadataInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setMetadata = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setMetadata( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setMetadata as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setMetadata as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setMetadata with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetMetadataInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMetadataInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMetadataInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMetadataInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setMetadata = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setMetadata(request), expectedError); + const actualRequest = (client.innerApiCalls.setMetadata as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setMetadata as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setMetadata with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetMetadataInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMetadataInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMetadataInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMetadataInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setMetadata(request), expectedError); + }); + }); + + describe('setMinCpuPlatform', () => { + it('invokes setMinCpuPlatform without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetMinCpuPlatformInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMinCpuPlatformInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMinCpuPlatformInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMinCpuPlatformInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setMinCpuPlatform = stubSimpleCall(expectedResponse); + const [response] = await client.setMinCpuPlatform(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setMinCpuPlatform as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setMinCpuPlatform as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setMinCpuPlatform without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetMinCpuPlatformInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMinCpuPlatformInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMinCpuPlatformInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMinCpuPlatformInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setMinCpuPlatform = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setMinCpuPlatform( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setMinCpuPlatform as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setMinCpuPlatform as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setMinCpuPlatform with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetMinCpuPlatformInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMinCpuPlatformInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMinCpuPlatformInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMinCpuPlatformInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setMinCpuPlatform = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setMinCpuPlatform(request), expectedError); + const actualRequest = (client.innerApiCalls.setMinCpuPlatform as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setMinCpuPlatform as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setMinCpuPlatform with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetMinCpuPlatformInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMinCpuPlatformInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMinCpuPlatformInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetMinCpuPlatformInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setMinCpuPlatform(request), expectedError); + }); + }); + + describe('setName', () => { + it('invokes setName without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetNameInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNameInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNameInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNameInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setName = stubSimpleCall(expectedResponse); + const [response] = await client.setName(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setName as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setName as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setName without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetNameInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNameInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNameInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNameInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setName = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setName( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setName as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setName as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setName with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetNameInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNameInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNameInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNameInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setName = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setName(request), expectedError); + const actualRequest = (client.innerApiCalls.setName as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setName as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setName with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetNameInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNameInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNameInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNameInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setName(request), expectedError); + }); + }); + + describe('setScheduling', () => { + it('invokes setScheduling without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSchedulingInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSchedulingInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSchedulingInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSchedulingInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setScheduling = stubSimpleCall(expectedResponse); + const [response] = await client.setScheduling(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setScheduling as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setScheduling as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setScheduling without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSchedulingInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSchedulingInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSchedulingInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSchedulingInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setScheduling = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setScheduling( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setScheduling as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setScheduling as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setScheduling with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSchedulingInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSchedulingInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSchedulingInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSchedulingInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setScheduling = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setScheduling(request), expectedError); + const actualRequest = (client.innerApiCalls.setScheduling as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setScheduling as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setScheduling with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSchedulingInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSchedulingInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSchedulingInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSchedulingInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setScheduling(request), expectedError); + }); + }); + + describe('setServiceAccount', () => { + it('invokes setServiceAccount without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetServiceAccountInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetServiceAccountInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetServiceAccountInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetServiceAccountInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setServiceAccount = stubSimpleCall(expectedResponse); + const [response] = await client.setServiceAccount(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setServiceAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setServiceAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setServiceAccount without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetServiceAccountInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetServiceAccountInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetServiceAccountInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetServiceAccountInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setServiceAccount = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setServiceAccount( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setServiceAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setServiceAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setServiceAccount with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetServiceAccountInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetServiceAccountInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetServiceAccountInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetServiceAccountInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setServiceAccount = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setServiceAccount(request), expectedError); + const actualRequest = (client.innerApiCalls.setServiceAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setServiceAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setServiceAccount with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetServiceAccountInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetServiceAccountInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetServiceAccountInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetServiceAccountInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setServiceAccount(request), expectedError); + }); + }); + + describe('setShieldedInstanceIntegrityPolicy', () => { + it('invokes setShieldedInstanceIntegrityPolicy without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetShieldedInstanceIntegrityPolicyInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetShieldedInstanceIntegrityPolicyInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetShieldedInstanceIntegrityPolicyInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetShieldedInstanceIntegrityPolicyInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setShieldedInstanceIntegrityPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setShieldedInstanceIntegrityPolicy(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setShieldedInstanceIntegrityPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setShieldedInstanceIntegrityPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setShieldedInstanceIntegrityPolicy without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetShieldedInstanceIntegrityPolicyInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetShieldedInstanceIntegrityPolicyInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetShieldedInstanceIntegrityPolicyInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetShieldedInstanceIntegrityPolicyInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setShieldedInstanceIntegrityPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setShieldedInstanceIntegrityPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setShieldedInstanceIntegrityPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setShieldedInstanceIntegrityPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setShieldedInstanceIntegrityPolicy with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetShieldedInstanceIntegrityPolicyInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetShieldedInstanceIntegrityPolicyInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetShieldedInstanceIntegrityPolicyInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetShieldedInstanceIntegrityPolicyInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setShieldedInstanceIntegrityPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setShieldedInstanceIntegrityPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setShieldedInstanceIntegrityPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setShieldedInstanceIntegrityPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setShieldedInstanceIntegrityPolicy with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetShieldedInstanceIntegrityPolicyInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetShieldedInstanceIntegrityPolicyInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetShieldedInstanceIntegrityPolicyInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetShieldedInstanceIntegrityPolicyInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setShieldedInstanceIntegrityPolicy(request), expectedError); + }); + }); + + describe('setTags', () => { + it('invokes setTags without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTagsInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTagsInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTagsInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTagsInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setTags = stubSimpleCall(expectedResponse); + const [response] = await client.setTags(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setTags as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setTags as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setTags without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTagsInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTagsInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTagsInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTagsInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setTags = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setTags( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setTags as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setTags as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setTags with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTagsInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTagsInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTagsInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTagsInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setTags = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setTags(request), expectedError); + const actualRequest = (client.innerApiCalls.setTags as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setTags as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setTags with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTagsInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTagsInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTagsInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTagsInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setTags(request), expectedError); + }); + }); + + describe('simulateMaintenanceEvent', () => { + it('invokes simulateMaintenanceEvent without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SimulateMaintenanceEventInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.simulateMaintenanceEvent = stubSimpleCall(expectedResponse); + const [response] = await client.simulateMaintenanceEvent(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.simulateMaintenanceEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.simulateMaintenanceEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes simulateMaintenanceEvent without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SimulateMaintenanceEventInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.simulateMaintenanceEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.simulateMaintenanceEvent( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.simulateMaintenanceEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.simulateMaintenanceEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes simulateMaintenanceEvent with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SimulateMaintenanceEventInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.simulateMaintenanceEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.simulateMaintenanceEvent(request), expectedError); + const actualRequest = (client.innerApiCalls.simulateMaintenanceEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.simulateMaintenanceEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes simulateMaintenanceEvent with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SimulateMaintenanceEventInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.simulateMaintenanceEvent(request), expectedError); + }); + }); + + describe('start', () => { + it('invokes start without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.StartInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.StartInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.StartInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.start = stubSimpleCall(expectedResponse); + const [response] = await client.start(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.start as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.start as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes start without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.StartInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.StartInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.StartInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.start = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.start( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.start as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.start as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes start with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.StartInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.StartInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.StartInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.start = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.start(request), expectedError); + const actualRequest = (client.innerApiCalls.start as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.start as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes start with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.StartInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.StartInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.StartInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.StartInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.start(request), expectedError); + }); + }); + + describe('startWithEncryptionKey', () => { + it('invokes startWithEncryptionKey without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.startWithEncryptionKey = stubSimpleCall(expectedResponse); + const [response] = await client.startWithEncryptionKey(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.startWithEncryptionKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startWithEncryptionKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startWithEncryptionKey without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.startWithEncryptionKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startWithEncryptionKey( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.startWithEncryptionKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startWithEncryptionKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startWithEncryptionKey with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startWithEncryptionKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.startWithEncryptionKey(request), expectedError); + const actualRequest = (client.innerApiCalls.startWithEncryptionKey as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startWithEncryptionKey as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startWithEncryptionKey with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.startWithEncryptionKey(request), expectedError); + }); + }); + + describe('stop', () => { + it('invokes stop without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.StopInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.StopInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.StopInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.stop = stubSimpleCall(expectedResponse); + const [response] = await client.stop(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.stop as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stop as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stop without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.StopInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.StopInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.StopInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.stop = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stop( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.stop as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stop as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stop with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.StopInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.StopInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.StopInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stop = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.stop(request), expectedError); + const actualRequest = (client.innerApiCalls.stop as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stop as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stop with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.StopInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.StopInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.StopInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.StopInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.stop(request), expectedError); + }); + }); + + describe('suspend', () => { + it('invokes suspend without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SuspendInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SuspendInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SuspendInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SuspendInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.suspend = stubSimpleCall(expectedResponse); + const [response] = await client.suspend(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.suspend as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.suspend as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes suspend without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SuspendInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SuspendInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SuspendInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SuspendInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.suspend = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.suspend( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.suspend as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.suspend as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes suspend with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SuspendInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SuspendInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SuspendInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SuspendInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.suspend = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.suspend(request), expectedError); + const actualRequest = (client.innerApiCalls.suspend as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.suspend as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes suspend with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SuspendInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SuspendInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SuspendInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SuspendInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.suspend(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsInstanceRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('updateAccessConfig', () => { + it('invokes updateAccessConfig without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateAccessConfigInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAccessConfigInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAccessConfigInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAccessConfigInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.updateAccessConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateAccessConfig(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.updateAccessConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAccessConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAccessConfig without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateAccessConfigInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAccessConfigInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAccessConfigInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAccessConfigInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.updateAccessConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAccessConfig( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateAccessConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAccessConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAccessConfig with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateAccessConfigInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAccessConfigInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAccessConfigInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAccessConfigInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAccessConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateAccessConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateAccessConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAccessConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAccessConfig with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateAccessConfigInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAccessConfigInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAccessConfigInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateAccessConfigInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateAccessConfig(request), expectedError); + }); + }); + + describe('updateDisplayDevice', () => { + it('invokes updateDisplayDevice without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateDisplayDeviceInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDisplayDeviceInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDisplayDeviceInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDisplayDeviceInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.updateDisplayDevice = stubSimpleCall(expectedResponse); + const [response] = await client.updateDisplayDevice(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.updateDisplayDevice as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDisplayDevice as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDisplayDevice without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateDisplayDeviceInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDisplayDeviceInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDisplayDeviceInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDisplayDeviceInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.updateDisplayDevice = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDisplayDevice( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateDisplayDevice as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDisplayDevice as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDisplayDevice with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateDisplayDeviceInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDisplayDeviceInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDisplayDeviceInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDisplayDeviceInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDisplayDevice = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateDisplayDevice(request), expectedError); + const actualRequest = (client.innerApiCalls.updateDisplayDevice as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDisplayDevice as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDisplayDevice with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateDisplayDeviceInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDisplayDeviceInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDisplayDeviceInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateDisplayDeviceInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateDisplayDevice(request), expectedError); + }); + }); + + describe('updateNetworkInterface', () => { + it('invokes updateNetworkInterface without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateNetworkInterfaceInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateNetworkInterfaceInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateNetworkInterfaceInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateNetworkInterfaceInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.updateNetworkInterface = stubSimpleCall(expectedResponse); + const [response] = await client.updateNetworkInterface(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.updateNetworkInterface as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateNetworkInterface as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateNetworkInterface without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateNetworkInterfaceInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateNetworkInterfaceInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateNetworkInterfaceInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateNetworkInterfaceInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.updateNetworkInterface = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateNetworkInterface( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateNetworkInterface as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateNetworkInterface as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateNetworkInterface with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateNetworkInterfaceInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateNetworkInterfaceInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateNetworkInterfaceInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateNetworkInterfaceInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateNetworkInterface = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateNetworkInterface(request), expectedError); + const actualRequest = (client.innerApiCalls.updateNetworkInterface as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateNetworkInterface as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateNetworkInterface with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateNetworkInterfaceInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateNetworkInterfaceInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateNetworkInterfaceInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateNetworkInterfaceInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateNetworkInterface(request), expectedError); + }); + }); + + describe('updateShieldedInstanceConfig', () => { + it('invokes updateShieldedInstanceConfig without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateShieldedInstanceConfigInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateShieldedInstanceConfigInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateShieldedInstanceConfigInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateShieldedInstanceConfigInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.updateShieldedInstanceConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateShieldedInstanceConfig(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateShieldedInstanceConfig without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateShieldedInstanceConfigInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateShieldedInstanceConfigInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateShieldedInstanceConfigInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateShieldedInstanceConfigInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.updateShieldedInstanceConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateShieldedInstanceConfig( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateShieldedInstanceConfig with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateShieldedInstanceConfigInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateShieldedInstanceConfigInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateShieldedInstanceConfigInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateShieldedInstanceConfigInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateShieldedInstanceConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateShieldedInstanceConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateShieldedInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateShieldedInstanceConfig with closed client', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateShieldedInstanceConfigInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateShieldedInstanceConfigInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateShieldedInstanceConfigInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateShieldedInstanceConfigInstanceRequest', ['instance']); + request.instance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateShieldedInstanceConfig(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListInstancesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.InstancesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.InstancesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.InstancesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IInstancesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListInstancesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IInstancesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Instance()), + generateSampleMessage(new protos.google.cloud.compute.v1.Instance()), + generateSampleMessage(new protos.google.cloud.compute.v1.Instance()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Instance()), + generateSampleMessage(new protos.google.cloud.compute.v1.Instance()), + generateSampleMessage(new protos.google.cloud.compute.v1.Instance()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstance[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Instance()), + generateSampleMessage(new protos.google.cloud.compute.v1.Instance()), + generateSampleMessage(new protos.google.cloud.compute.v1.Instance()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Instance[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Instance[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Instance()), + generateSampleMessage(new protos.google.cloud.compute.v1.Instance()), + generateSampleMessage(new protos.google.cloud.compute.v1.Instance()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IInstance[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listReferrers', () => { + it('invokes listReferrers without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListReferrersInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Reference()), + generateSampleMessage(new protos.google.cloud.compute.v1.Reference()), + generateSampleMessage(new protos.google.cloud.compute.v1.Reference()), + ]; + client.innerApiCalls.listReferrers = stubSimpleCall(expectedResponse); + const [response] = await client.listReferrers(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listReferrers as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferrers as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferrers without error using callback', async () => { + const client = new instancesModule.v1.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListReferrersInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Reference()), + generateSampleMessage(new protos.google.cloud.compute.v1.Reference()), + generateSampleMessage(new protos.google.cloud.compute.v1.Reference()), + ]; + client.innerApiCalls.listReferrers = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReferrers( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IReference[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listReferrers as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferrers as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferrers with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListReferrersInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listReferrers = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listReferrers(request), expectedError); + const actualRequest = (client.innerApiCalls.listReferrers as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferrers as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferrersStream without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListReferrersInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Reference()), + generateSampleMessage(new protos.google.cloud.compute.v1.Reference()), + generateSampleMessage(new protos.google.cloud.compute.v1.Reference()), + ]; + client.descriptors.page.listReferrers.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listReferrersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Reference[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Reference) => { + 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.listReferrers.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferrers, request)); + assert( + (client.descriptors.page.listReferrers.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listReferrersStream with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListReferrersInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReferrers.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listReferrersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Reference[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Reference) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listReferrers.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferrers, request)); + assert( + (client.descriptors.page.listReferrers.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listReferrers without error', async () => { + const client = new instancesModule.v1.InstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListReferrersInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Reference()), + generateSampleMessage(new protos.google.cloud.compute.v1.Reference()), + generateSampleMessage(new protos.google.cloud.compute.v1.Reference()), + ]; + client.descriptors.page.listReferrers.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IReference[] = []; + const iterable = client.listReferrersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listReferrers.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listReferrers.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listReferrers with error', async () => { + const client = new instancesModule.v1.InstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListReferrersInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReferrersInstancesRequest', ['instance']); + request.instance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReferrers.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listReferrersAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IReference[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listReferrers.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listReferrers.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_interconnect_attachments_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_interconnect_attachments_v1.ts new file mode 100644 index 00000000000..f2a1cf32146 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_interconnect_attachments_v1.ts @@ -0,0 +1,1194 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as interconnectattachmentsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.InterconnectAttachmentsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = interconnectattachmentsModule.v1.InterconnectAttachmentsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = interconnectattachmentsModule.v1.InterconnectAttachmentsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = interconnectattachmentsModule.v1.InterconnectAttachmentsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.interconnectAttachmentsStub, undefined); + await client.initialize(); + assert(client.interconnectAttachmentsStub); + }); + + it('has close method for the initialized client', done => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.interconnectAttachmentsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.interconnectAttachmentsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + 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 interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectAttachmentRequest', ['interconnectAttachment']); + request.interconnectAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&interconnect_attachment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectAttachmentRequest', ['interconnectAttachment']); + request.interconnectAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&interconnect_attachment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectAttachmentRequest', ['interconnectAttachment']); + request.interconnectAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&interconnect_attachment=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectAttachmentRequest', ['interconnectAttachment']); + request.interconnectAttachment = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectAttachmentRequest', ['interconnectAttachment']); + request.interconnectAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&interconnect_attachment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InterconnectAttachment() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectAttachmentRequest', ['interconnectAttachment']); + request.interconnectAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&interconnect_attachment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InterconnectAttachment() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInterconnectAttachment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectAttachmentRequest', ['interconnectAttachment']); + request.interconnectAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&interconnect_attachment=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectAttachmentRequest', ['interconnectAttachment']); + request.interconnectAttachment = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectAttachmentRequest', ['interconnectAttachment']); + request.interconnectAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&interconnect_attachment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectAttachmentRequest', ['interconnectAttachment']); + request.interconnectAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&interconnect_attachment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectAttachmentRequest', ['interconnectAttachment']); + request.interconnectAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&interconnect_attachment=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectAttachmentRequest', ['interconnectAttachment']); + request.interconnectAttachment = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('setLabels', () => { + it('invokes setLabels without error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCall(expectedResponse); + const [response] = await client.setLabels(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels without error using callback', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setLabels( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setLabels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with closed client', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsInterconnectAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setLabels(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListInterconnectAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListInterconnectAttachmentsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectAttachmentsScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectAttachmentsScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectAttachmentsScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IInterconnectAttachmentsScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListInterconnectAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListInterconnectAttachmentsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IInterconnectAttachmentsScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectAttachment()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectAttachment()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInterconnectAttachment[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectAttachment()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InterconnectAttachment[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InterconnectAttachment) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InterconnectAttachment[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InterconnectAttachment) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectAttachment()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IInterconnectAttachment[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new interconnectattachmentsModule.v1.InterconnectAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IInterconnectAttachment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_interconnect_locations_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_interconnect_locations_v1.ts new file mode 100644 index 00000000000..3f3161e4f53 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_interconnect_locations_v1.ts @@ -0,0 +1,573 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as interconnectlocationsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.InterconnectLocationsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = interconnectlocationsModule.v1.InterconnectLocationsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = interconnectlocationsModule.v1.InterconnectLocationsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = interconnectlocationsModule.v1.InterconnectLocationsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.interconnectLocationsStub, undefined); + await client.initialize(); + assert(client.interconnectLocationsStub); + }); + + it('has close method for the initialized client', done => { + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.interconnectLocationsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.interconnectLocationsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient({ + auth: googleAuth, + 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 interconnectlocationsModule.v1.InterconnectLocationsClient({ + auth: googleAuth, + 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('get', () => { + it('invokes get without error', async () => { + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInterconnectLocationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectLocationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectLocationRequest', ['interconnectLocation']); + request.interconnectLocation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&interconnect_location=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InterconnectLocation() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInterconnectLocationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectLocationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectLocationRequest', ['interconnectLocation']); + request.interconnectLocation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&interconnect_location=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InterconnectLocation() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInterconnectLocation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInterconnectLocationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectLocationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectLocationRequest', ['interconnectLocation']); + request.interconnectLocation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&interconnect_location=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInterconnectLocationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectLocationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectLocationRequest', ['interconnectLocation']); + request.interconnectLocation = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectLocationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectLocation()), + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectLocation()), + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectLocation()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectLocationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectLocation()), + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectLocation()), + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectLocation()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInterconnectLocation[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectLocationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectLocationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectLocation()), + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectLocation()), + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectLocation()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InterconnectLocation[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InterconnectLocation) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectLocationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InterconnectLocation[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InterconnectLocation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectLocationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectLocation()), + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectLocation()), + generateSampleMessage(new protos.google.cloud.compute.v1.InterconnectLocation()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IInterconnectLocation[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new interconnectlocationsModule.v1.InterconnectLocationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectLocationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectLocationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IInterconnectLocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_interconnects_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_interconnects_v1.ts new file mode 100644 index 00000000000..d57bd697435 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_interconnects_v1.ts @@ -0,0 +1,1161 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as interconnectsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.InterconnectsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = interconnectsModule.v1.InterconnectsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = interconnectsModule.v1.InterconnectsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = interconnectsModule.v1.InterconnectsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new interconnectsModule.v1.InterconnectsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.interconnectsStub, undefined); + await client.initialize(); + assert(client.interconnectsStub); + }); + + it('has close method for the initialized client', done => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.interconnectsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.interconnectsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + 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 interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectRequest', ['interconnect']); + request.interconnect = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&interconnect=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectRequest', ['interconnect']); + request.interconnect = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&interconnect=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectRequest', ['interconnect']); + request.interconnect = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&interconnect=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInterconnectRequest', ['interconnect']); + request.interconnect = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectRequest', ['interconnect']); + request.interconnect = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&interconnect=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Interconnect() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectRequest', ['interconnect']); + request.interconnect = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&interconnect=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Interconnect() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInterconnect|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectRequest', ['interconnect']); + request.interconnect = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&interconnect=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetInterconnectRequest', ['interconnect']); + request.interconnect = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getDiagnostics', () => { + it('invokes getDiagnostics without error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetDiagnosticsInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiagnosticsInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiagnosticsInterconnectRequest', ['interconnect']); + request.interconnect = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&interconnect=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InterconnectsGetDiagnosticsResponse() + ); + client.innerApiCalls.getDiagnostics = stubSimpleCall(expectedResponse); + const [response] = await client.getDiagnostics(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDiagnostics as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDiagnostics as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDiagnostics without error using callback', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetDiagnosticsInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiagnosticsInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiagnosticsInterconnectRequest', ['interconnect']); + request.interconnect = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&interconnect=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InterconnectsGetDiagnosticsResponse() + ); + client.innerApiCalls.getDiagnostics = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDiagnostics( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInterconnectsGetDiagnosticsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDiagnostics as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDiagnostics as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDiagnostics with error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetDiagnosticsInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiagnosticsInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiagnosticsInterconnectRequest', ['interconnect']); + request.interconnect = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&interconnect=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDiagnostics = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDiagnostics(request), expectedError); + const actualRequest = (client.innerApiCalls.getDiagnostics as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDiagnostics as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDiagnostics with closed client', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetDiagnosticsInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiagnosticsInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetDiagnosticsInterconnectRequest', ['interconnect']); + request.interconnect = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDiagnostics(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInterconnectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInterconnectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInterconnectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertInterconnectRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectRequest', ['interconnect']); + request.interconnect = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&interconnect=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectRequest', ['interconnect']); + request.interconnect = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&interconnect=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectRequest', ['interconnect']); + request.interconnect = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&interconnect=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchInterconnectRequest', ['interconnect']); + request.interconnect = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('setLabels', () => { + it('invokes setLabels without error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCall(expectedResponse); + const [response] = await client.setLabels(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels without error using callback', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setLabels( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setLabels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with closed client', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsInterconnectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsInterconnectRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setLabels(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Interconnect()), + generateSampleMessage(new protos.google.cloud.compute.v1.Interconnect()), + generateSampleMessage(new protos.google.cloud.compute.v1.Interconnect()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Interconnect()), + generateSampleMessage(new protos.google.cloud.compute.v1.Interconnect()), + generateSampleMessage(new protos.google.cloud.compute.v1.Interconnect()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInterconnect[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Interconnect()), + generateSampleMessage(new protos.google.cloud.compute.v1.Interconnect()), + generateSampleMessage(new protos.google.cloud.compute.v1.Interconnect()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Interconnect[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Interconnect) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Interconnect[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Interconnect) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Interconnect()), + generateSampleMessage(new protos.google.cloud.compute.v1.Interconnect()), + generateSampleMessage(new protos.google.cloud.compute.v1.Interconnect()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IInterconnect[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new interconnectsModule.v1.InterconnectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInterconnectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInterconnectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IInterconnect[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_license_codes_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_license_codes_v1.ts new file mode 100644 index 00000000000..4af4bbcf383 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_license_codes_v1.ts @@ -0,0 +1,401 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as licensecodesModule from '../src'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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); +} + +describe('v1.LicenseCodesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = licensecodesModule.v1.LicenseCodesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = licensecodesModule.v1.LicenseCodesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = licensecodesModule.v1.LicenseCodesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new licensecodesModule.v1.LicenseCodesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new licensecodesModule.v1.LicenseCodesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new licensecodesModule.v1.LicenseCodesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.licenseCodesStub, undefined); + await client.initialize(); + assert(client.licenseCodesStub); + }); + + it('has close method for the initialized client', done => { + const client = new licensecodesModule.v1.LicenseCodesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.licenseCodesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new licensecodesModule.v1.LicenseCodesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.licenseCodesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new licensecodesModule.v1.LicenseCodesClient({ + auth: googleAuth, + 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 licensecodesModule.v1.LicenseCodesClient({ + auth: googleAuth, + 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('get', () => { + it('invokes get without error', async () => { + const client = new licensecodesModule.v1.LicenseCodesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetLicenseCodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetLicenseCodeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetLicenseCodeRequest', ['licenseCode']); + request.licenseCode = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&license_code=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.LicenseCode() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new licensecodesModule.v1.LicenseCodesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetLicenseCodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetLicenseCodeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetLicenseCodeRequest', ['licenseCode']); + request.licenseCode = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&license_code=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.LicenseCode() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ILicenseCode|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new licensecodesModule.v1.LicenseCodesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetLicenseCodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetLicenseCodeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetLicenseCodeRequest', ['licenseCode']); + request.licenseCode = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&license_code=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new licensecodesModule.v1.LicenseCodesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetLicenseCodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetLicenseCodeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetLicenseCodeRequest', ['licenseCode']); + request.licenseCode = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new licensecodesModule.v1.LicenseCodesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsLicenseCodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsLicenseCodeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsLicenseCodeRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new licensecodesModule.v1.LicenseCodesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsLicenseCodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsLicenseCodeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsLicenseCodeRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new licensecodesModule.v1.LicenseCodesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsLicenseCodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsLicenseCodeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsLicenseCodeRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new licensecodesModule.v1.LicenseCodesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsLicenseCodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsLicenseCodeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsLicenseCodeRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_licenses_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_licenses_v1.ts new file mode 100644 index 00000000000..1a89c325f75 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_licenses_v1.ts @@ -0,0 +1,1161 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as licensesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.LicensesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = licensesModule.v1.LicensesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = licensesModule.v1.LicensesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = licensesModule.v1.LicensesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new licensesModule.v1.LicensesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new licensesModule.v1.LicensesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.licensesStub, undefined); + await client.initialize(); + assert(client.licensesStub); + }); + + it('has close method for the initialized client', done => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.licensesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.licensesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + 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 licensesModule.v1.LicensesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteLicenseRequest', ['license']); + request.license = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&license=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteLicenseRequest', ['license']); + request.license = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&license=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteLicenseRequest', ['license']); + request.license = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&license=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteLicenseRequest', ['license']); + request.license = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetLicenseRequest', ['license']); + request.license = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&license=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.License() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetLicenseRequest', ['license']); + request.license = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&license=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.License() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ILicense|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetLicenseRequest', ['license']); + request.license = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&license=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetLicenseRequest', ['license']); + request.license = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyLicenseRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyLicenseRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyLicenseRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyLicenseRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertLicenseRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertLicenseRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertLicenseRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertLicenseRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyLicenseRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyLicenseRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyLicenseRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyLicenseRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsLicenseRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsLicenseRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsLicenseRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsLicenseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsLicenseRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsLicenseRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new licensesModule.v1.LicensesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListLicensesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListLicensesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.License()), + generateSampleMessage(new protos.google.cloud.compute.v1.License()), + generateSampleMessage(new protos.google.cloud.compute.v1.License()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new licensesModule.v1.LicensesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListLicensesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListLicensesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.License()), + generateSampleMessage(new protos.google.cloud.compute.v1.License()), + generateSampleMessage(new protos.google.cloud.compute.v1.License()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ILicense[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new licensesModule.v1.LicensesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListLicensesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListLicensesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new licensesModule.v1.LicensesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListLicensesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListLicensesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.License()), + generateSampleMessage(new protos.google.cloud.compute.v1.License()), + generateSampleMessage(new protos.google.cloud.compute.v1.License()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.License[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.License) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new licensesModule.v1.LicensesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListLicensesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListLicensesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.License[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.License) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new licensesModule.v1.LicensesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListLicensesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListLicensesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.License()), + generateSampleMessage(new protos.google.cloud.compute.v1.License()), + generateSampleMessage(new protos.google.cloud.compute.v1.License()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ILicense[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new licensesModule.v1.LicensesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListLicensesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListLicensesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ILicense[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_machine_images_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_machine_images_v1.ts new file mode 100644 index 00000000000..22fd2c84f61 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_machine_images_v1.ts @@ -0,0 +1,1161 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as machineimagesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.MachineImagesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = machineimagesModule.v1.MachineImagesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = machineimagesModule.v1.MachineImagesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = machineimagesModule.v1.MachineImagesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new machineimagesModule.v1.MachineImagesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.machineImagesStub, undefined); + await client.initialize(); + assert(client.machineImagesStub); + }); + + it('has close method for the initialized client', done => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.machineImagesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.machineImagesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + 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 machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteMachineImageRequest', ['machineImage']); + request.machineImage = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&machine_image=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteMachineImageRequest', ['machineImage']); + request.machineImage = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&machine_image=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteMachineImageRequest', ['machineImage']); + request.machineImage = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&machine_image=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteMachineImageRequest', ['machineImage']); + request.machineImage = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineImageRequest', ['machineImage']); + request.machineImage = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&machine_image=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.MachineImage() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineImageRequest', ['machineImage']); + request.machineImage = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&machine_image=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.MachineImage() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IMachineImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineImageRequest', ['machineImage']); + request.machineImage = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&machine_image=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineImageRequest', ['machineImage']); + request.machineImage = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyMachineImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyMachineImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyMachineImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyMachineImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertMachineImageRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertMachineImageRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertMachineImageRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertMachineImageRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyMachineImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyMachineImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyMachineImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyMachineImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsMachineImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsMachineImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsMachineImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsMachineImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsMachineImageRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsMachineImageRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListMachineImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineImagesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.MachineImage()), + generateSampleMessage(new protos.google.cloud.compute.v1.MachineImage()), + generateSampleMessage(new protos.google.cloud.compute.v1.MachineImage()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListMachineImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineImagesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.MachineImage()), + generateSampleMessage(new protos.google.cloud.compute.v1.MachineImage()), + generateSampleMessage(new protos.google.cloud.compute.v1.MachineImage()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IMachineImage[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListMachineImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineImagesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListMachineImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineImagesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.MachineImage()), + generateSampleMessage(new protos.google.cloud.compute.v1.MachineImage()), + generateSampleMessage(new protos.google.cloud.compute.v1.MachineImage()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.MachineImage[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.MachineImage) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListMachineImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineImagesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.MachineImage[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.MachineImage) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListMachineImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineImagesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.MachineImage()), + generateSampleMessage(new protos.google.cloud.compute.v1.MachineImage()), + generateSampleMessage(new protos.google.cloud.compute.v1.MachineImage()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IMachineImage[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new machineimagesModule.v1.MachineImagesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListMachineImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineImagesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IMachineImage[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_machine_types_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_machine_types_v1.ts new file mode 100644 index 00000000000..d24d797936e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_machine_types_v1.ts @@ -0,0 +1,678 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as machinetypesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.MachineTypesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = machinetypesModule.v1.MachineTypesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = machinetypesModule.v1.MachineTypesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = machinetypesModule.v1.MachineTypesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new machinetypesModule.v1.MachineTypesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new machinetypesModule.v1.MachineTypesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new machinetypesModule.v1.MachineTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.machineTypesStub, undefined); + await client.initialize(); + assert(client.machineTypesStub); + }); + + it('has close method for the initialized client', done => { + const client = new machinetypesModule.v1.MachineTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.machineTypesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new machinetypesModule.v1.MachineTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.machineTypesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new machinetypesModule.v1.MachineTypesClient({ + auth: googleAuth, + 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 machinetypesModule.v1.MachineTypesClient({ + auth: googleAuth, + 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('get', () => { + it('invokes get without error', async () => { + const client = new machinetypesModule.v1.MachineTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetMachineTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineTypeRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineTypeRequest', ['machineType']); + request.machineType = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&machine_type=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.MachineType() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new machinetypesModule.v1.MachineTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetMachineTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineTypeRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineTypeRequest', ['machineType']); + request.machineType = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&machine_type=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.MachineType() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IMachineType|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new machinetypesModule.v1.MachineTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetMachineTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineTypeRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineTypeRequest', ['machineType']); + request.machineType = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&machine_type=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new machinetypesModule.v1.MachineTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetMachineTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineTypeRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetMachineTypeRequest', ['machineType']); + request.machineType = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new machinetypesModule.v1.MachineTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListMachineTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListMachineTypesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.MachineTypesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.MachineTypesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.MachineTypesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IMachineTypesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new machinetypesModule.v1.MachineTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListMachineTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListMachineTypesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IMachineTypesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new machinetypesModule.v1.MachineTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListMachineTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.MachineType()), + generateSampleMessage(new protos.google.cloud.compute.v1.MachineType()), + generateSampleMessage(new protos.google.cloud.compute.v1.MachineType()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new machinetypesModule.v1.MachineTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListMachineTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.MachineType()), + generateSampleMessage(new protos.google.cloud.compute.v1.MachineType()), + generateSampleMessage(new protos.google.cloud.compute.v1.MachineType()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IMachineType[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new machinetypesModule.v1.MachineTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListMachineTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new machinetypesModule.v1.MachineTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListMachineTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.MachineType()), + generateSampleMessage(new protos.google.cloud.compute.v1.MachineType()), + generateSampleMessage(new protos.google.cloud.compute.v1.MachineType()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.MachineType[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.MachineType) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new machinetypesModule.v1.MachineTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListMachineTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.MachineType[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.MachineType) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new machinetypesModule.v1.MachineTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListMachineTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.MachineType()), + generateSampleMessage(new protos.google.cloud.compute.v1.MachineType()), + generateSampleMessage(new protos.google.cloud.compute.v1.MachineType()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IMachineType[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new machinetypesModule.v1.MachineTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListMachineTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListMachineTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IMachineType[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_network_attachments_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_network_attachments_v1.ts new file mode 100644 index 00000000000..2b5fc53524f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_network_attachments_v1.ts @@ -0,0 +1,1326 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as networkattachmentsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.NetworkAttachmentsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = networkattachmentsModule.v1.NetworkAttachmentsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = networkattachmentsModule.v1.NetworkAttachmentsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = networkattachmentsModule.v1.NetworkAttachmentsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.networkAttachmentsStub, undefined); + await client.initialize(); + assert(client.networkAttachmentsStub); + }); + + it('has close method for the initialized client', done => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.networkAttachmentsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.networkAttachmentsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + 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 networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkAttachmentRequest', ['networkAttachment']); + request.networkAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_attachment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkAttachmentRequest', ['networkAttachment']); + request.networkAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_attachment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkAttachmentRequest', ['networkAttachment']); + request.networkAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_attachment=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkAttachmentRequest', ['networkAttachment']); + request.networkAttachment = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkAttachmentRequest', ['networkAttachment']); + request.networkAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_attachment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NetworkAttachment() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkAttachmentRequest', ['networkAttachment']); + request.networkAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_attachment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NetworkAttachment() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INetworkAttachment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkAttachmentRequest', ['networkAttachment']); + request.networkAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_attachment=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkAttachmentRequest', ['networkAttachment']); + request.networkAttachment = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNetworkAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListNetworkAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListNetworkAttachmentsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.NetworkAttachmentsScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.NetworkAttachmentsScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.NetworkAttachmentsScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.INetworkAttachmentsScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListNetworkAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListNetworkAttachmentsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.INetworkAttachmentsScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkAttachment()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkAttachment()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INetworkAttachment[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkAttachment()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NetworkAttachment[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NetworkAttachment) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NetworkAttachment[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NetworkAttachment) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkAttachment()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.INetworkAttachment[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new networkattachmentsModule.v1.NetworkAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.INetworkAttachment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_network_edge_security_services_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_network_edge_security_services_v1.ts new file mode 100644 index 00000000000..0be1ad9be05 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_network_edge_security_services_v1.ts @@ -0,0 +1,796 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as networkedgesecurityservicesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.NetworkEdgeSecurityServicesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.networkEdgeSecurityServicesStub, undefined); + await client.initialize(); + assert(client.networkEdgeSecurityServicesStub); + }); + + it('has close method for the initialized client', done => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.networkEdgeSecurityServicesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.networkEdgeSecurityServicesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + 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 networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkEdgeSecurityServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEdgeSecurityServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEdgeSecurityServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEdgeSecurityServiceRequest', ['networkEdgeSecurityService']); + request.networkEdgeSecurityService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_edge_security_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkEdgeSecurityServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEdgeSecurityServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEdgeSecurityServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEdgeSecurityServiceRequest', ['networkEdgeSecurityService']); + request.networkEdgeSecurityService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_edge_security_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkEdgeSecurityServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEdgeSecurityServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEdgeSecurityServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEdgeSecurityServiceRequest', ['networkEdgeSecurityService']); + request.networkEdgeSecurityService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_edge_security_service=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkEdgeSecurityServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEdgeSecurityServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEdgeSecurityServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEdgeSecurityServiceRequest', ['networkEdgeSecurityService']); + request.networkEdgeSecurityService = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkEdgeSecurityServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEdgeSecurityServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEdgeSecurityServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEdgeSecurityServiceRequest', ['networkEdgeSecurityService']); + request.networkEdgeSecurityService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_edge_security_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NetworkEdgeSecurityService() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkEdgeSecurityServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEdgeSecurityServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEdgeSecurityServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEdgeSecurityServiceRequest', ['networkEdgeSecurityService']); + request.networkEdgeSecurityService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_edge_security_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NetworkEdgeSecurityService() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INetworkEdgeSecurityService|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkEdgeSecurityServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEdgeSecurityServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEdgeSecurityServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEdgeSecurityServiceRequest', ['networkEdgeSecurityService']); + request.networkEdgeSecurityService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_edge_security_service=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkEdgeSecurityServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEdgeSecurityServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEdgeSecurityServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEdgeSecurityServiceRequest', ['networkEdgeSecurityService']); + request.networkEdgeSecurityService = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkEdgeSecurityServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkEdgeSecurityServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkEdgeSecurityServiceRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkEdgeSecurityServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkEdgeSecurityServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkEdgeSecurityServiceRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkEdgeSecurityServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkEdgeSecurityServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkEdgeSecurityServiceRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkEdgeSecurityServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkEdgeSecurityServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkEdgeSecurityServiceRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchNetworkEdgeSecurityServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkEdgeSecurityServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkEdgeSecurityServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkEdgeSecurityServiceRequest', ['networkEdgeSecurityService']); + request.networkEdgeSecurityService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_edge_security_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchNetworkEdgeSecurityServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkEdgeSecurityServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkEdgeSecurityServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkEdgeSecurityServiceRequest', ['networkEdgeSecurityService']); + request.networkEdgeSecurityService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_edge_security_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchNetworkEdgeSecurityServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkEdgeSecurityServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkEdgeSecurityServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkEdgeSecurityServiceRequest', ['networkEdgeSecurityService']); + request.networkEdgeSecurityService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_edge_security_service=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchNetworkEdgeSecurityServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkEdgeSecurityServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkEdgeSecurityServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkEdgeSecurityServiceRequest', ['networkEdgeSecurityService']); + request.networkEdgeSecurityService = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListNetworkEdgeSecurityServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListNetworkEdgeSecurityServicesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEdgeSecurityServicesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEdgeSecurityServicesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEdgeSecurityServicesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.INetworkEdgeSecurityServicesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new networkedgesecurityservicesModule.v1.NetworkEdgeSecurityServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListNetworkEdgeSecurityServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListNetworkEdgeSecurityServicesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.INetworkEdgeSecurityServicesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_network_endpoint_groups_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_network_endpoint_groups_v1.ts new file mode 100644 index 00000000000..c0762f1c8a7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_network_endpoint_groups_v1.ts @@ -0,0 +1,1613 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as networkendpointgroupsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.NetworkEndpointGroupsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = networkendpointgroupsModule.v1.NetworkEndpointGroupsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = networkendpointgroupsModule.v1.NetworkEndpointGroupsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = networkendpointgroupsModule.v1.NetworkEndpointGroupsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.networkEndpointGroupsStub, undefined); + await client.initialize(); + assert(client.networkEndpointGroupsStub); + }); + + it('has close method for the initialized client', done => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.networkEndpointGroupsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.networkEndpointGroupsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + 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 networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + 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('attachNetworkEndpoints', () => { + it('invokes attachNetworkEndpoints without error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AttachNetworkEndpointsNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.attachNetworkEndpoints = stubSimpleCall(expectedResponse); + const [response] = await client.attachNetworkEndpoints(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.attachNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.attachNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes attachNetworkEndpoints without error using callback', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AttachNetworkEndpointsNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.attachNetworkEndpoints = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.attachNetworkEndpoints( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.attachNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.attachNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes attachNetworkEndpoints with error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AttachNetworkEndpointsNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.attachNetworkEndpoints = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.attachNetworkEndpoints(request), expectedError); + const actualRequest = (client.innerApiCalls.attachNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.attachNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes attachNetworkEndpoints with closed client', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AttachNetworkEndpointsNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AttachNetworkEndpointsNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.attachNetworkEndpoints(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('detachNetworkEndpoints', () => { + it('invokes detachNetworkEndpoints without error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DetachNetworkEndpointsNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.detachNetworkEndpoints = stubSimpleCall(expectedResponse); + const [response] = await client.detachNetworkEndpoints(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.detachNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.detachNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes detachNetworkEndpoints without error using callback', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DetachNetworkEndpointsNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.detachNetworkEndpoints = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.detachNetworkEndpoints( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.detachNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.detachNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes detachNetworkEndpoints with error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DetachNetworkEndpointsNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.detachNetworkEndpoints = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.detachNetworkEndpoints(request), expectedError); + const actualRequest = (client.innerApiCalls.detachNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.detachNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes detachNetworkEndpoints with closed client', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DetachNetworkEndpointsNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DetachNetworkEndpointsNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.detachNetworkEndpoints(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NetworkEndpointGroup() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NetworkEndpointGroup() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INetworkEndpointGroup|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkEndpointGroupRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkEndpointGroupRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkEndpointGroupRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkEndpointGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkEndpointGroupRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroupsScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroupsScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroupsScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.INetworkEndpointGroupsScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.INetworkEndpointGroupsScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INetworkEndpointGroup[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NetworkEndpointGroup[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NetworkEndpointGroup) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NetworkEndpointGroup[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NetworkEndpointGroup) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.INetworkEndpointGroup[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.INetworkEndpointGroup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listNetworkEndpoints', () => { + it('invokes listNetworkEndpoints without error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + ]; + client.innerApiCalls.listNetworkEndpoints = stubSimpleCall(expectedResponse); + const [response] = await client.listNetworkEndpoints(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNetworkEndpoints without error using callback', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + ]; + client.innerApiCalls.listNetworkEndpoints = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listNetworkEndpoints( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNetworkEndpoints with error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listNetworkEndpoints = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listNetworkEndpoints(request), expectedError); + const actualRequest = (client.innerApiCalls.listNetworkEndpoints as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listNetworkEndpoints as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNetworkEndpointsStream without error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + ]; + client.descriptors.page.listNetworkEndpoints.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listNetworkEndpointsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus) => { + 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.listNetworkEndpoints.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNetworkEndpoints, request)); + assert( + (client.descriptors.page.listNetworkEndpoints.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listNetworkEndpointsStream with error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listNetworkEndpoints.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listNetworkEndpointsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listNetworkEndpoints.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNetworkEndpoints, request)); + assert( + (client.descriptors.page.listNetworkEndpoints.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listNetworkEndpoints without error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointWithHealthStatus()), + ]; + client.descriptors.page.listNetworkEndpoints.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus[] = []; + const iterable = client.listNetworkEndpointsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listNetworkEndpoints.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listNetworkEndpoints.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listNetworkEndpoints with error', async () => { + const client = new networkendpointgroupsModule.v1.NetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkEndpointsNetworkEndpointGroupsRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listNetworkEndpoints.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listNetworkEndpointsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.INetworkEndpointWithHealthStatus[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listNetworkEndpoints.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listNetworkEndpoints.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_network_firewall_policies_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_network_firewall_policies_v1.ts new file mode 100644 index 00000000000..e7cc9cfa426 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_network_firewall_policies_v1.ts @@ -0,0 +1,2241 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as networkfirewallpoliciesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.NetworkFirewallPoliciesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.networkFirewallPoliciesStub, undefined); + await client.initialize(); + assert(client.networkFirewallPoliciesStub); + }); + + it('has close method for the initialized client', done => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.networkFirewallPoliciesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.networkFirewallPoliciesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + 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 networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + 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('addAssociation', () => { + it('invokes addAssociation without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddAssociationNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addAssociation = stubSimpleCall(expectedResponse); + const [response] = await client.addAssociation(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addAssociation without error using callback', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddAssociationNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addAssociation = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addAssociation( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addAssociation with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddAssociationNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addAssociation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addAssociation(request), expectedError); + const actualRequest = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addAssociation with closed client', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddAssociationNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addAssociation(request), expectedError); + }); + }); + + describe('addRule', () => { + it('invokes addRule without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddRuleNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addRule = stubSimpleCall(expectedResponse); + const [response] = await client.addRule(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addRule without error using callback', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddRuleNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addRule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addRule( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addRule with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddRuleNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addRule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addRule(request), expectedError); + const actualRequest = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addRule with closed client', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddRuleNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addRule(request), expectedError); + }); + }); + + describe('cloneRules', () => { + it('invokes cloneRules without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CloneRulesNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.cloneRules = stubSimpleCall(expectedResponse); + const [response] = await client.cloneRules(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cloneRules without error using callback', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CloneRulesNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.cloneRules = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.cloneRules( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cloneRules with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CloneRulesNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.cloneRules = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.cloneRules(request), expectedError); + const actualRequest = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cloneRules with closed client', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CloneRulesNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.cloneRules(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicy() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicy() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IFirewallPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getAssociation', () => { + it('invokes getAssociation without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAssociationNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicyAssociation() + ); + client.innerApiCalls.getAssociation = stubSimpleCall(expectedResponse); + const [response] = await client.getAssociation(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAssociation without error using callback', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAssociationNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicyAssociation() + ); + client.innerApiCalls.getAssociation = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAssociation( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IFirewallPolicyAssociation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAssociation with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAssociationNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAssociation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAssociation(request), expectedError); + const actualRequest = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAssociation with closed client', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAssociationNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getAssociation(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('getRule', () => { + it('invokes getRule without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRuleNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicyRule() + ); + client.innerApiCalls.getRule = stubSimpleCall(expectedResponse); + const [response] = await client.getRule(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRule without error using callback', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRuleNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicyRule() + ); + client.innerApiCalls.getRule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRule( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IFirewallPolicyRule|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRule with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRuleNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRule(request), expectedError); + const actualRequest = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRule with closed client', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRuleNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getRule(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('patchRule', () => { + it('invokes patchRule without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRuleNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patchRule = stubSimpleCall(expectedResponse); + const [response] = await client.patchRule(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchRule without error using callback', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRuleNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patchRule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patchRule( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchRule with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRuleNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patchRule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patchRule(request), expectedError); + const actualRequest = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchRule with closed client', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRuleNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patchRule(request), expectedError); + }); + }); + + describe('removeAssociation', () => { + it('invokes removeAssociation without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveAssociationNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeAssociation = stubSimpleCall(expectedResponse); + const [response] = await client.removeAssociation(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeAssociation without error using callback', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveAssociationNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeAssociation = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeAssociation( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeAssociation with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveAssociationNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeAssociation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeAssociation(request), expectedError); + const actualRequest = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeAssociation with closed client', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveAssociationNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeAssociation(request), expectedError); + }); + }); + + describe('removeRule', () => { + it('invokes removeRule without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveRuleNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeRule = stubSimpleCall(expectedResponse); + const [response] = await client.removeRule(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeRule without error using callback', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveRuleNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeRule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeRule( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeRule with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveRuleNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&firewall_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeRule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeRule(request), expectedError); + const actualRequest = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeRule with closed client', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveRuleNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeRule(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkFirewallPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkFirewallPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkFirewallPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkFirewallPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IFirewallPolicy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkFirewallPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkFirewallPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkFirewallPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkFirewallPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.FirewallPolicy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.FirewallPolicy) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkFirewallPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkFirewallPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.FirewallPolicy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.FirewallPolicy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkFirewallPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkFirewallPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IFirewallPolicy[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new networkfirewallpoliciesModule.v1.NetworkFirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworkFirewallPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworkFirewallPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IFirewallPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_networks_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_networks_v1.ts new file mode 100644 index 00000000000..4db2217433f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_networks_v1.ts @@ -0,0 +1,1787 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as networksModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.NetworksClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = networksModule.v1.NetworksClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = networksModule.v1.NetworksClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = networksModule.v1.NetworksClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new networksModule.v1.NetworksClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new networksModule.v1.NetworksClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.networksStub, undefined); + await client.initialize(); + assert(client.networksStub); + }); + + it('has close method for the initialized client', done => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.networksStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.networksStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + 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 networksModule.v1.NetworksClient({ + auth: googleAuth, + 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('addPeering', () => { + it('invokes addPeering without error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddPeeringNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddPeeringNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddPeeringNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addPeering = stubSimpleCall(expectedResponse); + const [response] = await client.addPeering(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addPeering as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addPeering as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addPeering without error using callback', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddPeeringNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddPeeringNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddPeeringNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addPeering = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addPeering( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addPeering as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addPeering as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addPeering with error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddPeeringNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddPeeringNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddPeeringNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addPeering = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addPeering(request), expectedError); + const actualRequest = (client.innerApiCalls.addPeering as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addPeering as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addPeering with closed client', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddPeeringNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddPeeringNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddPeeringNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addPeering(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Network() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Network() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INetwork|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getEffectiveFirewalls', () => { + it('invokes getEffectiveFirewalls without error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetEffectiveFirewallsNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NetworksGetEffectiveFirewallsResponse() + ); + client.innerApiCalls.getEffectiveFirewalls = stubSimpleCall(expectedResponse); + const [response] = await client.getEffectiveFirewalls(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEffectiveFirewalls without error using callback', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetEffectiveFirewallsNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NetworksGetEffectiveFirewallsResponse() + ); + client.innerApiCalls.getEffectiveFirewalls = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEffectiveFirewalls( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INetworksGetEffectiveFirewallsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEffectiveFirewalls with error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetEffectiveFirewallsNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEffectiveFirewalls = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getEffectiveFirewalls(request), expectedError); + const actualRequest = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEffectiveFirewalls with closed client', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetEffectiveFirewallsNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getEffectiveFirewalls(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNetworkRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('removePeering', () => { + it('invokes removePeering without error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemovePeeringNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemovePeeringNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemovePeeringNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removePeering = stubSimpleCall(expectedResponse); + const [response] = await client.removePeering(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.removePeering as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removePeering as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removePeering without error using callback', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemovePeeringNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemovePeeringNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemovePeeringNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removePeering = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removePeering( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removePeering as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removePeering as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removePeering with error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemovePeeringNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemovePeeringNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemovePeeringNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removePeering = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removePeering(request), expectedError); + const actualRequest = (client.innerApiCalls.removePeering as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removePeering as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removePeering with closed client', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemovePeeringNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemovePeeringNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemovePeeringNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removePeering(request), expectedError); + }); + }); + + describe('switchToCustomMode', () => { + it('invokes switchToCustomMode without error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SwitchToCustomModeNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SwitchToCustomModeNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SwitchToCustomModeNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.switchToCustomMode = stubSimpleCall(expectedResponse); + const [response] = await client.switchToCustomMode(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.switchToCustomMode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.switchToCustomMode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes switchToCustomMode without error using callback', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SwitchToCustomModeNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SwitchToCustomModeNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SwitchToCustomModeNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.switchToCustomMode = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.switchToCustomMode( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.switchToCustomMode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.switchToCustomMode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes switchToCustomMode with error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SwitchToCustomModeNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SwitchToCustomModeNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SwitchToCustomModeNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.switchToCustomMode = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.switchToCustomMode(request), expectedError); + const actualRequest = (client.innerApiCalls.switchToCustomMode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.switchToCustomMode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes switchToCustomMode with closed client', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SwitchToCustomModeNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SwitchToCustomModeNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SwitchToCustomModeNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.switchToCustomMode(request), expectedError); + }); + }); + + describe('updatePeering', () => { + it('invokes updatePeering without error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdatePeeringNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePeeringNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePeeringNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.updatePeering = stubSimpleCall(expectedResponse); + const [response] = await client.updatePeering(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.updatePeering as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePeering as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePeering without error using callback', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdatePeeringNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePeeringNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePeeringNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.updatePeering = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updatePeering( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updatePeering as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePeering as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePeering with error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdatePeeringNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePeeringNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePeeringNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePeering = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updatePeering(request), expectedError); + const actualRequest = (client.innerApiCalls.updatePeering as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePeering as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePeering with closed client', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdatePeeringNetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePeeringNetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePeeringNetworkRequest', ['network']); + request.network = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updatePeering(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new networksModule.v1.NetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Network()), + generateSampleMessage(new protos.google.cloud.compute.v1.Network()), + generateSampleMessage(new protos.google.cloud.compute.v1.Network()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new networksModule.v1.NetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Network()), + generateSampleMessage(new protos.google.cloud.compute.v1.Network()), + generateSampleMessage(new protos.google.cloud.compute.v1.Network()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INetwork[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new networksModule.v1.NetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new networksModule.v1.NetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Network()), + generateSampleMessage(new protos.google.cloud.compute.v1.Network()), + generateSampleMessage(new protos.google.cloud.compute.v1.Network()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Network[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Network) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new networksModule.v1.NetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Network[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Network) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Network()), + generateSampleMessage(new protos.google.cloud.compute.v1.Network()), + generateSampleMessage(new protos.google.cloud.compute.v1.Network()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.INetwork[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new networksModule.v1.NetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNetworksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.INetwork[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listPeeringRoutes', () => { + it('invokes listPeeringRoutes without error', async () => { + const client = new networksModule.v1.NetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ExchangedPeeringRoute()), + generateSampleMessage(new protos.google.cloud.compute.v1.ExchangedPeeringRoute()), + generateSampleMessage(new protos.google.cloud.compute.v1.ExchangedPeeringRoute()), + ]; + client.innerApiCalls.listPeeringRoutes = stubSimpleCall(expectedResponse); + const [response] = await client.listPeeringRoutes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPeeringRoutes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPeeringRoutes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPeeringRoutes without error using callback', async () => { + const client = new networksModule.v1.NetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ExchangedPeeringRoute()), + generateSampleMessage(new protos.google.cloud.compute.v1.ExchangedPeeringRoute()), + generateSampleMessage(new protos.google.cloud.compute.v1.ExchangedPeeringRoute()), + ]; + client.innerApiCalls.listPeeringRoutes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPeeringRoutes( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IExchangedPeeringRoute[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPeeringRoutes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPeeringRoutes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPeeringRoutes with error', async () => { + const client = new networksModule.v1.NetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPeeringRoutes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listPeeringRoutes(request), expectedError); + const actualRequest = (client.innerApiCalls.listPeeringRoutes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPeeringRoutes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPeeringRoutesStream without error', async () => { + const client = new networksModule.v1.NetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ExchangedPeeringRoute()), + generateSampleMessage(new protos.google.cloud.compute.v1.ExchangedPeeringRoute()), + generateSampleMessage(new protos.google.cloud.compute.v1.ExchangedPeeringRoute()), + ]; + client.descriptors.page.listPeeringRoutes.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listPeeringRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.ExchangedPeeringRoute[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.ExchangedPeeringRoute) => { + 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.listPeeringRoutes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPeeringRoutes, request)); + assert( + (client.descriptors.page.listPeeringRoutes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listPeeringRoutesStream with error', async () => { + const client = new networksModule.v1.NetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPeeringRoutes.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listPeeringRoutesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.ExchangedPeeringRoute[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.ExchangedPeeringRoute) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listPeeringRoutes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPeeringRoutes, request)); + assert( + (client.descriptors.page.listPeeringRoutes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPeeringRoutes without error', async () => { + const client = new networksModule.v1.NetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ExchangedPeeringRoute()), + generateSampleMessage(new protos.google.cloud.compute.v1.ExchangedPeeringRoute()), + generateSampleMessage(new protos.google.cloud.compute.v1.ExchangedPeeringRoute()), + ]; + client.descriptors.page.listPeeringRoutes.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IExchangedPeeringRoute[] = []; + const iterable = client.listPeeringRoutesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listPeeringRoutes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPeeringRoutes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPeeringRoutes with error', async () => { + const client = new networksModule.v1.NetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPeeringRoutesNetworksRequest', ['network']); + request.network = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&network=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPeeringRoutes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPeeringRoutesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IExchangedPeeringRoute[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listPeeringRoutes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPeeringRoutes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_node_groups_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_node_groups_v1.ts new file mode 100644 index 00000000000..5a8a23d5152 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_node_groups_v1.ts @@ -0,0 +1,2273 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as nodegroupsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.NodeGroupsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = nodegroupsModule.v1.NodeGroupsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = nodegroupsModule.v1.NodeGroupsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = nodegroupsModule.v1.NodeGroupsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new nodegroupsModule.v1.NodeGroupsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.nodeGroupsStub, undefined); + await client.initialize(); + assert(client.nodeGroupsStub); + }); + + it('has close method for the initialized client', done => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.nodeGroupsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.nodeGroupsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + 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 nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + 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('addNodes', () => { + it('invokes addNodes without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddNodesNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddNodesNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddNodesNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddNodesNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addNodes = stubSimpleCall(expectedResponse); + const [response] = await client.addNodes(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addNodes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addNodes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addNodes without error using callback', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddNodesNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddNodesNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddNodesNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddNodesNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addNodes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addNodes( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addNodes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addNodes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addNodes with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddNodesNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddNodesNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddNodesNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddNodesNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addNodes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addNodes(request), expectedError); + const actualRequest = (client.innerApiCalls.addNodes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addNodes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addNodes with closed client', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddNodesNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddNodesNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddNodesNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddNodesNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addNodes(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('deleteNodes', () => { + it('invokes deleteNodes without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNodesNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodesNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodesNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodesNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deleteNodes = stubSimpleCall(expectedResponse); + const [response] = await client.deleteNodes(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteNodes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteNodes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteNodes without error using callback', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNodesNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodesNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodesNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodesNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deleteNodes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteNodes( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteNodes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteNodes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteNodes with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNodesNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodesNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodesNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodesNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteNodes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteNodes(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteNodes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteNodes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteNodes with closed client', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNodesNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodesNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodesNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodesNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteNodes(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NodeGroup() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NodeGroup() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INodeGroup|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeGroupRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeGroupRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeGroupRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeGroupRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeGroupRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeGroupRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeGroupRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeGroupRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('setNodeTemplate', () => { + it('invokes setNodeTemplate without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetNodeTemplateNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNodeTemplateNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNodeTemplateNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNodeTemplateNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setNodeTemplate = stubSimpleCall(expectedResponse); + const [response] = await client.setNodeTemplate(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setNodeTemplate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setNodeTemplate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setNodeTemplate without error using callback', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetNodeTemplateNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNodeTemplateNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNodeTemplateNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNodeTemplateNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setNodeTemplate = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setNodeTemplate( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setNodeTemplate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setNodeTemplate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setNodeTemplate with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetNodeTemplateNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNodeTemplateNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNodeTemplateNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNodeTemplateNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setNodeTemplate = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setNodeTemplate(request), expectedError); + const actualRequest = (client.innerApiCalls.setNodeTemplate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setNodeTemplate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setNodeTemplate with closed client', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetNodeTemplateNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNodeTemplateNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNodeTemplateNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNodeTemplateNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setNodeTemplate(request), expectedError); + }); + }); + + describe('simulateMaintenanceEvent', () => { + it('invokes simulateMaintenanceEvent without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SimulateMaintenanceEventNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.simulateMaintenanceEvent = stubSimpleCall(expectedResponse); + const [response] = await client.simulateMaintenanceEvent(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.simulateMaintenanceEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.simulateMaintenanceEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes simulateMaintenanceEvent without error using callback', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SimulateMaintenanceEventNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.simulateMaintenanceEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.simulateMaintenanceEvent( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.simulateMaintenanceEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.simulateMaintenanceEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes simulateMaintenanceEvent with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SimulateMaintenanceEventNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.simulateMaintenanceEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.simulateMaintenanceEvent(request), expectedError); + const actualRequest = (client.innerApiCalls.simulateMaintenanceEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.simulateMaintenanceEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes simulateMaintenanceEvent with closed client', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SimulateMaintenanceEventNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SimulateMaintenanceEventNodeGroupRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.simulateMaintenanceEvent(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeGroupRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeGroupRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeGroupRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNodeGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeGroupRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeGroupRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListNodeGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListNodeGroupsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroupsScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroupsScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroupsScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.INodeGroupsScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListNodeGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListNodeGroupsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.INodeGroupsScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroup()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroup()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INodeGroup[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroup()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NodeGroup[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NodeGroup) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NodeGroup[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NodeGroup) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroup()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.INodeGroup[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeGroupsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.INodeGroup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listNodes', () => { + it('invokes listNodes without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodesNodeGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroupNode()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroupNode()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroupNode()), + ]; + client.innerApiCalls.listNodes = stubSimpleCall(expectedResponse); + const [response] = await client.listNodes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNodes without error using callback', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodesNodeGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroupNode()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroupNode()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroupNode()), + ]; + client.innerApiCalls.listNodes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listNodes( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INodeGroupNode[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNodes with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodesNodeGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listNodes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listNodes(request), expectedError); + const actualRequest = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNodesStream without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodesNodeGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroupNode()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroupNode()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroupNode()), + ]; + client.descriptors.page.listNodes.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listNodesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NodeGroupNode[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NodeGroupNode) => { + 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.listNodes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNodes, request)); + assert( + (client.descriptors.page.listNodes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listNodesStream with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodesNodeGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listNodes.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listNodesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NodeGroupNode[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NodeGroupNode) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listNodes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNodes, request)); + assert( + (client.descriptors.page.listNodes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listNodes without error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodesNodeGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroupNode()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroupNode()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeGroupNode()), + ]; + client.descriptors.page.listNodes.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.INodeGroupNode[] = []; + const iterable = client.listNodesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listNodes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listNodes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listNodes with error', async () => { + const client = new nodegroupsModule.v1.NodeGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodesNodeGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodesNodeGroupsRequest', ['nodeGroup']); + request.nodeGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listNodes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listNodesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.INodeGroupNode[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listNodes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listNodes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_node_templates_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_node_templates_v1.ts new file mode 100644 index 00000000000..bf649a63a75 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_node_templates_v1.ts @@ -0,0 +1,1326 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as nodetemplatesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.NodeTemplatesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = nodetemplatesModule.v1.NodeTemplatesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = nodetemplatesModule.v1.NodeTemplatesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = nodetemplatesModule.v1.NodeTemplatesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.nodeTemplatesStub, undefined); + await client.initialize(); + assert(client.nodeTemplatesStub); + }); + + it('has close method for the initialized client', done => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.nodeTemplatesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.nodeTemplatesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + 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 nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeTemplateRequest', ['nodeTemplate']); + request.nodeTemplate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&node_template=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeTemplateRequest', ['nodeTemplate']); + request.nodeTemplate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&node_template=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeTemplateRequest', ['nodeTemplate']); + request.nodeTemplate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&node_template=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteNodeTemplateRequest', ['nodeTemplate']); + request.nodeTemplate = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTemplateRequest', ['nodeTemplate']); + request.nodeTemplate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&node_template=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NodeTemplate() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTemplateRequest', ['nodeTemplate']); + request.nodeTemplate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&node_template=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NodeTemplate() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INodeTemplate|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTemplateRequest', ['nodeTemplate']); + request.nodeTemplate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&node_template=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTemplateRequest', ['nodeTemplate']); + request.nodeTemplate = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeTemplateRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeTemplateRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeTemplateRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyNodeTemplateRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeTemplateRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeTemplateRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeTemplateRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyNodeTemplateRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeTemplateRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeTemplateRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeTemplateRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsNodeTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsNodeTemplateRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListNodeTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListNodeTemplatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.NodeTemplatesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.NodeTemplatesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.NodeTemplatesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.INodeTemplatesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListNodeTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListNodeTemplatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.INodeTemplatesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTemplatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTemplatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NodeTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeTemplate()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTemplatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTemplatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NodeTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeTemplate()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INodeTemplate[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTemplatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTemplatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTemplatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTemplatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NodeTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeTemplate()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NodeTemplate[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NodeTemplate) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTemplatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTemplatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NodeTemplate[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NodeTemplate) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTemplatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTemplatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NodeTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeTemplate()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.INodeTemplate[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new nodetemplatesModule.v1.NodeTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTemplatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTemplatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.INodeTemplate[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_node_types_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_node_types_v1.ts new file mode 100644 index 00000000000..f0d7b3fe5a3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_node_types_v1.ts @@ -0,0 +1,678 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as nodetypesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.NodeTypesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = nodetypesModule.v1.NodeTypesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = nodetypesModule.v1.NodeTypesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = nodetypesModule.v1.NodeTypesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new nodetypesModule.v1.NodeTypesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new nodetypesModule.v1.NodeTypesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new nodetypesModule.v1.NodeTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.nodeTypesStub, undefined); + await client.initialize(); + assert(client.nodeTypesStub); + }); + + it('has close method for the initialized client', done => { + const client = new nodetypesModule.v1.NodeTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.nodeTypesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new nodetypesModule.v1.NodeTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.nodeTypesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new nodetypesModule.v1.NodeTypesClient({ + auth: googleAuth, + 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 nodetypesModule.v1.NodeTypesClient({ + auth: googleAuth, + 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('get', () => { + it('invokes get without error', async () => { + const client = new nodetypesModule.v1.NodeTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNodeTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTypeRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTypeRequest', ['nodeType']); + request.nodeType = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_type=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NodeType() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new nodetypesModule.v1.NodeTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNodeTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTypeRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTypeRequest', ['nodeType']); + request.nodeType = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_type=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NodeType() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INodeType|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new nodetypesModule.v1.NodeTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNodeTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTypeRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTypeRequest', ['nodeType']); + request.nodeType = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&node_type=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new nodetypesModule.v1.NodeTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNodeTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTypeRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNodeTypeRequest', ['nodeType']); + request.nodeType = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new nodetypesModule.v1.NodeTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListNodeTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListNodeTypesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.NodeTypesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.NodeTypesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.NodeTypesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.INodeTypesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new nodetypesModule.v1.NodeTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListNodeTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListNodeTypesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.INodeTypesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new nodetypesModule.v1.NodeTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NodeType()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeType()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeType()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new nodetypesModule.v1.NodeTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NodeType()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeType()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeType()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INodeType[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new nodetypesModule.v1.NodeTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new nodetypesModule.v1.NodeTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NodeType()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeType()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeType()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NodeType[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NodeType) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new nodetypesModule.v1.NodeTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NodeType[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NodeType) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new nodetypesModule.v1.NodeTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NodeType()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeType()), + generateSampleMessage(new protos.google.cloud.compute.v1.NodeType()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.INodeType[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new nodetypesModule.v1.NodeTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListNodeTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListNodeTypesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.INodeType[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_packet_mirrorings_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_packet_mirrorings_v1.ts new file mode 100644 index 00000000000..dd60759fc61 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_packet_mirrorings_v1.ts @@ -0,0 +1,1194 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as packetmirroringsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.PacketMirroringsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = packetmirroringsModule.v1.PacketMirroringsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = packetmirroringsModule.v1.PacketMirroringsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = packetmirroringsModule.v1.PacketMirroringsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.packetMirroringsStub, undefined); + await client.initialize(); + assert(client.packetMirroringsStub); + }); + + it('has close method for the initialized client', done => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.packetMirroringsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.packetMirroringsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + 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 packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePacketMirroringRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePacketMirroringRequest', ['packetMirroring']); + request.packetMirroring = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&packet_mirroring=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePacketMirroringRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePacketMirroringRequest', ['packetMirroring']); + request.packetMirroring = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&packet_mirroring=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePacketMirroringRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePacketMirroringRequest', ['packetMirroring']); + request.packetMirroring = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&packet_mirroring=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePacketMirroringRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePacketMirroringRequest', ['packetMirroring']); + request.packetMirroring = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetPacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPacketMirroringRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPacketMirroringRequest', ['packetMirroring']); + request.packetMirroring = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&packet_mirroring=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.PacketMirroring() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetPacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPacketMirroringRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPacketMirroringRequest', ['packetMirroring']); + request.packetMirroring = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&packet_mirroring=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.PacketMirroring() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPacketMirroring|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetPacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPacketMirroringRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPacketMirroringRequest', ['packetMirroring']); + request.packetMirroring = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&packet_mirroring=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetPacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPacketMirroringRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPacketMirroringRequest', ['packetMirroring']); + request.packetMirroring = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertPacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPacketMirroringRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertPacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPacketMirroringRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertPacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPacketMirroringRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertPacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPacketMirroringRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPacketMirroringRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPacketMirroringRequest', ['packetMirroring']); + request.packetMirroring = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&packet_mirroring=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPacketMirroringRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPacketMirroringRequest', ['packetMirroring']); + request.packetMirroring = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&packet_mirroring=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPacketMirroringRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPacketMirroringRequest', ['packetMirroring']); + request.packetMirroring = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&packet_mirroring=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPacketMirroringRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPacketMirroringRequest', ['packetMirroring']); + request.packetMirroring = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsPacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsPacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsPacketMirroringRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsPacketMirroringRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsPacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsPacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsPacketMirroringRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsPacketMirroringRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsPacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsPacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsPacketMirroringRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsPacketMirroringRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsPacketMirroringRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsPacketMirroringRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsPacketMirroringRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsPacketMirroringRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListPacketMirroringsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListPacketMirroringsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.PacketMirroringsScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.PacketMirroringsScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.PacketMirroringsScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IPacketMirroringsScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListPacketMirroringsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListPacketMirroringsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IPacketMirroringsScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPacketMirroringsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPacketMirroringsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPacketMirroringsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PacketMirroring()), + generateSampleMessage(new protos.google.cloud.compute.v1.PacketMirroring()), + generateSampleMessage(new protos.google.cloud.compute.v1.PacketMirroring()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPacketMirroringsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPacketMirroringsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPacketMirroringsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PacketMirroring()), + generateSampleMessage(new protos.google.cloud.compute.v1.PacketMirroring()), + generateSampleMessage(new protos.google.cloud.compute.v1.PacketMirroring()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPacketMirroring[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPacketMirroringsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPacketMirroringsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPacketMirroringsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPacketMirroringsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPacketMirroringsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPacketMirroringsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PacketMirroring()), + generateSampleMessage(new protos.google.cloud.compute.v1.PacketMirroring()), + generateSampleMessage(new protos.google.cloud.compute.v1.PacketMirroring()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.PacketMirroring[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.PacketMirroring) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPacketMirroringsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPacketMirroringsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPacketMirroringsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.PacketMirroring[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.PacketMirroring) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPacketMirroringsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPacketMirroringsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPacketMirroringsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PacketMirroring()), + generateSampleMessage(new protos.google.cloud.compute.v1.PacketMirroring()), + generateSampleMessage(new protos.google.cloud.compute.v1.PacketMirroring()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IPacketMirroring[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new packetmirroringsModule.v1.PacketMirroringsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPacketMirroringsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPacketMirroringsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPacketMirroringsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IPacketMirroring[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_projects_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_projects_v1.ts new file mode 100644 index 00000000000..57f538bbffa --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_projects_v1.ts @@ -0,0 +1,1886 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as projectsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.ProjectsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = projectsModule.v1.ProjectsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = projectsModule.v1.ProjectsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = projectsModule.v1.ProjectsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new projectsModule.v1.ProjectsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new projectsModule.v1.ProjectsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.projectsStub, undefined); + await client.initialize(); + assert(client.projectsStub); + }); + + it('has close method for the initialized client', done => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.projectsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.projectsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + 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 projectsModule.v1.ProjectsClient({ + auth: googleAuth, + 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('disableXpnHost', () => { + it('invokes disableXpnHost without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DisableXpnHostProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DisableXpnHostProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.disableXpnHost = stubSimpleCall(expectedResponse); + const [response] = await client.disableXpnHost(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.disableXpnHost as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.disableXpnHost as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes disableXpnHost without error using callback', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DisableXpnHostProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DisableXpnHostProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.disableXpnHost = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.disableXpnHost( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.disableXpnHost as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.disableXpnHost as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes disableXpnHost with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DisableXpnHostProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DisableXpnHostProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.disableXpnHost = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.disableXpnHost(request), expectedError); + const actualRequest = (client.innerApiCalls.disableXpnHost as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.disableXpnHost as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes disableXpnHost with closed client', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DisableXpnHostProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DisableXpnHostProjectRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.disableXpnHost(request), expectedError); + }); + }); + + describe('disableXpnResource', () => { + it('invokes disableXpnResource without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DisableXpnResourceProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DisableXpnResourceProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.disableXpnResource = stubSimpleCall(expectedResponse); + const [response] = await client.disableXpnResource(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.disableXpnResource as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.disableXpnResource as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes disableXpnResource without error using callback', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DisableXpnResourceProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DisableXpnResourceProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.disableXpnResource = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.disableXpnResource( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.disableXpnResource as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.disableXpnResource as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes disableXpnResource with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DisableXpnResourceProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DisableXpnResourceProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.disableXpnResource = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.disableXpnResource(request), expectedError); + const actualRequest = (client.innerApiCalls.disableXpnResource as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.disableXpnResource as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes disableXpnResource with closed client', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DisableXpnResourceProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DisableXpnResourceProjectRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.disableXpnResource(request), expectedError); + }); + }); + + describe('enableXpnHost', () => { + it('invokes enableXpnHost without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.EnableXpnHostProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.EnableXpnHostProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.enableXpnHost = stubSimpleCall(expectedResponse); + const [response] = await client.enableXpnHost(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.enableXpnHost as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.enableXpnHost as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes enableXpnHost without error using callback', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.EnableXpnHostProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.EnableXpnHostProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.enableXpnHost = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.enableXpnHost( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.enableXpnHost as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.enableXpnHost as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes enableXpnHost with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.EnableXpnHostProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.EnableXpnHostProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.enableXpnHost = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.enableXpnHost(request), expectedError); + const actualRequest = (client.innerApiCalls.enableXpnHost as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.enableXpnHost as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes enableXpnHost with closed client', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.EnableXpnHostProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.EnableXpnHostProjectRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.enableXpnHost(request), expectedError); + }); + }); + + describe('enableXpnResource', () => { + it('invokes enableXpnResource without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.EnableXpnResourceProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.EnableXpnResourceProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.enableXpnResource = stubSimpleCall(expectedResponse); + const [response] = await client.enableXpnResource(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.enableXpnResource as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.enableXpnResource as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes enableXpnResource without error using callback', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.EnableXpnResourceProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.EnableXpnResourceProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.enableXpnResource = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.enableXpnResource( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.enableXpnResource as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.enableXpnResource as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes enableXpnResource with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.EnableXpnResourceProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.EnableXpnResourceProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.enableXpnResource = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.enableXpnResource(request), expectedError); + const actualRequest = (client.innerApiCalls.enableXpnResource as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.enableXpnResource as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes enableXpnResource with closed client', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.EnableXpnResourceProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.EnableXpnResourceProjectRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.enableXpnResource(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Project() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Project() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IProject|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetProjectRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getXpnHost', () => { + it('invokes getXpnHost without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetXpnHostProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetXpnHostProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Project() + ); + client.innerApiCalls.getXpnHost = stubSimpleCall(expectedResponse); + const [response] = await client.getXpnHost(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getXpnHost as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getXpnHost as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getXpnHost without error using callback', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetXpnHostProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetXpnHostProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Project() + ); + client.innerApiCalls.getXpnHost = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getXpnHost( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IProject|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getXpnHost as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getXpnHost as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getXpnHost with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetXpnHostProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetXpnHostProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getXpnHost = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getXpnHost(request), expectedError); + const actualRequest = (client.innerApiCalls.getXpnHost as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getXpnHost as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getXpnHost with closed client', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetXpnHostProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetXpnHostProjectRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getXpnHost(request), expectedError); + }); + }); + + describe('moveDisk', () => { + it('invokes moveDisk without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.MoveDiskProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.MoveDiskProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.moveDisk = stubSimpleCall(expectedResponse); + const [response] = await client.moveDisk(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.moveDisk as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.moveDisk as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes moveDisk without error using callback', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.MoveDiskProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.MoveDiskProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.moveDisk = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.moveDisk( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.moveDisk as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.moveDisk as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes moveDisk with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.MoveDiskProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.MoveDiskProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.moveDisk = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.moveDisk(request), expectedError); + const actualRequest = (client.innerApiCalls.moveDisk as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.moveDisk as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes moveDisk with closed client', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.MoveDiskProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.MoveDiskProjectRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.moveDisk(request), expectedError); + }); + }); + + describe('moveInstance', () => { + it('invokes moveInstance without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.MoveInstanceProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.MoveInstanceProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.moveInstance = stubSimpleCall(expectedResponse); + const [response] = await client.moveInstance(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.moveInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.moveInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes moveInstance without error using callback', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.MoveInstanceProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.MoveInstanceProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.moveInstance = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.moveInstance( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.moveInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.moveInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes moveInstance with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.MoveInstanceProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.MoveInstanceProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.moveInstance = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.moveInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.moveInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.moveInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes moveInstance with closed client', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.MoveInstanceProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.MoveInstanceProjectRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.moveInstance(request), expectedError); + }); + }); + + describe('setCommonInstanceMetadata', () => { + it('invokes setCommonInstanceMetadata without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetCommonInstanceMetadataProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCommonInstanceMetadataProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setCommonInstanceMetadata = stubSimpleCall(expectedResponse); + const [response] = await client.setCommonInstanceMetadata(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setCommonInstanceMetadata as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setCommonInstanceMetadata as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setCommonInstanceMetadata without error using callback', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetCommonInstanceMetadataProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCommonInstanceMetadataProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setCommonInstanceMetadata = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setCommonInstanceMetadata( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setCommonInstanceMetadata as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setCommonInstanceMetadata as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setCommonInstanceMetadata with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetCommonInstanceMetadataProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCommonInstanceMetadataProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setCommonInstanceMetadata = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setCommonInstanceMetadata(request), expectedError); + const actualRequest = (client.innerApiCalls.setCommonInstanceMetadata as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setCommonInstanceMetadata as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setCommonInstanceMetadata with closed client', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetCommonInstanceMetadataProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCommonInstanceMetadataProjectRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setCommonInstanceMetadata(request), expectedError); + }); + }); + + describe('setDefaultNetworkTier', () => { + it('invokes setDefaultNetworkTier without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetDefaultNetworkTierProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDefaultNetworkTierProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setDefaultNetworkTier = stubSimpleCall(expectedResponse); + const [response] = await client.setDefaultNetworkTier(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setDefaultNetworkTier as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultNetworkTier as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultNetworkTier without error using callback', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetDefaultNetworkTierProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDefaultNetworkTierProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setDefaultNetworkTier = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setDefaultNetworkTier( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setDefaultNetworkTier as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultNetworkTier as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultNetworkTier with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetDefaultNetworkTierProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDefaultNetworkTierProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultNetworkTier = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setDefaultNetworkTier(request), expectedError); + const actualRequest = (client.innerApiCalls.setDefaultNetworkTier as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultNetworkTier as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultNetworkTier with closed client', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetDefaultNetworkTierProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetDefaultNetworkTierProjectRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setDefaultNetworkTier(request), expectedError); + }); + }); + + describe('setUsageExportBucket', () => { + it('invokes setUsageExportBucket without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUsageExportBucketProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUsageExportBucketProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setUsageExportBucket = stubSimpleCall(expectedResponse); + const [response] = await client.setUsageExportBucket(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setUsageExportBucket as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setUsageExportBucket as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setUsageExportBucket without error using callback', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUsageExportBucketProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUsageExportBucketProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setUsageExportBucket = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setUsageExportBucket( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setUsageExportBucket as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setUsageExportBucket as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setUsageExportBucket with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUsageExportBucketProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUsageExportBucketProjectRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setUsageExportBucket = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setUsageExportBucket(request), expectedError); + const actualRequest = (client.innerApiCalls.setUsageExportBucket as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setUsageExportBucket as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setUsageExportBucket with closed client', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUsageExportBucketProjectRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUsageExportBucketProjectRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setUsageExportBucket(request), expectedError); + }); + }); + + describe('getXpnResources', () => { + it('invokes getXpnResources without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetXpnResourcesProjectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetXpnResourcesProjectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.XpnResourceId()), + generateSampleMessage(new protos.google.cloud.compute.v1.XpnResourceId()), + generateSampleMessage(new protos.google.cloud.compute.v1.XpnResourceId()), + ]; + client.innerApiCalls.getXpnResources = stubSimpleCall(expectedResponse); + const [response] = await client.getXpnResources(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getXpnResources as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getXpnResources as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getXpnResources without error using callback', async () => { + const client = new projectsModule.v1.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetXpnResourcesProjectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetXpnResourcesProjectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.XpnResourceId()), + generateSampleMessage(new protos.google.cloud.compute.v1.XpnResourceId()), + generateSampleMessage(new protos.google.cloud.compute.v1.XpnResourceId()), + ]; + client.innerApiCalls.getXpnResources = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getXpnResources( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IXpnResourceId[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getXpnResources as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getXpnResources as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getXpnResources with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetXpnResourcesProjectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetXpnResourcesProjectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getXpnResources = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getXpnResources(request), expectedError); + const actualRequest = (client.innerApiCalls.getXpnResources as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getXpnResources as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getXpnResourcesStream without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetXpnResourcesProjectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetXpnResourcesProjectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.XpnResourceId()), + generateSampleMessage(new protos.google.cloud.compute.v1.XpnResourceId()), + generateSampleMessage(new protos.google.cloud.compute.v1.XpnResourceId()), + ]; + client.descriptors.page.getXpnResources.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.getXpnResourcesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.XpnResourceId[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.XpnResourceId) => { + 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.getXpnResources.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.getXpnResources, request)); + assert( + (client.descriptors.page.getXpnResources.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes getXpnResourcesStream with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetXpnResourcesProjectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetXpnResourcesProjectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.getXpnResources.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.getXpnResourcesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.XpnResourceId[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.XpnResourceId) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.getXpnResources.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.getXpnResources, request)); + assert( + (client.descriptors.page.getXpnResources.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with getXpnResources without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetXpnResourcesProjectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetXpnResourcesProjectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.XpnResourceId()), + generateSampleMessage(new protos.google.cloud.compute.v1.XpnResourceId()), + generateSampleMessage(new protos.google.cloud.compute.v1.XpnResourceId()), + ]; + client.descriptors.page.getXpnResources.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IXpnResourceId[] = []; + const iterable = client.getXpnResourcesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.getXpnResources.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.getXpnResources.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with getXpnResources with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetXpnResourcesProjectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetXpnResourcesProjectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.getXpnResources.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.getXpnResourcesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IXpnResourceId[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.getXpnResources.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.getXpnResources.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listXpnHosts', () => { + it('invokes listXpnHosts without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListXpnHostsProjectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListXpnHostsProjectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Project()), + generateSampleMessage(new protos.google.cloud.compute.v1.Project()), + generateSampleMessage(new protos.google.cloud.compute.v1.Project()), + ]; + client.innerApiCalls.listXpnHosts = stubSimpleCall(expectedResponse); + const [response] = await client.listXpnHosts(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listXpnHosts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listXpnHosts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listXpnHosts without error using callback', async () => { + const client = new projectsModule.v1.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListXpnHostsProjectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListXpnHostsProjectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Project()), + generateSampleMessage(new protos.google.cloud.compute.v1.Project()), + generateSampleMessage(new protos.google.cloud.compute.v1.Project()), + ]; + client.innerApiCalls.listXpnHosts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listXpnHosts( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IProject[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listXpnHosts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listXpnHosts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listXpnHosts with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListXpnHostsProjectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListXpnHostsProjectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listXpnHosts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listXpnHosts(request), expectedError); + const actualRequest = (client.innerApiCalls.listXpnHosts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listXpnHosts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listXpnHostsStream without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListXpnHostsProjectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListXpnHostsProjectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Project()), + generateSampleMessage(new protos.google.cloud.compute.v1.Project()), + generateSampleMessage(new protos.google.cloud.compute.v1.Project()), + ]; + client.descriptors.page.listXpnHosts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listXpnHostsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Project[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Project) => { + 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.listXpnHosts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listXpnHosts, request)); + assert( + (client.descriptors.page.listXpnHosts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listXpnHostsStream with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListXpnHostsProjectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListXpnHostsProjectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listXpnHosts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listXpnHostsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Project[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Project) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listXpnHosts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listXpnHosts, request)); + assert( + (client.descriptors.page.listXpnHosts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listXpnHosts without error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListXpnHostsProjectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListXpnHostsProjectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Project()), + generateSampleMessage(new protos.google.cloud.compute.v1.Project()), + generateSampleMessage(new protos.google.cloud.compute.v1.Project()), + ]; + client.descriptors.page.listXpnHosts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IProject[] = []; + const iterable = client.listXpnHostsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listXpnHosts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listXpnHosts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listXpnHosts with error', async () => { + const client = new projectsModule.v1.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListXpnHostsProjectsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListXpnHostsProjectsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listXpnHosts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listXpnHostsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IProject[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listXpnHosts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listXpnHosts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_public_advertised_prefixes_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_public_advertised_prefixes_v1.ts new file mode 100644 index 00000000000..ef92738c84c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_public_advertised_prefixes_v1.ts @@ -0,0 +1,921 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as publicadvertisedprefixesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.PublicAdvertisedPrefixesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.publicAdvertisedPrefixesStub, undefined); + await client.initialize(); + assert(client.publicAdvertisedPrefixesStub); + }); + + it('has close method for the initialized client', done => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.publicAdvertisedPrefixesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.publicAdvertisedPrefixesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + 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 publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePublicAdvertisedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicAdvertisedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicAdvertisedPrefixeRequest', ['publicAdvertisedPrefix']); + request.publicAdvertisedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_advertised_prefix=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePublicAdvertisedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicAdvertisedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicAdvertisedPrefixeRequest', ['publicAdvertisedPrefix']); + request.publicAdvertisedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_advertised_prefix=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePublicAdvertisedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicAdvertisedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicAdvertisedPrefixeRequest', ['publicAdvertisedPrefix']); + request.publicAdvertisedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_advertised_prefix=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePublicAdvertisedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicAdvertisedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicAdvertisedPrefixeRequest', ['publicAdvertisedPrefix']); + request.publicAdvertisedPrefix = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetPublicAdvertisedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicAdvertisedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicAdvertisedPrefixeRequest', ['publicAdvertisedPrefix']); + request.publicAdvertisedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_advertised_prefix=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.PublicAdvertisedPrefix() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetPublicAdvertisedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicAdvertisedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicAdvertisedPrefixeRequest', ['publicAdvertisedPrefix']); + request.publicAdvertisedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_advertised_prefix=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.PublicAdvertisedPrefix() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPublicAdvertisedPrefix|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetPublicAdvertisedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicAdvertisedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicAdvertisedPrefixeRequest', ['publicAdvertisedPrefix']); + request.publicAdvertisedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_advertised_prefix=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetPublicAdvertisedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicAdvertisedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicAdvertisedPrefixeRequest', ['publicAdvertisedPrefix']); + request.publicAdvertisedPrefix = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertPublicAdvertisedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPublicAdvertisedPrefixeRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertPublicAdvertisedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPublicAdvertisedPrefixeRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertPublicAdvertisedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPublicAdvertisedPrefixeRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertPublicAdvertisedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPublicAdvertisedPrefixeRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPublicAdvertisedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicAdvertisedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicAdvertisedPrefixeRequest', ['publicAdvertisedPrefix']); + request.publicAdvertisedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_advertised_prefix=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPublicAdvertisedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicAdvertisedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicAdvertisedPrefixeRequest', ['publicAdvertisedPrefix']); + request.publicAdvertisedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_advertised_prefix=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPublicAdvertisedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicAdvertisedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicAdvertisedPrefixeRequest', ['publicAdvertisedPrefix']); + request.publicAdvertisedPrefix = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&public_advertised_prefix=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPublicAdvertisedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicAdvertisedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicAdvertisedPrefixeRequest', ['publicAdvertisedPrefix']); + request.publicAdvertisedPrefix = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPublicAdvertisedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicAdvertisedPrefixesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PublicAdvertisedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicAdvertisedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicAdvertisedPrefix()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPublicAdvertisedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicAdvertisedPrefixesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PublicAdvertisedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicAdvertisedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicAdvertisedPrefix()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPublicAdvertisedPrefix[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPublicAdvertisedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicAdvertisedPrefixesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPublicAdvertisedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicAdvertisedPrefixesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PublicAdvertisedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicAdvertisedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicAdvertisedPrefix()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.PublicAdvertisedPrefix[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.PublicAdvertisedPrefix) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPublicAdvertisedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicAdvertisedPrefixesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.PublicAdvertisedPrefix[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.PublicAdvertisedPrefix) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPublicAdvertisedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicAdvertisedPrefixesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PublicAdvertisedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicAdvertisedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicAdvertisedPrefix()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IPublicAdvertisedPrefix[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new publicadvertisedprefixesModule.v1.PublicAdvertisedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPublicAdvertisedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicAdvertisedPrefixesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IPublicAdvertisedPrefix[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_public_delegated_prefixes_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_public_delegated_prefixes_v1.ts new file mode 100644 index 00000000000..1f1b496aabb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_public_delegated_prefixes_v1.ts @@ -0,0 +1,1062 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as publicdelegatedprefixesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.PublicDelegatedPrefixesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.publicDelegatedPrefixesStub, undefined); + await client.initialize(); + assert(client.publicDelegatedPrefixesStub); + }); + + it('has close method for the initialized client', done => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.publicDelegatedPrefixesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.publicDelegatedPrefixesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + 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 publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicDelegatedPrefixeRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&public_delegated_prefix=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicDelegatedPrefixeRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&public_delegated_prefix=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicDelegatedPrefixeRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&public_delegated_prefix=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicDelegatedPrefixeRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicDelegatedPrefixeRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&public_delegated_prefix=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.PublicDelegatedPrefix() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicDelegatedPrefixeRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&public_delegated_prefix=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.PublicDelegatedPrefix() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPublicDelegatedPrefix|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicDelegatedPrefixeRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&public_delegated_prefix=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicDelegatedPrefixeRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPublicDelegatedPrefixeRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPublicDelegatedPrefixeRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPublicDelegatedPrefixeRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertPublicDelegatedPrefixeRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicDelegatedPrefixeRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&public_delegated_prefix=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicDelegatedPrefixeRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&public_delegated_prefix=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicDelegatedPrefixeRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&public_delegated_prefix=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPublicDelegatedPrefixeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicDelegatedPrefixeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicDelegatedPrefixeRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPublicDelegatedPrefixeRequest', ['publicDelegatedPrefix']); + request.publicDelegatedPrefix = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListPublicDelegatedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListPublicDelegatedPrefixesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefixesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefixesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefixesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IPublicDelegatedPrefixesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListPublicDelegatedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListPublicDelegatedPrefixesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IPublicDelegatedPrefixesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPublicDelegatedPrefix[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.PublicDelegatedPrefix[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.PublicDelegatedPrefix) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.PublicDelegatedPrefix[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.PublicDelegatedPrefix) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + generateSampleMessage(new protos.google.cloud.compute.v1.PublicDelegatedPrefix()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IPublicDelegatedPrefix[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new publicdelegatedprefixesModule.v1.PublicDelegatedPrefixesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPublicDelegatedPrefixesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IPublicDelegatedPrefix[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_autoscalers_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_autoscalers_v1.ts new file mode 100644 index 00000000000..d1fae33b7f1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_autoscalers_v1.ts @@ -0,0 +1,1098 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regionautoscalersModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionAutoscalersClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regionautoscalersModule.v1.RegionAutoscalersClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regionautoscalersModule.v1.RegionAutoscalersClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regionautoscalersModule.v1.RegionAutoscalersClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionAutoscalersStub, undefined); + await client.initialize(); + assert(client.regionAutoscalersStub); + }); + + it('has close method for the initialized client', done => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionAutoscalersStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionAutoscalersStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + 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 regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionAutoscalerRequest', ['autoscaler']); + request.autoscaler = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&autoscaler=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionAutoscalerRequest', ['autoscaler']); + request.autoscaler = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&autoscaler=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionAutoscalerRequest', ['autoscaler']); + request.autoscaler = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&autoscaler=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionAutoscalerRequest', ['autoscaler']); + request.autoscaler = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionAutoscalerRequest', ['autoscaler']); + request.autoscaler = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&autoscaler=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Autoscaler() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionAutoscalerRequest', ['autoscaler']); + request.autoscaler = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&autoscaler=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Autoscaler() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IAutoscaler|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionAutoscalerRequest', ['autoscaler']); + request.autoscaler = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&autoscaler=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionAutoscalerRequest', ['autoscaler']); + request.autoscaler = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionAutoscalerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionAutoscalerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionAutoscalerRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionAutoscalersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionAutoscalersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionAutoscalersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionAutoscalersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionAutoscalersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionAutoscalersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IAutoscaler[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionAutoscalersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionAutoscalersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionAutoscalersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionAutoscalersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionAutoscalersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionAutoscalersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Autoscaler[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Autoscaler) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionAutoscalersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionAutoscalersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionAutoscalersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Autoscaler[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Autoscaler) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionAutoscalersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionAutoscalersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionAutoscalersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + generateSampleMessage(new protos.google.cloud.compute.v1.Autoscaler()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IAutoscaler[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regionautoscalersModule.v1.RegionAutoscalersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionAutoscalersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionAutoscalersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionAutoscalersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IAutoscaler[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_backend_services_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_backend_services_v1.ts new file mode 100644 index 00000000000..7ec122a3a66 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_backend_services_v1.ts @@ -0,0 +1,1518 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regionbackendservicesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionBackendServicesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regionbackendservicesModule.v1.RegionBackendServicesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regionbackendservicesModule.v1.RegionBackendServicesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regionbackendservicesModule.v1.RegionBackendServicesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionBackendServicesStub, undefined); + await client.initialize(); + assert(client.regionBackendServicesStub); + }); + + it('has close method for the initialized client', done => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionBackendServicesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionBackendServicesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + 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 regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&backend_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&backend_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&backend_service=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&backend_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.BackendService() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&backend_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.BackendService() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IBackendService|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&backend_service=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getHealth', () => { + it('invokes getHealth without error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetHealthRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&backend_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.BackendServiceGroupHealth() + ); + client.innerApiCalls.getHealth = stubSimpleCall(expectedResponse); + const [response] = await client.getHealth(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getHealth without error using callback', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetHealthRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&backend_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.BackendServiceGroupHealth() + ); + client.innerApiCalls.getHealth = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getHealth( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IBackendServiceGroupHealth|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getHealth with error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetHealthRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&backend_service=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getHealth = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getHealth(request), expectedError); + const actualRequest = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getHealth with closed client', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetHealthRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getHealth(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionBackendServiceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionBackendServiceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionBackendServiceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionBackendServiceRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&backend_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&backend_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&backend_service=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionBackendServiceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionBackendServiceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionBackendServiceRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionBackendServiceRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&backend_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&backend_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&backend_service=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionBackendServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionBackendServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionBackendServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionBackendServiceRequest', ['backendService']); + request.backendService = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionBackendServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionBackendServicesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionBackendServicesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionBackendServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionBackendServicesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionBackendServicesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IBackendService[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionBackendServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionBackendServicesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionBackendServicesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionBackendServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionBackendServicesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionBackendServicesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.BackendService[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.BackendService) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionBackendServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionBackendServicesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionBackendServicesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.BackendService[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.BackendService) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionBackendServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionBackendServicesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionBackendServicesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + generateSampleMessage(new protos.google.cloud.compute.v1.BackendService()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IBackendService[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regionbackendservicesModule.v1.RegionBackendServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionBackendServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionBackendServicesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionBackendServicesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IBackendService[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_commitments_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_commitments_v1.ts new file mode 100644 index 00000000000..f20fdd890fb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_commitments_v1.ts @@ -0,0 +1,930 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regioncommitmentsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionCommitmentsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regioncommitmentsModule.v1.RegionCommitmentsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regioncommitmentsModule.v1.RegionCommitmentsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regioncommitmentsModule.v1.RegionCommitmentsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionCommitmentsStub, undefined); + await client.initialize(); + assert(client.regionCommitmentsStub); + }); + + it('has close method for the initialized client', done => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionCommitmentsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionCommitmentsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + 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 regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + 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('get', () => { + it('invokes get without error', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionCommitmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionCommitmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionCommitmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionCommitmentRequest', ['commitment']); + request.commitment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&commitment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Commitment() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionCommitmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionCommitmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionCommitmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionCommitmentRequest', ['commitment']); + request.commitment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&commitment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Commitment() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ICommitment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionCommitmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionCommitmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionCommitmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionCommitmentRequest', ['commitment']); + request.commitment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&commitment=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionCommitmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionCommitmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionCommitmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionCommitmentRequest', ['commitment']); + request.commitment = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionCommitmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionCommitmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionCommitmentRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionCommitmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionCommitmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionCommitmentRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionCommitmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionCommitmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionCommitmentRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionCommitmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionCommitmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionCommitmentRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionCommitmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionCommitmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionCommitmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionCommitmentRequest', ['commitment']); + request.commitment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&commitment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionCommitmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionCommitmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionCommitmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionCommitmentRequest', ['commitment']); + request.commitment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&commitment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionCommitmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionCommitmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionCommitmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionCommitmentRequest', ['commitment']); + request.commitment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&commitment=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionCommitmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionCommitmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionCommitmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionCommitmentRequest', ['commitment']); + request.commitment = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListRegionCommitmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListRegionCommitmentsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.CommitmentsScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.CommitmentsScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.CommitmentsScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.ICommitmentsScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListRegionCommitmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListRegionCommitmentsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.ICommitmentsScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionCommitmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionCommitmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionCommitmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Commitment()), + generateSampleMessage(new protos.google.cloud.compute.v1.Commitment()), + generateSampleMessage(new protos.google.cloud.compute.v1.Commitment()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionCommitmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionCommitmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionCommitmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Commitment()), + generateSampleMessage(new protos.google.cloud.compute.v1.Commitment()), + generateSampleMessage(new protos.google.cloud.compute.v1.Commitment()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ICommitment[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionCommitmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionCommitmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionCommitmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionCommitmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionCommitmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionCommitmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Commitment()), + generateSampleMessage(new protos.google.cloud.compute.v1.Commitment()), + generateSampleMessage(new protos.google.cloud.compute.v1.Commitment()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Commitment[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Commitment) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionCommitmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionCommitmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionCommitmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Commitment[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Commitment) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionCommitmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionCommitmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionCommitmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Commitment()), + generateSampleMessage(new protos.google.cloud.compute.v1.Commitment()), + generateSampleMessage(new protos.google.cloud.compute.v1.Commitment()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ICommitment[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regioncommitmentsModule.v1.RegionCommitmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionCommitmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionCommitmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionCommitmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ICommitment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_disk_types_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_disk_types_v1.ts new file mode 100644 index 00000000000..830168e9dd0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_disk_types_v1.ts @@ -0,0 +1,606 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regiondisktypesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionDiskTypesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regiondisktypesModule.v1.RegionDiskTypesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regiondisktypesModule.v1.RegionDiskTypesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regiondisktypesModule.v1.RegionDiskTypesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regiondisktypesModule.v1.RegionDiskTypesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regiondisktypesModule.v1.RegionDiskTypesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regiondisktypesModule.v1.RegionDiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionDiskTypesStub, undefined); + await client.initialize(); + assert(client.regionDiskTypesStub); + }); + + it('has close method for the initialized client', done => { + const client = new regiondisktypesModule.v1.RegionDiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionDiskTypesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regiondisktypesModule.v1.RegionDiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionDiskTypesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regiondisktypesModule.v1.RegionDiskTypesClient({ + auth: googleAuth, + 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 regiondisktypesModule.v1.RegionDiskTypesClient({ + auth: googleAuth, + 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('get', () => { + it('invokes get without error', async () => { + const client = new regiondisktypesModule.v1.RegionDiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionDiskTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskTypeRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskTypeRequest', ['diskType']); + request.diskType = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk_type=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.DiskType() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regiondisktypesModule.v1.RegionDiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionDiskTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskTypeRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskTypeRequest', ['diskType']); + request.diskType = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk_type=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.DiskType() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IDiskType|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regiondisktypesModule.v1.RegionDiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionDiskTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskTypeRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskTypeRequest', ['diskType']); + request.diskType = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk_type=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regiondisktypesModule.v1.RegionDiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionDiskTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskTypeRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskTypeRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskTypeRequest', ['diskType']); + request.diskType = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regiondisktypesModule.v1.RegionDiskTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionDiskTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDiskTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDiskTypesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regiondisktypesModule.v1.RegionDiskTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionDiskTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDiskTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDiskTypesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IDiskType[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regiondisktypesModule.v1.RegionDiskTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionDiskTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDiskTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDiskTypesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regiondisktypesModule.v1.RegionDiskTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionDiskTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDiskTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDiskTypesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.DiskType[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.DiskType) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regiondisktypesModule.v1.RegionDiskTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionDiskTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDiskTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDiskTypesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.DiskType[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.DiskType) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regiondisktypesModule.v1.RegionDiskTypesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionDiskTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDiskTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDiskTypesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + generateSampleMessage(new protos.google.cloud.compute.v1.DiskType()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IDiskType[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regiondisktypesModule.v1.RegionDiskTypesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionDiskTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDiskTypesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDiskTypesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IDiskType[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_disks_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_disks_v1.ts new file mode 100644 index 00000000000..3aea6af6992 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_disks_v1.ts @@ -0,0 +1,2046 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regiondisksModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionDisksClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regiondisksModule.v1.RegionDisksClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regiondisksModule.v1.RegionDisksClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regiondisksModule.v1.RegionDisksClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regiondisksModule.v1.RegionDisksClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionDisksStub, undefined); + await client.initialize(); + assert(client.regionDisksStub); + }); + + it('has close method for the initialized client', done => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionDisksStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionDisksStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + 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 regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + 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('addResourcePolicies', () => { + it('invokes addResourcePolicies without error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddResourcePoliciesRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addResourcePolicies = stubSimpleCall(expectedResponse); + const [response] = await client.addResourcePolicies(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addResourcePolicies without error using callback', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddResourcePoliciesRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addResourcePolicies = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addResourcePolicies( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addResourcePolicies with error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddResourcePoliciesRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addResourcePolicies = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addResourcePolicies(request), expectedError); + const actualRequest = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addResourcePolicies with closed client', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddResourcePoliciesRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddResourcePoliciesRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addResourcePolicies(request), expectedError); + }); + }); + + describe('createSnapshot', () => { + it('invokes createSnapshot without error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CreateSnapshotRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.createSnapshot = stubSimpleCall(expectedResponse); + const [response] = await client.createSnapshot(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.createSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSnapshot without error using callback', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CreateSnapshotRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.createSnapshot = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSnapshot( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSnapshot with error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CreateSnapshotRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSnapshot = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createSnapshot(request), expectedError); + const actualRequest = (client.innerApiCalls.createSnapshot as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSnapshot as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSnapshot with closed client', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CreateSnapshotRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateSnapshotRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createSnapshot(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Disk() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Disk() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IDisk|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionDiskRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionDiskRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionDiskRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionDiskRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('removeResourcePolicies', () => { + it('invokes removeResourcePolicies without error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveResourcePoliciesRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeResourcePolicies = stubSimpleCall(expectedResponse); + const [response] = await client.removeResourcePolicies(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeResourcePolicies without error using callback', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveResourcePoliciesRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeResourcePolicies = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeResourcePolicies( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeResourcePolicies with error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveResourcePoliciesRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeResourcePolicies = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeResourcePolicies(request), expectedError); + const actualRequest = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeResourcePolicies as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeResourcePolicies with closed client', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveResourcePoliciesRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveResourcePoliciesRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeResourcePolicies(request), expectedError); + }); + }); + + describe('resize', () => { + it('invokes resize without error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.resize = stubSimpleCall(expectedResponse); + const [response] = await client.resize(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resize without error using callback', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.resize = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resize( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resize with error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resize = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.resize(request), expectedError); + const actualRequest = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resize with closed client', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resize(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('setLabels', () => { + it('invokes setLabels without error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsRegionDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCall(expectedResponse); + const [response] = await client.setLabels(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels without error using callback', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsRegionDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setLabels( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsRegionDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setLabels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with closed client', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsRegionDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setLabels(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionDiskRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&disk=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionDiskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionDiskRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionDiskRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionDiskRequest', ['disk']); + request.disk = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionDisksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDisksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDisksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionDisksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDisksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDisksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IDisk[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionDisksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDisksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDisksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionDisksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDisksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDisksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Disk[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Disk) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionDisksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDisksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDisksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Disk[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Disk) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionDisksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDisksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDisksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + generateSampleMessage(new protos.google.cloud.compute.v1.Disk()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IDisk[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regiondisksModule.v1.RegionDisksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionDisksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDisksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionDisksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IDisk[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_health_check_services_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_health_check_services_v1.ts new file mode 100644 index 00000000000..24496ee3af3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_health_check_services_v1.ts @@ -0,0 +1,990 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regionhealthcheckservicesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionHealthCheckServicesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionHealthCheckServicesStub, undefined); + await client.initialize(); + assert(client.regionHealthCheckServicesStub); + }); + + it('has close method for the initialized client', done => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionHealthCheckServicesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionHealthCheckServicesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + 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 regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionHealthCheckServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckServiceRequest', ['healthCheckService']); + request.healthCheckService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionHealthCheckServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckServiceRequest', ['healthCheckService']); + request.healthCheckService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionHealthCheckServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckServiceRequest', ['healthCheckService']); + request.healthCheckService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check_service=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionHealthCheckServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckServiceRequest', ['healthCheckService']); + request.healthCheckService = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionHealthCheckServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckServiceRequest', ['healthCheckService']); + request.healthCheckService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.HealthCheckService() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionHealthCheckServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckServiceRequest', ['healthCheckService']); + request.healthCheckService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.HealthCheckService() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IHealthCheckService|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionHealthCheckServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckServiceRequest', ['healthCheckService']); + request.healthCheckService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check_service=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionHealthCheckServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckServiceRequest', ['healthCheckService']); + request.healthCheckService = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionHealthCheckServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionHealthCheckServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionHealthCheckServiceRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionHealthCheckServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionHealthCheckServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionHealthCheckServiceRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionHealthCheckServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionHealthCheckServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionHealthCheckServiceRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionHealthCheckServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionHealthCheckServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionHealthCheckServiceRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionHealthCheckServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckServiceRequest', ['healthCheckService']); + request.healthCheckService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionHealthCheckServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckServiceRequest', ['healthCheckService']); + request.healthCheckService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check_service=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionHealthCheckServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckServiceRequest', ['healthCheckService']); + request.healthCheckService = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check_service=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionHealthCheckServiceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckServiceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckServiceRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckServiceRequest', ['healthCheckService']); + request.healthCheckService = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheckService()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheckService()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheckService()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheckService()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheckService()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheckService()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IHealthCheckService[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheckService()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheckService()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheckService()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.HealthCheckService[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.HealthCheckService) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.HealthCheckService[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.HealthCheckService) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheckService()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheckService()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheckService()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IHealthCheckService[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regionhealthcheckservicesModule.v1.RegionHealthCheckServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthCheckServicesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IHealthCheckService[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_health_checks_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_health_checks_v1.ts new file mode 100644 index 00000000000..f24a3d90db0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_health_checks_v1.ts @@ -0,0 +1,1122 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regionhealthchecksModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionHealthChecksClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regionhealthchecksModule.v1.RegionHealthChecksClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regionhealthchecksModule.v1.RegionHealthChecksClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regionhealthchecksModule.v1.RegionHealthChecksClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionHealthChecksStub, undefined); + await client.initialize(); + assert(client.regionHealthChecksStub); + }); + + it('has close method for the initialized client', done => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionHealthChecksStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionHealthChecksStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + 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 regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.HealthCheck() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.HealthCheck() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IHealthCheck|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&health_check=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionHealthCheckRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionHealthCheckRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionHealthCheckRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionHealthCheckRequest', ['healthCheck']); + request.healthCheck = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionHealthChecksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthChecksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthChecksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionHealthChecksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthChecksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthChecksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IHealthCheck[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionHealthChecksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthChecksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthChecksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionHealthChecksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthChecksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthChecksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.HealthCheck[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.HealthCheck) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionHealthChecksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthChecksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthChecksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.HealthCheck[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.HealthCheck) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionHealthChecksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthChecksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthChecksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + generateSampleMessage(new protos.google.cloud.compute.v1.HealthCheck()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IHealthCheck[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regionhealthchecksModule.v1.RegionHealthChecksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionHealthChecksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthChecksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionHealthChecksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IHealthCheck[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_instance_group_managers_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_instance_group_managers_v1.ts new file mode 100644 index 00000000000..05ecbb8003a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_instance_group_managers_v1.ts @@ -0,0 +1,3303 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regioninstancegroupmanagersModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionInstanceGroupManagersClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionInstanceGroupManagersStub, undefined); + await client.initialize(); + assert(client.regionInstanceGroupManagersStub); + }); + + it('has close method for the initialized client', done => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionInstanceGroupManagersStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionInstanceGroupManagersStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + 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 regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + 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('abandonInstances', () => { + it('invokes abandonInstances without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AbandonInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.abandonInstances = stubSimpleCall(expectedResponse); + const [response] = await client.abandonInstances(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.abandonInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.abandonInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes abandonInstances without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AbandonInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.abandonInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.abandonInstances( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.abandonInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.abandonInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes abandonInstances with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AbandonInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.abandonInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.abandonInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.abandonInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.abandonInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes abandonInstances with closed client', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AbandonInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AbandonInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.abandonInstances(request), expectedError); + }); + }); + + describe('applyUpdatesToInstances', () => { + it('invokes applyUpdatesToInstances without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.applyUpdatesToInstances = stubSimpleCall(expectedResponse); + const [response] = await client.applyUpdatesToInstances(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.applyUpdatesToInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.applyUpdatesToInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes applyUpdatesToInstances without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.applyUpdatesToInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.applyUpdatesToInstances( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.applyUpdatesToInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.applyUpdatesToInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes applyUpdatesToInstances with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.applyUpdatesToInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.applyUpdatesToInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.applyUpdatesToInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.applyUpdatesToInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes applyUpdatesToInstances with closed client', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.applyUpdatesToInstances(request), expectedError); + }); + }); + + describe('createInstances', () => { + it('invokes createInstances without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CreateInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.createInstances = stubSimpleCall(expectedResponse); + const [response] = await client.createInstances(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.createInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstances without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CreateInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.createInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstances( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstances with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CreateInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.createInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstances with closed client', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CreateInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CreateInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createInstances(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('deleteInstances', () => { + it('invokes deleteInstances without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deleteInstances = stubSimpleCall(expectedResponse); + const [response] = await client.deleteInstances(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstances without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deleteInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstances( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstances with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstances with closed client', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteInstances(request), expectedError); + }); + }); + + describe('deletePerInstanceConfigs', () => { + it('invokes deletePerInstanceConfigs without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deletePerInstanceConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.deletePerInstanceConfigs(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.deletePerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePerInstanceConfigs without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.deletePerInstanceConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePerInstanceConfigs( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deletePerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePerInstanceConfigs with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePerInstanceConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deletePerInstanceConfigs(request), expectedError); + const actualRequest = (client.innerApiCalls.deletePerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePerInstanceConfigs with closed client', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deletePerInstanceConfigs(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InstanceGroupManager() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InstanceGroupManager() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstanceGroupManager|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('patchPerInstanceConfigs', () => { + it('invokes patchPerInstanceConfigs without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patchPerInstanceConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.patchPerInstanceConfigs(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patchPerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchPerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchPerInstanceConfigs without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patchPerInstanceConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patchPerInstanceConfigs( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patchPerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchPerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchPerInstanceConfigs with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patchPerInstanceConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patchPerInstanceConfigs(request), expectedError); + const actualRequest = (client.innerApiCalls.patchPerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchPerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchPerInstanceConfigs with closed client', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patchPerInstanceConfigs(request), expectedError); + }); + }); + + describe('recreateInstances', () => { + it('invokes recreateInstances without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RecreateInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.recreateInstances = stubSimpleCall(expectedResponse); + const [response] = await client.recreateInstances(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.recreateInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.recreateInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes recreateInstances without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RecreateInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.recreateInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.recreateInstances( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.recreateInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.recreateInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes recreateInstances with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RecreateInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.recreateInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.recreateInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.recreateInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.recreateInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes recreateInstances with closed client', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RecreateInstancesRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RecreateInstancesRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.recreateInstances(request), expectedError); + }); + }); + + describe('resize', () => { + it('invokes resize without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.resize = stubSimpleCall(expectedResponse); + const [response] = await client.resize(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resize without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.resize = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resize( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resize with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resize = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.resize(request), expectedError); + const actualRequest = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resize with closed client', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resize(request), expectedError); + }); + }); + + describe('setInstanceTemplate', () => { + it('invokes setInstanceTemplate without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetInstanceTemplateRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setInstanceTemplate = stubSimpleCall(expectedResponse); + const [response] = await client.setInstanceTemplate(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setInstanceTemplate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceTemplate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceTemplate without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetInstanceTemplateRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setInstanceTemplate = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInstanceTemplate( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setInstanceTemplate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceTemplate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceTemplate with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetInstanceTemplateRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInstanceTemplate = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setInstanceTemplate(request), expectedError); + const actualRequest = (client.innerApiCalls.setInstanceTemplate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInstanceTemplate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInstanceTemplate with closed client', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetInstanceTemplateRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetInstanceTemplateRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setInstanceTemplate(request), expectedError); + }); + }); + + describe('setTargetPools', () => { + it('invokes setTargetPools without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTargetPoolsRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setTargetPools = stubSimpleCall(expectedResponse); + const [response] = await client.setTargetPools(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setTargetPools as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setTargetPools as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setTargetPools without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTargetPoolsRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setTargetPools = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setTargetPools( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setTargetPools as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setTargetPools as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setTargetPools with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTargetPoolsRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setTargetPools = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setTargetPools(request), expectedError); + const actualRequest = (client.innerApiCalls.setTargetPools as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setTargetPools as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setTargetPools with closed client', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetTargetPoolsRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetTargetPoolsRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setTargetPools(request), expectedError); + }); + }); + + describe('updatePerInstanceConfigs', () => { + it('invokes updatePerInstanceConfigs without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.updatePerInstanceConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.updatePerInstanceConfigs(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.updatePerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePerInstanceConfigs without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.updatePerInstanceConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updatePerInstanceConfigs( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updatePerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePerInstanceConfigs with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePerInstanceConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updatePerInstanceConfigs(request), expectedError); + const actualRequest = (client.innerApiCalls.updatePerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePerInstanceConfigs with closed client', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updatePerInstanceConfigs(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstanceGroupManager[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceGroupManager[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceGroupManager) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceGroupManager[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceGroupManager) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroupManager()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IInstanceGroupManager[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IInstanceGroupManager[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listErrors', () => { + it('invokes listErrors without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + ]; + client.innerApiCalls.listErrors = stubSimpleCall(expectedResponse); + const [response] = await client.listErrors(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listErrors as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listErrors as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listErrors without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + ]; + client.innerApiCalls.listErrors = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listErrors( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstanceManagedByIgmError[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listErrors as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listErrors as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listErrors with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listErrors = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listErrors(request), expectedError); + const actualRequest = (client.innerApiCalls.listErrors as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listErrors as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listErrorsStream without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + ]; + client.descriptors.page.listErrors.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listErrorsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceManagedByIgmError[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceManagedByIgmError) => { + 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.listErrors.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listErrors, request)); + assert( + (client.descriptors.page.listErrors.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listErrorsStream with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listErrors.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listErrorsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceManagedByIgmError[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceManagedByIgmError) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listErrors.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listErrors, request)); + assert( + (client.descriptors.page.listErrors.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listErrors without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceManagedByIgmError()), + ]; + client.descriptors.page.listErrors.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IInstanceManagedByIgmError[] = []; + const iterable = client.listErrorsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listErrors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listErrors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listErrors with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListErrorsRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listErrors.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listErrorsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IInstanceManagedByIgmError[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listErrors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listErrors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listManagedInstances', () => { + it('invokes listManagedInstances without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + ]; + client.innerApiCalls.listManagedInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listManagedInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listManagedInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listManagedInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listManagedInstances without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + ]; + client.innerApiCalls.listManagedInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listManagedInstances( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IManagedInstance[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listManagedInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listManagedInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listManagedInstances with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listManagedInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listManagedInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.listManagedInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listManagedInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listManagedInstancesStream without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + ]; + client.descriptors.page.listManagedInstances.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listManagedInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.ManagedInstance[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.ManagedInstance) => { + 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.listManagedInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listManagedInstances, request)); + assert( + (client.descriptors.page.listManagedInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listManagedInstancesStream with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listManagedInstances.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listManagedInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.ManagedInstance[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.ManagedInstance) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listManagedInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listManagedInstances, request)); + assert( + (client.descriptors.page.listManagedInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listManagedInstances without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.ManagedInstance()), + ]; + client.descriptors.page.listManagedInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IManagedInstance[] = []; + const iterable = client.listManagedInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listManagedInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listManagedInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listManagedInstances with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListManagedInstancesRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listManagedInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listManagedInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IManagedInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listManagedInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listManagedInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listPerInstanceConfigs', () => { + it('invokes listPerInstanceConfigs without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + ]; + client.innerApiCalls.listPerInstanceConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.listPerInstanceConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPerInstanceConfigs without error using callback', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + ]; + client.innerApiCalls.listPerInstanceConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPerInstanceConfigs( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPerInstanceConfig[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPerInstanceConfigs with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPerInstanceConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listPerInstanceConfigs(request), expectedError); + const actualRequest = (client.innerApiCalls.listPerInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPerInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPerInstanceConfigsStream without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + ]; + client.descriptors.page.listPerInstanceConfigs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listPerInstanceConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.PerInstanceConfig[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.PerInstanceConfig) => { + 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.listPerInstanceConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPerInstanceConfigs, request)); + assert( + (client.descriptors.page.listPerInstanceConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listPerInstanceConfigsStream with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPerInstanceConfigs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listPerInstanceConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.PerInstanceConfig[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.PerInstanceConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listPerInstanceConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPerInstanceConfigs, request)); + assert( + (client.descriptors.page.listPerInstanceConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPerInstanceConfigs without error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + generateSampleMessage(new protos.google.cloud.compute.v1.PerInstanceConfig()), + ]; + client.descriptors.page.listPerInstanceConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IPerInstanceConfig[] = []; + const iterable = client.listPerInstanceConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listPerInstanceConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPerInstanceConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPerInstanceConfigs with error', async () => { + const client = new regioninstancegroupmanagersModule.v1.RegionInstanceGroupManagersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPerInstanceConfigsRegionInstanceGroupManagersRequest', ['instanceGroupManager']); + request.instanceGroupManager = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group_manager=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPerInstanceConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPerInstanceConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IPerInstanceConfig[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listPerInstanceConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPerInstanceConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_instance_groups_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_instance_groups_v1.ts new file mode 100644 index 00000000000..3e0fd29becb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_instance_groups_v1.ts @@ -0,0 +1,1025 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regioninstancegroupsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionInstanceGroupsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regioninstancegroupsModule.v1.RegionInstanceGroupsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regioninstancegroupsModule.v1.RegionInstanceGroupsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regioninstancegroupsModule.v1.RegionInstanceGroupsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionInstanceGroupsStub, undefined); + await client.initialize(); + assert(client.regionInstanceGroupsStub); + }); + + it('has close method for the initialized client', done => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionInstanceGroupsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionInstanceGroupsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + auth: googleAuth, + 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 regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + auth: googleAuth, + 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('get', () => { + it('invokes get without error', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InstanceGroup() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InstanceGroup() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstanceGroup|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('setNamedPorts', () => { + it('invokes setNamedPorts without error', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetNamedPortsRegionInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsRegionInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsRegionInstanceGroupRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsRegionInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setNamedPorts = stubSimpleCall(expectedResponse); + const [response] = await client.setNamedPorts(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setNamedPorts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setNamedPorts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setNamedPorts without error using callback', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetNamedPortsRegionInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsRegionInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsRegionInstanceGroupRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsRegionInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setNamedPorts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setNamedPorts( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setNamedPorts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setNamedPorts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setNamedPorts with error', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetNamedPortsRegionInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsRegionInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsRegionInstanceGroupRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsRegionInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setNamedPorts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setNamedPorts(request), expectedError); + const actualRequest = (client.innerApiCalls.setNamedPorts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setNamedPorts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setNamedPorts with closed client', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetNamedPortsRegionInstanceGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsRegionInstanceGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsRegionInstanceGroupRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetNamedPortsRegionInstanceGroupRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setNamedPorts(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstanceGroup[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceGroup[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceGroup) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceGroup[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceGroup) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceGroup()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IInstanceGroup[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceGroupsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IInstanceGroup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + ]; + 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 regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + ]; + client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstanceWithNamedPorts[]|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 regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group=${defaultValue3}`; + 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 regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + ]; + client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceWithNamedPorts[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceWithNamedPorts) => { + 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 regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group=${defaultValue3}`; + 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.compute.v1.InstanceWithNamedPorts[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceWithNamedPorts) => { + 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 regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceWithNamedPorts()), + ]; + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IInstanceWithNamedPorts[] = []; + 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 regioninstancegroupsModule.v1.RegionInstanceGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ListInstancesRegionInstanceGroupsRequest', ['instanceGroup']); + request.instanceGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_group=${defaultValue3}`; + 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.compute.v1.IInstanceWithNamedPorts[] = []; + 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 + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_instance_templates_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_instance_templates_v1.ts new file mode 100644 index 00000000000..b990cea38f2 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_instance_templates_v1.ts @@ -0,0 +1,858 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regioninstancetemplatesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionInstanceTemplatesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionInstanceTemplatesStub, undefined); + await client.initialize(); + assert(client.regionInstanceTemplatesStub); + }); + + it('has close method for the initialized client', done => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionInstanceTemplatesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionInstanceTemplatesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + 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 regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceTemplateRequest', ['instanceTemplate']); + request.instanceTemplate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_template=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceTemplateRequest', ['instanceTemplate']); + request.instanceTemplate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_template=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceTemplateRequest', ['instanceTemplate']); + request.instanceTemplate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_template=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionInstanceTemplateRequest', ['instanceTemplate']); + request.instanceTemplate = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceTemplateRequest', ['instanceTemplate']); + request.instanceTemplate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_template=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InstanceTemplate() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceTemplateRequest', ['instanceTemplate']); + request.instanceTemplate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_template=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.InstanceTemplate() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstanceTemplate|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceTemplateRequest', ['instanceTemplate']); + request.instanceTemplate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&instance_template=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceTemplateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionInstanceTemplateRequest', ['instanceTemplate']); + request.instanceTemplate = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionInstanceTemplateRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionInstanceTemplateRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionInstanceTemplateRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionInstanceTemplateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionInstanceTemplateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionInstanceTemplateRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IInstanceTemplate[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceTemplate[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceTemplate) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.InstanceTemplate[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.InstanceTemplate) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + generateSampleMessage(new protos.google.cloud.compute.v1.InstanceTemplate()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IInstanceTemplate[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regioninstancetemplatesModule.v1.RegionInstanceTemplatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionInstanceTemplatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IInstanceTemplate[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_instances_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_instances_v1.ts new file mode 100644 index 00000000000..0af975e8f0c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_instances_v1.ts @@ -0,0 +1,281 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regioninstancesModule from '../src'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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); +} + +describe('v1.RegionInstancesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regioninstancesModule.v1.RegionInstancesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regioninstancesModule.v1.RegionInstancesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regioninstancesModule.v1.RegionInstancesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regioninstancesModule.v1.RegionInstancesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regioninstancesModule.v1.RegionInstancesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regioninstancesModule.v1.RegionInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionInstancesStub, undefined); + await client.initialize(); + assert(client.regionInstancesStub); + }); + + it('has close method for the initialized client', done => { + const client = new regioninstancesModule.v1.RegionInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionInstancesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regioninstancesModule.v1.RegionInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionInstancesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regioninstancesModule.v1.RegionInstancesClient({ + auth: googleAuth, + 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 regioninstancesModule.v1.RegionInstancesClient({ + auth: googleAuth, + 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('bulkInsert', () => { + it('invokes bulkInsert without error', async () => { + const client = new regioninstancesModule.v1.RegionInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.BulkInsertRegionInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.BulkInsertRegionInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.BulkInsertRegionInstanceRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.bulkInsert = stubSimpleCall(expectedResponse); + const [response] = await client.bulkInsert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.bulkInsert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.bulkInsert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes bulkInsert without error using callback', async () => { + const client = new regioninstancesModule.v1.RegionInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.BulkInsertRegionInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.BulkInsertRegionInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.BulkInsertRegionInstanceRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.bulkInsert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.bulkInsert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.bulkInsert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.bulkInsert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes bulkInsert with error', async () => { + const client = new regioninstancesModule.v1.RegionInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.BulkInsertRegionInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.BulkInsertRegionInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.BulkInsertRegionInstanceRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.bulkInsert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.bulkInsert(request), expectedError); + const actualRequest = (client.innerApiCalls.bulkInsert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.bulkInsert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes bulkInsert with closed client', async () => { + const client = new regioninstancesModule.v1.RegionInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.BulkInsertRegionInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.BulkInsertRegionInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.BulkInsertRegionInstanceRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.bulkInsert(request), expectedError); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_network_endpoint_groups_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_network_endpoint_groups_v1.ts new file mode 100644 index 00000000000..fefea2345f4 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_network_endpoint_groups_v1.ts @@ -0,0 +1,858 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regionnetworkendpointgroupsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionNetworkEndpointGroupsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionNetworkEndpointGroupsStub, undefined); + await client.initialize(); + assert(client.regionNetworkEndpointGroupsStub); + }); + + it('has close method for the initialized client', done => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionNetworkEndpointGroupsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionNetworkEndpointGroupsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + 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 regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkEndpointGroupRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkEndpointGroupRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkEndpointGroupRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkEndpointGroupRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkEndpointGroupRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NetworkEndpointGroup() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkEndpointGroupRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NetworkEndpointGroup() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INetworkEndpointGroup|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkEndpointGroupRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&network_endpoint_group=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkEndpointGroupRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkEndpointGroupRequest', ['networkEndpointGroup']); + request.networkEndpointGroup = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNetworkEndpointGroupRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNetworkEndpointGroupRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNetworkEndpointGroupRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionNetworkEndpointGroupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNetworkEndpointGroupRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNetworkEndpointGroupRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INetworkEndpointGroup[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NetworkEndpointGroup[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NetworkEndpointGroup) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NetworkEndpointGroup[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NetworkEndpointGroup) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + generateSampleMessage(new protos.google.cloud.compute.v1.NetworkEndpointGroup()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.INetworkEndpointGroup[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regionnetworkendpointgroupsModule.v1.RegionNetworkEndpointGroupsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkEndpointGroupsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.INetworkEndpointGroup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_network_firewall_policies_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_network_firewall_policies_v1.ts new file mode 100644 index 00000000000..973aac52796 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_network_firewall_policies_v1.ts @@ -0,0 +1,2562 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regionnetworkfirewallpoliciesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionNetworkFirewallPoliciesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionNetworkFirewallPoliciesStub, undefined); + await client.initialize(); + assert(client.regionNetworkFirewallPoliciesStub); + }); + + it('has close method for the initialized client', done => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionNetworkFirewallPoliciesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionNetworkFirewallPoliciesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + 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 regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + 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('addAssociation', () => { + it('invokes addAssociation without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddAssociationRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addAssociation = stubSimpleCall(expectedResponse); + const [response] = await client.addAssociation(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addAssociation without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddAssociationRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addAssociation = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addAssociation( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addAssociation with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddAssociationRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addAssociation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addAssociation(request), expectedError); + const actualRequest = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addAssociation with closed client', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddAssociationRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddAssociationRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addAssociation(request), expectedError); + }); + }); + + describe('addRule', () => { + it('invokes addRule without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddRuleRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addRule = stubSimpleCall(expectedResponse); + const [response] = await client.addRule(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addRule without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddRuleRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addRule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addRule( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addRule with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddRuleRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addRule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addRule(request), expectedError); + const actualRequest = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addRule with closed client', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddRuleRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addRule(request), expectedError); + }); + }); + + describe('cloneRules', () => { + it('invokes cloneRules without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CloneRulesRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.cloneRules = stubSimpleCall(expectedResponse); + const [response] = await client.cloneRules(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cloneRules without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CloneRulesRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.cloneRules = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.cloneRules( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cloneRules with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CloneRulesRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.cloneRules = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.cloneRules(request), expectedError); + const actualRequest = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.cloneRules as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cloneRules with closed client', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.CloneRulesRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.CloneRulesRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.cloneRules(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicy() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicy() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IFirewallPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getAssociation', () => { + it('invokes getAssociation without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAssociationRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicyAssociation() + ); + client.innerApiCalls.getAssociation = stubSimpleCall(expectedResponse); + const [response] = await client.getAssociation(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAssociation without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAssociationRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicyAssociation() + ); + client.innerApiCalls.getAssociation = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAssociation( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IFirewallPolicyAssociation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAssociation with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAssociationRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAssociation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAssociation(request), expectedError); + const actualRequest = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAssociation with closed client', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetAssociationRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetAssociationRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getAssociation(request), expectedError); + }); + }); + + describe('getEffectiveFirewalls', () => { + it('invokes getEffectiveFirewalls without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse() + ); + client.innerApiCalls.getEffectiveFirewalls = stubSimpleCall(expectedResponse); + const [response] = await client.getEffectiveFirewalls(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEffectiveFirewalls without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse() + ); + client.innerApiCalls.getEffectiveFirewalls = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEffectiveFirewalls( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IRegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEffectiveFirewalls with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEffectiveFirewalls = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getEffectiveFirewalls(request), expectedError); + const actualRequest = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEffectiveFirewalls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEffectiveFirewalls with closed client', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getEffectiveFirewalls(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyRegionNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('getRule', () => { + it('invokes getRule without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRuleRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicyRule() + ); + client.innerApiCalls.getRule = stubSimpleCall(expectedResponse); + const [response] = await client.getRule(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRule without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRuleRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.FirewallPolicyRule() + ); + client.innerApiCalls.getRule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRule( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IFirewallPolicyRule|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRule with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRuleRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRule(request), expectedError); + const actualRequest = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRule with closed client', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRuleRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getRule(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('patchRule', () => { + it('invokes patchRule without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRuleRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patchRule = stubSimpleCall(expectedResponse); + const [response] = await client.patchRule(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchRule without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRuleRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patchRule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patchRule( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchRule with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRuleRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patchRule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patchRule(request), expectedError); + const actualRequest = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchRule with closed client', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRuleRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patchRule(request), expectedError); + }); + }); + + describe('removeAssociation', () => { + it('invokes removeAssociation without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveAssociationRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeAssociation = stubSimpleCall(expectedResponse); + const [response] = await client.removeAssociation(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeAssociation without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveAssociationRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeAssociation = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeAssociation( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeAssociation with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveAssociationRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeAssociation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeAssociation(request), expectedError); + const actualRequest = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeAssociation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeAssociation with closed client', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveAssociationRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveAssociationRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeAssociation(request), expectedError); + }); + }); + + describe('removeRule', () => { + it('invokes removeRule without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveRuleRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeRule = stubSimpleCall(expectedResponse); + const [response] = await client.removeRule(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeRule without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveRuleRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeRule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeRule( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeRule with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveRuleRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&firewall_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeRule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeRule(request), expectedError); + const actualRequest = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeRule with closed client', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveRuleRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleRegionNetworkFirewallPolicyRequest', ['firewallPolicy']); + request.firewallPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeRule(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyRegionNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsRegionNetworkFirewallPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionNetworkFirewallPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionNetworkFirewallPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsRegionNetworkFirewallPolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IFirewallPolicy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.FirewallPolicy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.FirewallPolicy) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.FirewallPolicy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.FirewallPolicy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.FirewallPolicy()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IFirewallPolicy[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regionnetworkfirewallpoliciesModule.v1.RegionNetworkFirewallPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNetworkFirewallPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IFirewallPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_notification_endpoints_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_notification_endpoints_v1.ts new file mode 100644 index 00000000000..4b63aff1705 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_notification_endpoints_v1.ts @@ -0,0 +1,858 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regionnotificationendpointsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionNotificationEndpointsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionNotificationEndpointsStub, undefined); + await client.initialize(); + assert(client.regionNotificationEndpointsStub); + }); + + it('has close method for the initialized client', done => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionNotificationEndpointsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionNotificationEndpointsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + 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 regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionNotificationEndpointRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNotificationEndpointRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNotificationEndpointRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNotificationEndpointRequest', ['notificationEndpoint']); + request.notificationEndpoint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}¬ification_endpoint=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionNotificationEndpointRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNotificationEndpointRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNotificationEndpointRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNotificationEndpointRequest', ['notificationEndpoint']); + request.notificationEndpoint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}¬ification_endpoint=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionNotificationEndpointRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNotificationEndpointRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNotificationEndpointRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNotificationEndpointRequest', ['notificationEndpoint']); + request.notificationEndpoint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}¬ification_endpoint=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionNotificationEndpointRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNotificationEndpointRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNotificationEndpointRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionNotificationEndpointRequest', ['notificationEndpoint']); + request.notificationEndpoint = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionNotificationEndpointRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNotificationEndpointRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNotificationEndpointRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNotificationEndpointRequest', ['notificationEndpoint']); + request.notificationEndpoint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}¬ification_endpoint=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NotificationEndpoint() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionNotificationEndpointRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNotificationEndpointRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNotificationEndpointRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNotificationEndpointRequest', ['notificationEndpoint']); + request.notificationEndpoint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}¬ification_endpoint=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.NotificationEndpoint() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INotificationEndpoint|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionNotificationEndpointRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNotificationEndpointRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNotificationEndpointRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNotificationEndpointRequest', ['notificationEndpoint']); + request.notificationEndpoint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}¬ification_endpoint=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionNotificationEndpointRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNotificationEndpointRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNotificationEndpointRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionNotificationEndpointRequest', ['notificationEndpoint']); + request.notificationEndpoint = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionNotificationEndpointRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNotificationEndpointRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNotificationEndpointRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionNotificationEndpointRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNotificationEndpointRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNotificationEndpointRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionNotificationEndpointRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNotificationEndpointRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNotificationEndpointRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionNotificationEndpointRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNotificationEndpointRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionNotificationEndpointRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NotificationEndpoint()), + generateSampleMessage(new protos.google.cloud.compute.v1.NotificationEndpoint()), + generateSampleMessage(new protos.google.cloud.compute.v1.NotificationEndpoint()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NotificationEndpoint()), + generateSampleMessage(new protos.google.cloud.compute.v1.NotificationEndpoint()), + generateSampleMessage(new protos.google.cloud.compute.v1.NotificationEndpoint()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.INotificationEndpoint[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NotificationEndpoint()), + generateSampleMessage(new protos.google.cloud.compute.v1.NotificationEndpoint()), + generateSampleMessage(new protos.google.cloud.compute.v1.NotificationEndpoint()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NotificationEndpoint[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NotificationEndpoint) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.NotificationEndpoint[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.NotificationEndpoint) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.NotificationEndpoint()), + generateSampleMessage(new protos.google.cloud.compute.v1.NotificationEndpoint()), + generateSampleMessage(new protos.google.cloud.compute.v1.NotificationEndpoint()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.INotificationEndpoint[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regionnotificationendpointsModule.v1.RegionNotificationEndpointsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionNotificationEndpointsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.INotificationEndpoint[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_operations_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_operations_v1.ts new file mode 100644 index 00000000000..cb852df247e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_operations_v1.ts @@ -0,0 +1,870 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regionoperationsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionOperationsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regionoperationsModule.v1.RegionOperationsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regionoperationsModule.v1.RegionOperationsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regionoperationsModule.v1.RegionOperationsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regionoperationsModule.v1.RegionOperationsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionOperationsStub, undefined); + await client.initialize(); + assert(client.regionOperationsStub); + }); + + it('has close method for the initialized client', done => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionOperationsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionOperationsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + 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 regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&operation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionOperationResponse() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&operation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionOperationResponse() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IDeleteRegionOperationResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&operation=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&operation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&operation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&operation=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('wait', () => { + it('invokes wait without error', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.WaitRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&operation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.wait = stubSimpleCall(expectedResponse); + const [response] = await client.wait(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes wait without error using callback', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.WaitRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&operation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.wait = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.wait( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes wait with error', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.WaitRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&operation=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.wait = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.wait(request), expectedError); + const actualRequest = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes wait with closed client', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.WaitRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.wait(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionOperationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionOperationsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionOperationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionOperationsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionOperationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionOperationsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionOperationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionOperationsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Operation[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Operation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionOperationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionOperationsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Operation[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Operation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionOperationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionOperationsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IOperation[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regionoperationsModule.v1.RegionOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionOperationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionOperationsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_security_policies_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_security_policies_v1.ts new file mode 100644 index 00000000000..88975231c60 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_security_policies_v1.ts @@ -0,0 +1,990 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regionsecuritypoliciesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionSecurityPoliciesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionSecurityPoliciesStub, undefined); + await client.initialize(); + assert(client.regionSecurityPoliciesStub); + }); + + it('has close method for the initialized client', done => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionSecurityPoliciesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionSecurityPoliciesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + 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 regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSecurityPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&security_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSecurityPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&security_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSecurityPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&security_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSecurityPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSecurityPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&security_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SecurityPolicy() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSecurityPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&security_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SecurityPolicy() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISecurityPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSecurityPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&security_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSecurityPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSecurityPolicyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSecurityPolicyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSecurityPolicyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSecurityPolicyRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSecurityPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&security_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSecurityPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&security_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSecurityPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&security_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSecurityPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISecurityPolicy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.SecurityPolicy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.SecurityPolicy) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.SecurityPolicy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.SecurityPolicy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ISecurityPolicy[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regionsecuritypoliciesModule.v1.RegionSecurityPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSecurityPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ISecurityPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_ssl_certificates_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_ssl_certificates_v1.ts new file mode 100644 index 00000000000..18bce488f8f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_ssl_certificates_v1.ts @@ -0,0 +1,858 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regionsslcertificatesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionSslCertificatesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regionsslcertificatesModule.v1.RegionSslCertificatesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regionsslcertificatesModule.v1.RegionSslCertificatesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regionsslcertificatesModule.v1.RegionSslCertificatesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionSslCertificatesStub, undefined); + await client.initialize(); + assert(client.regionSslCertificatesStub); + }); + + it('has close method for the initialized client', done => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionSslCertificatesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionSslCertificatesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + 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 regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslCertificateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslCertificateRequest', ['sslCertificate']); + request.sslCertificate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&ssl_certificate=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslCertificateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslCertificateRequest', ['sslCertificate']); + request.sslCertificate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&ssl_certificate=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslCertificateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslCertificateRequest', ['sslCertificate']); + request.sslCertificate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&ssl_certificate=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslCertificateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslCertificateRequest', ['sslCertificate']); + request.sslCertificate = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslCertificateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslCertificateRequest', ['sslCertificate']); + request.sslCertificate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&ssl_certificate=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SslCertificate() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslCertificateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslCertificateRequest', ['sslCertificate']); + request.sslCertificate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&ssl_certificate=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SslCertificate() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISslCertificate|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslCertificateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslCertificateRequest', ['sslCertificate']); + request.sslCertificate = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&ssl_certificate=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslCertificateRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslCertificateRequest', ['sslCertificate']); + request.sslCertificate = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSslCertificateRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSslCertificateRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSslCertificateRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSslCertificateRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSslCertificatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslCertificatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslCertificatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSslCertificatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslCertificatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslCertificatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISslCertificate[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSslCertificatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslCertificatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslCertificatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSslCertificatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslCertificatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslCertificatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.SslCertificate[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.SslCertificate) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSslCertificatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslCertificatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslCertificatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.SslCertificate[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.SslCertificate) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSslCertificatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslCertificatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslCertificatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ISslCertificate[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regionsslcertificatesModule.v1.RegionSslCertificatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSslCertificatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslCertificatesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslCertificatesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ISslCertificate[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_ssl_policies_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_ssl_policies_v1.ts new file mode 100644 index 00000000000..57ce0c8f2e3 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_ssl_policies_v1.ts @@ -0,0 +1,1110 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regionsslpoliciesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionSslPoliciesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regionsslpoliciesModule.v1.RegionSslPoliciesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regionsslpoliciesModule.v1.RegionSslPoliciesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regionsslpoliciesModule.v1.RegionSslPoliciesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionSslPoliciesStub, undefined); + await client.initialize(); + assert(client.regionSslPoliciesStub); + }); + + it('has close method for the initialized client', done => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionSslPoliciesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionSslPoliciesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + 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 regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&ssl_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&ssl_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&ssl_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&ssl_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SslPolicy() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&ssl_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SslPolicy() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISslPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&ssl_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSslPolicyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSslPolicyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSslPolicyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionSslPolicyRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('listAvailableFeatures', () => { + it('invokes listAvailableFeatures without error', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAvailableFeaturesRegionSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAvailableFeaturesRegionSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAvailableFeaturesRegionSslPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SslPoliciesListAvailableFeaturesResponse() + ); + client.innerApiCalls.listAvailableFeatures = stubSimpleCall(expectedResponse); + const [response] = await client.listAvailableFeatures(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listAvailableFeatures as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAvailableFeatures as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAvailableFeatures without error using callback', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAvailableFeaturesRegionSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAvailableFeaturesRegionSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAvailableFeaturesRegionSslPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SslPoliciesListAvailableFeaturesResponse() + ); + client.innerApiCalls.listAvailableFeatures = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAvailableFeatures( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISslPoliciesListAvailableFeaturesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listAvailableFeatures as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAvailableFeatures as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAvailableFeatures with error', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAvailableFeaturesRegionSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAvailableFeaturesRegionSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAvailableFeaturesRegionSslPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAvailableFeatures = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listAvailableFeatures(request), expectedError); + const actualRequest = (client.innerApiCalls.listAvailableFeatures as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAvailableFeatures as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAvailableFeatures with closed client', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAvailableFeaturesRegionSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAvailableFeaturesRegionSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAvailableFeaturesRegionSslPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.listAvailableFeatures(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSslPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&ssl_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSslPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&ssl_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSslPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&ssl_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSslPolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISslPolicy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.SslPolicy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.SslPolicy) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.SslPolicy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.SslPolicy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ISslPolicy[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regionsslpoliciesModule.v1.RegionSslPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionSslPoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ISslPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_target_http_proxies_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_target_http_proxies_v1.ts new file mode 100644 index 00000000000..0efbc47b14d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_target_http_proxies_v1.ts @@ -0,0 +1,990 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regiontargethttpproxiesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionTargetHttpProxiesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionTargetHttpProxiesStub, undefined); + await client.initialize(); + assert(client.regionTargetHttpProxiesStub); + }); + + it('has close method for the initialized client', done => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionTargetHttpProxiesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionTargetHttpProxiesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + 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 regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_http_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_http_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_http_proxy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_http_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetHttpProxy() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_http_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetHttpProxy() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetHttpProxy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_http_proxy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetHttpProxyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetHttpProxyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetHttpProxyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetHttpProxyRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('setUrlMap', () => { + it('invokes setUrlMap without error', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUrlMapRegionTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_http_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setUrlMap = stubSimpleCall(expectedResponse); + const [response] = await client.setUrlMap(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setUrlMap without error using callback', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUrlMapRegionTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_http_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setUrlMap = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setUrlMap( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setUrlMap with error', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUrlMapRegionTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_http_proxy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setUrlMap = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setUrlMap(request), expectedError); + const actualRequest = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setUrlMap with closed client', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUrlMapRegionTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setUrlMap(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetHttpProxy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetHttpProxy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetHttpProxy) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetHttpProxy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetHttpProxy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ITargetHttpProxy[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regiontargethttpproxiesModule.v1.RegionTargetHttpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ITargetHttpProxy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_target_https_proxies_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_target_https_proxies_v1.ts new file mode 100644 index 00000000000..64706aa2829 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_target_https_proxies_v1.ts @@ -0,0 +1,1254 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regiontargethttpsproxiesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionTargetHttpsProxiesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionTargetHttpsProxiesStub, undefined); + await client.initialize(); + assert(client.regionTargetHttpsProxiesStub); + }); + + it('has close method for the initialized client', done => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionTargetHttpsProxiesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionTargetHttpsProxiesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + 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 regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_https_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_https_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_https_proxy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_https_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetHttpsProxy() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_https_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetHttpsProxy() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetHttpsProxy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_https_proxy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_https_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_https_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_https_proxy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('setSslCertificates', () => { + it('invokes setSslCertificates without error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslCertificatesRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_https_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setSslCertificates = stubSimpleCall(expectedResponse); + const [response] = await client.setSslCertificates(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSslCertificates without error using callback', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslCertificatesRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_https_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setSslCertificates = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setSslCertificates( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSslCertificates with error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslCertificatesRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_https_proxy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setSslCertificates = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setSslCertificates(request), expectedError); + const actualRequest = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSslCertificates with closed client', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslCertificatesRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setSslCertificates(request), expectedError); + }); + }); + + describe('setUrlMap', () => { + it('invokes setUrlMap without error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUrlMapRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_https_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setUrlMap = stubSimpleCall(expectedResponse); + const [response] = await client.setUrlMap(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setUrlMap without error using callback', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUrlMapRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_https_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setUrlMap = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setUrlMap( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setUrlMap with error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUrlMapRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_https_proxy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setUrlMap = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setUrlMap(request), expectedError); + const actualRequest = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setUrlMap with closed client', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUrlMapRegionTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpsProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapRegionTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setUrlMap(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetHttpsProxy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetHttpsProxy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetHttpsProxy) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetHttpsProxy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetHttpsProxy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ITargetHttpsProxy[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regiontargethttpsproxiesModule.v1.RegionTargetHttpsProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetHttpsProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ITargetHttpsProxy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_target_tcp_proxies_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_target_tcp_proxies_v1.ts new file mode 100644 index 00000000000..fd083b8bc99 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_target_tcp_proxies_v1.ts @@ -0,0 +1,858 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regiontargettcpproxiesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionTargetTcpProxiesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionTargetTcpProxiesStub, undefined); + await client.initialize(); + assert(client.regionTargetTcpProxiesStub); + }); + + it('has close method for the initialized client', done => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionTargetTcpProxiesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionTargetTcpProxiesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + 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 regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetTcpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_tcp_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetTcpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_tcp_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetTcpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_tcp_proxy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetTcpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetTcpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_tcp_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetTcpProxy() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetTcpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_tcp_proxy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetTcpProxy() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetTcpProxy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetTcpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_tcp_proxy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetTcpProxyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetTcpProxyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetTcpProxyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetTcpProxyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionTargetTcpProxyRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetTcpProxy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetTcpProxy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetTcpProxy) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetTcpProxy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetTcpProxy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ITargetTcpProxy[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regiontargettcpproxiesModule.v1.RegionTargetTcpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionTargetTcpProxiesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ITargetTcpProxy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_url_maps_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_url_maps_v1.ts new file mode 100644 index 00000000000..f5b3f58cb52 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_region_url_maps_v1.ts @@ -0,0 +1,1254 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regionurlmapsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionUrlMapsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regionurlmapsModule.v1.RegionUrlMapsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regionurlmapsModule.v1.RegionUrlMapsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regionurlmapsModule.v1.RegionUrlMapsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionUrlMapsStub, undefined); + await client.initialize(); + assert(client.regionUrlMapsStub); + }); + + it('has close method for the initialized client', done => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionUrlMapsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionUrlMapsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + 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 regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&url_map=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&url_map=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&url_map=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&url_map=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.UrlMap() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&url_map=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.UrlMap() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IUrlMap|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&url_map=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&url_map=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&url_map=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&url_map=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&url_map=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&url_map=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&url_map=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('validate', () => { + it('invokes validate without error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ValidateRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&url_map=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.UrlMapsValidateResponse() + ); + client.innerApiCalls.validate = stubSimpleCall(expectedResponse); + const [response] = await client.validate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.validate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.validate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes validate without error using callback', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ValidateRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&url_map=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.UrlMapsValidateResponse() + ); + client.innerApiCalls.validate = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.validate( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IUrlMapsValidateResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.validate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.validate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes validate with error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ValidateRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&url_map=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.validate = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.validate(request), expectedError); + const actualRequest = (client.innerApiCalls.validate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.validate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes validate with closed client', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ValidateRegionUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateRegionUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateRegionUrlMapRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateRegionUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.validate(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionUrlMapsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionUrlMapsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionUrlMapsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionUrlMapsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionUrlMapsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionUrlMapsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IUrlMap[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionUrlMapsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionUrlMapsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionUrlMapsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionUrlMapsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionUrlMapsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionUrlMapsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.UrlMap[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.UrlMap) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionUrlMapsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionUrlMapsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionUrlMapsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.UrlMap[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.UrlMap) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionUrlMapsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionUrlMapsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionUrlMapsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IUrlMap[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regionurlmapsModule.v1.RegionUrlMapsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionUrlMapsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionUrlMapsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionUrlMapsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IUrlMap[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_regions_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_regions_v1.ts new file mode 100644 index 00000000000..1aeb95e721f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_regions_v1.ts @@ -0,0 +1,573 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regionsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RegionsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regionsModule.v1.RegionsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regionsModule.v1.RegionsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regionsModule.v1.RegionsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regionsModule.v1.RegionsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regionsModule.v1.RegionsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regionsModule.v1.RegionsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionsStub, undefined); + await client.initialize(); + assert(client.regionsStub); + }); + + it('has close method for the initialized client', done => { + const client = new regionsModule.v1.RegionsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regionsModule.v1.RegionsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regionsModule.v1.RegionsClient({ + auth: googleAuth, + 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 regionsModule.v1.RegionsClient({ + auth: googleAuth, + 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('get', () => { + it('invokes get without error', async () => { + const client = new regionsModule.v1.RegionsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Region() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regionsModule.v1.RegionsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Region() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IRegion|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regionsModule.v1.RegionsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regionsModule.v1.RegionsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRegionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRegionRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new regionsModule.v1.RegionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Region()), + generateSampleMessage(new protos.google.cloud.compute.v1.Region()), + generateSampleMessage(new protos.google.cloud.compute.v1.Region()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new regionsModule.v1.RegionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Region()), + generateSampleMessage(new protos.google.cloud.compute.v1.Region()), + generateSampleMessage(new protos.google.cloud.compute.v1.Region()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IRegion[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new regionsModule.v1.RegionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new regionsModule.v1.RegionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Region()), + generateSampleMessage(new protos.google.cloud.compute.v1.Region()), + generateSampleMessage(new protos.google.cloud.compute.v1.Region()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Region[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Region) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new regionsModule.v1.RegionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Region[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Region) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new regionsModule.v1.RegionsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Region()), + generateSampleMessage(new protos.google.cloud.compute.v1.Region()), + generateSampleMessage(new protos.google.cloud.compute.v1.Region()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IRegion[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new regionsModule.v1.RegionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRegionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRegionsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IRegion[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_reservations_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_reservations_v1.ts new file mode 100644 index 00000000000..479e83c417f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_reservations_v1.ts @@ -0,0 +1,1590 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as reservationsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.ReservationsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = reservationsModule.v1.ReservationsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = reservationsModule.v1.ReservationsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = reservationsModule.v1.ReservationsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new reservationsModule.v1.ReservationsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new reservationsModule.v1.ReservationsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.reservationsStub, undefined); + await client.initialize(); + assert(client.reservationsStub); + }); + + it('has close method for the initialized client', done => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.reservationsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.reservationsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + 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 reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteReservationRequest', ['reservation']); + request.reservation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&reservation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteReservationRequest', ['reservation']); + request.reservation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&reservation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteReservationRequest', ['reservation']); + request.reservation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&reservation=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteReservationRequest', ['reservation']); + request.reservation = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetReservationRequest', ['reservation']); + request.reservation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&reservation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Reservation() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetReservationRequest', ['reservation']); + request.reservation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&reservation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Reservation() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IReservation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetReservationRequest', ['reservation']); + request.reservation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&reservation=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetReservationRequest', ['reservation']); + request.reservation = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyReservationRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyReservationRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyReservationRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyReservationRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertReservationRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertReservationRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertReservationRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertReservationRequest', ['zone']); + request.zone = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('resize', () => { + it('invokes resize without error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeReservationRequest', ['reservation']); + request.reservation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&reservation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.resize = stubSimpleCall(expectedResponse); + const [response] = await client.resize(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resize without error using callback', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeReservationRequest', ['reservation']); + request.reservation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&reservation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.resize = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resize( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resize with error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeReservationRequest', ['reservation']); + request.reservation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&reservation=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resize = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.resize(request), expectedError); + const actualRequest = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resize as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resize with closed client', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ResizeReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ResizeReservationRequest', ['reservation']); + request.reservation = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resize(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyReservationRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyReservationRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyReservationRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyReservationRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsReservationRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsReservationRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsReservationRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsReservationRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateReservationRequest', ['reservation']); + request.reservation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&reservation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateReservationRequest', ['reservation']); + request.reservation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&reservation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateReservationRequest', ['reservation']); + request.reservation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&reservation=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateReservationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateReservationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateReservationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateReservationRequest', ['reservation']); + request.reservation = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListReservationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListReservationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.ReservationsScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.ReservationsScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.ReservationsScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IReservationsScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListReservationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListReservationsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IReservationsScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListReservationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReservationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReservationsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Reservation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Reservation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Reservation()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListReservationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReservationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReservationsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Reservation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Reservation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Reservation()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IReservation[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListReservationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReservationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReservationsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListReservationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReservationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReservationsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Reservation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Reservation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Reservation()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Reservation[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Reservation) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListReservationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReservationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReservationsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Reservation[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Reservation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListReservationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReservationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReservationsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Reservation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Reservation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Reservation()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IReservation[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new reservationsModule.v1.ReservationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListReservationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReservationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListReservationsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IReservation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_resource_policies_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_resource_policies_v1.ts new file mode 100644 index 00000000000..90be0e80946 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_resource_policies_v1.ts @@ -0,0 +1,1326 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as resourcepoliciesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.ResourcePoliciesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = resourcepoliciesModule.v1.ResourcePoliciesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = resourcepoliciesModule.v1.ResourcePoliciesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = resourcepoliciesModule.v1.ResourcePoliciesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.resourcePoliciesStub, undefined); + await client.initialize(); + assert(client.resourcePoliciesStub); + }); + + it('has close method for the initialized client', done => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.resourcePoliciesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.resourcePoliciesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + 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 resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteResourcePolicyRequest', ['resourcePolicy']); + request.resourcePolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteResourcePolicyRequest', ['resourcePolicy']); + request.resourcePolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteResourcePolicyRequest', ['resourcePolicy']); + request.resourcePolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteResourcePolicyRequest', ['resourcePolicy']); + request.resourcePolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetResourcePolicyRequest', ['resourcePolicy']); + request.resourcePolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.ResourcePolicy() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetResourcePolicyRequest', ['resourcePolicy']); + request.resourcePolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource_policy=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.ResourcePolicy() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IResourcePolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetResourcePolicyRequest', ['resourcePolicy']); + request.resourcePolicy = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource_policy=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetResourcePolicyRequest', ['resourcePolicy']); + request.resourcePolicy = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyResourcePolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyResourcePolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyResourcePolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyResourcePolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyResourcePolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyResourcePolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyResourcePolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyResourcePolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsResourcePolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsResourcePolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsResourcePolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsResourcePolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsResourcePolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsResourcePolicyRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsResourcePolicyRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListResourcePoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListResourcePoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.ResourcePoliciesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.ResourcePoliciesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.ResourcePoliciesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IResourcePoliciesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListResourcePoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListResourcePoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IResourcePoliciesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListResourcePoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListResourcePoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListResourcePoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ResourcePolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.ResourcePolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.ResourcePolicy()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListResourcePoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListResourcePoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListResourcePoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ResourcePolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.ResourcePolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.ResourcePolicy()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IResourcePolicy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListResourcePoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListResourcePoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListResourcePoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListResourcePoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListResourcePoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListResourcePoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ResourcePolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.ResourcePolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.ResourcePolicy()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.ResourcePolicy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.ResourcePolicy) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListResourcePoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListResourcePoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListResourcePoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.ResourcePolicy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.ResourcePolicy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListResourcePoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListResourcePoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListResourcePoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ResourcePolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.ResourcePolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.ResourcePolicy()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IResourcePolicy[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new resourcepoliciesModule.v1.ResourcePoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListResourcePoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListResourcePoliciesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListResourcePoliciesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IResourcePolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_routers_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_routers_v1.ts new file mode 100644 index 00000000000..d85e6e858a9 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_routers_v1.ts @@ -0,0 +1,1745 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as routersModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RoutersClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = routersModule.v1.RoutersClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = routersModule.v1.RoutersClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = routersModule.v1.RoutersClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new routersModule.v1.RoutersClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new routersModule.v1.RoutersClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.routersStub, undefined); + await client.initialize(); + assert(client.routersStub); + }); + + it('has close method for the initialized client', done => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.routersStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.routersStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + 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 routersModule.v1.RoutersClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouterRequest', ['router']); + request.router = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Router() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Router() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IRouter|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterRequest', ['router']); + request.router = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getRouterStatus', () => { + it('invokes getRouterStatus without error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRouterStatusRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterStatusRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterStatusRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterStatusRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.RouterStatusResponse() + ); + client.innerApiCalls.getRouterStatus = stubSimpleCall(expectedResponse); + const [response] = await client.getRouterStatus(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRouterStatus as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRouterStatus as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRouterStatus without error using callback', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRouterStatusRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterStatusRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterStatusRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterStatusRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.RouterStatusResponse() + ); + client.innerApiCalls.getRouterStatus = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRouterStatus( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IRouterStatusResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRouterStatus as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRouterStatus as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRouterStatus with error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRouterStatusRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterStatusRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterStatusRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterStatusRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRouterStatus = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRouterStatus(request), expectedError); + const actualRequest = (client.innerApiCalls.getRouterStatus as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRouterStatus as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRouterStatus with closed client', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRouterStatusRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterStatusRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterStatusRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouterStatusRouterRequest', ['router']); + request.router = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getRouterStatus(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRouterRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRouterRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRouterRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRouterRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRouterRequest', ['router']); + request.router = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('preview', () => { + it('invokes preview without error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PreviewRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PreviewRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PreviewRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PreviewRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.RoutersPreviewResponse() + ); + client.innerApiCalls.preview = stubSimpleCall(expectedResponse); + const [response] = await client.preview(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.preview as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.preview as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes preview without error using callback', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PreviewRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PreviewRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PreviewRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PreviewRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.RoutersPreviewResponse() + ); + client.innerApiCalls.preview = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.preview( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IRoutersPreviewResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.preview as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.preview as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes preview with error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PreviewRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PreviewRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PreviewRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PreviewRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.preview = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.preview(request), expectedError); + const actualRequest = (client.innerApiCalls.preview as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.preview as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes preview with closed client', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PreviewRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PreviewRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PreviewRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PreviewRouterRequest', ['router']); + request.router = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.preview(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRouterRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateRouterRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRouterRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRouterRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateRouterRequest', ['router']); + request.router = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListRoutersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListRoutersRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.RoutersScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.RoutersScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.RoutersScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IRoutersScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new routersModule.v1.RoutersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListRoutersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListRoutersRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IRoutersScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('getNatMappingInfo', () => { + it('invokes getNatMappingInfo without error', async () => { + const client = new routersModule.v1.RoutersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.VmEndpointNatMappings()), + generateSampleMessage(new protos.google.cloud.compute.v1.VmEndpointNatMappings()), + generateSampleMessage(new protos.google.cloud.compute.v1.VmEndpointNatMappings()), + ]; + client.innerApiCalls.getNatMappingInfo = stubSimpleCall(expectedResponse); + const [response] = await client.getNatMappingInfo(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getNatMappingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getNatMappingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getNatMappingInfo without error using callback', async () => { + const client = new routersModule.v1.RoutersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.VmEndpointNatMappings()), + generateSampleMessage(new protos.google.cloud.compute.v1.VmEndpointNatMappings()), + generateSampleMessage(new protos.google.cloud.compute.v1.VmEndpointNatMappings()), + ]; + client.innerApiCalls.getNatMappingInfo = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getNatMappingInfo( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IVmEndpointNatMappings[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getNatMappingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getNatMappingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getNatMappingInfo with error', async () => { + const client = new routersModule.v1.RoutersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getNatMappingInfo = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getNatMappingInfo(request), expectedError); + const actualRequest = (client.innerApiCalls.getNatMappingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getNatMappingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getNatMappingInfoStream without error', async () => { + const client = new routersModule.v1.RoutersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.VmEndpointNatMappings()), + generateSampleMessage(new protos.google.cloud.compute.v1.VmEndpointNatMappings()), + generateSampleMessage(new protos.google.cloud.compute.v1.VmEndpointNatMappings()), + ]; + client.descriptors.page.getNatMappingInfo.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.getNatMappingInfoStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.VmEndpointNatMappings[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.VmEndpointNatMappings) => { + 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.getNatMappingInfo.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.getNatMappingInfo, request)); + assert( + (client.descriptors.page.getNatMappingInfo.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes getNatMappingInfoStream with error', async () => { + const client = new routersModule.v1.RoutersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.getNatMappingInfo.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.getNatMappingInfoStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.VmEndpointNatMappings[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.VmEndpointNatMappings) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.getNatMappingInfo.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.getNatMappingInfo, request)); + assert( + (client.descriptors.page.getNatMappingInfo.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with getNatMappingInfo without error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.VmEndpointNatMappings()), + generateSampleMessage(new protos.google.cloud.compute.v1.VmEndpointNatMappings()), + generateSampleMessage(new protos.google.cloud.compute.v1.VmEndpointNatMappings()), + ]; + client.descriptors.page.getNatMappingInfo.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IVmEndpointNatMappings[] = []; + const iterable = client.getNatMappingInfoAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.getNatMappingInfo.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.getNatMappingInfo.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with getNatMappingInfo with error', async () => { + const client = new routersModule.v1.RoutersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetNatMappingInfoRoutersRequest', ['router']); + request.router = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&router=${defaultValue3}`; + const expectedError = new Error('expected'); + client.descriptors.page.getNatMappingInfo.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.getNatMappingInfoAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IVmEndpointNatMappings[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.getNatMappingInfo.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.getNatMappingInfo.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new routersModule.v1.RoutersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRoutersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Router()), + generateSampleMessage(new protos.google.cloud.compute.v1.Router()), + generateSampleMessage(new protos.google.cloud.compute.v1.Router()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new routersModule.v1.RoutersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRoutersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Router()), + generateSampleMessage(new protos.google.cloud.compute.v1.Router()), + generateSampleMessage(new protos.google.cloud.compute.v1.Router()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IRouter[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new routersModule.v1.RoutersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRoutersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new routersModule.v1.RoutersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRoutersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Router()), + generateSampleMessage(new protos.google.cloud.compute.v1.Router()), + generateSampleMessage(new protos.google.cloud.compute.v1.Router()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Router[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Router) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new routersModule.v1.RoutersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRoutersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Router[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Router) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new routersModule.v1.RoutersClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRoutersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Router()), + generateSampleMessage(new protos.google.cloud.compute.v1.Router()), + generateSampleMessage(new protos.google.cloud.compute.v1.Router()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IRouter[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new routersModule.v1.RoutersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRoutersRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutersRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutersRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IRouter[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_routes_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_routes_v1.ts new file mode 100644 index 00000000000..a1648a288fc --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_routes_v1.ts @@ -0,0 +1,801 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as routesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.RoutesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = routesModule.v1.RoutesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = routesModule.v1.RoutesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = routesModule.v1.RoutesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new routesModule.v1.RoutesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new routesModule.v1.RoutesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.routesStub, undefined); + await client.initialize(); + assert(client.routesStub); + }); + + it('has close method for the initialized client', done => { + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.routesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.routesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + 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 routesModule.v1.RoutesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRouteRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouteRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouteRequest', ['route']); + request.route = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&route=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRouteRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouteRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouteRequest', ['route']); + request.route = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&route=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRouteRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouteRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouteRequest', ['route']); + request.route = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&route=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteRouteRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouteRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteRouteRequest', ['route']); + request.route = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRouteRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouteRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouteRequest', ['route']); + request.route = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&route=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Route() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRouteRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouteRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouteRequest', ['route']); + request.route = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&route=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Route() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IRoute|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRouteRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouteRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouteRequest', ['route']); + request.route = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&route=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRouteRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouteRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRouteRequest', ['route']); + request.route = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRouteRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRouteRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRouteRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRouteRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRouteRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRouteRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertRouteRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertRouteRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new routesModule.v1.RoutesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRoutesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Route()), + generateSampleMessage(new protos.google.cloud.compute.v1.Route()), + generateSampleMessage(new protos.google.cloud.compute.v1.Route()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new routesModule.v1.RoutesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRoutesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Route()), + generateSampleMessage(new protos.google.cloud.compute.v1.Route()), + generateSampleMessage(new protos.google.cloud.compute.v1.Route()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IRoute[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new routesModule.v1.RoutesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRoutesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new routesModule.v1.RoutesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRoutesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Route()), + generateSampleMessage(new protos.google.cloud.compute.v1.Route()), + generateSampleMessage(new protos.google.cloud.compute.v1.Route()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Route[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Route) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new routesModule.v1.RoutesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRoutesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Route[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Route) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new routesModule.v1.RoutesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRoutesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Route()), + generateSampleMessage(new protos.google.cloud.compute.v1.Route()), + generateSampleMessage(new protos.google.cloud.compute.v1.Route()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IRoute[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new routesModule.v1.RoutesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListRoutesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListRoutesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IRoute[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_security_policies_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_security_policies_v1.ts new file mode 100644 index 00000000000..6f1c34a7587 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_security_policies_v1.ts @@ -0,0 +1,1701 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as securitypoliciesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.SecurityPoliciesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = securitypoliciesModule.v1.SecurityPoliciesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = securitypoliciesModule.v1.SecurityPoliciesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = securitypoliciesModule.v1.SecurityPoliciesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.securityPoliciesStub, undefined); + await client.initialize(); + assert(client.securityPoliciesStub); + }); + + it('has close method for the initialized client', done => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.securityPoliciesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.securityPoliciesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + 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 securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + 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('addRule', () => { + it('invokes addRule without error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddRuleSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addRule = stubSimpleCall(expectedResponse); + const [response] = await client.addRule(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addRule without error using callback', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddRuleSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addRule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addRule( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addRule with error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddRuleSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addRule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addRule(request), expectedError); + const actualRequest = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addRule with closed client', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddRuleSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddRuleSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addRule(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SecurityPolicy() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SecurityPolicy() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISecurityPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getRule', () => { + it('invokes getRule without error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRuleSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SecurityPolicyRule() + ); + client.innerApiCalls.getRule = stubSimpleCall(expectedResponse); + const [response] = await client.getRule(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRule without error using callback', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRuleSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SecurityPolicyRule() + ); + client.innerApiCalls.getRule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRule( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISecurityPolicyRule|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRule with error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRuleSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRule(request), expectedError); + const actualRequest = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRule with closed client', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetRuleSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetRuleSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getRule(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('listPreconfiguredExpressionSets', () => { + it('invokes listPreconfiguredExpressionSets without error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPreconfiguredExpressionSetsSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPreconfiguredExpressionSetsSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SecurityPoliciesListPreconfiguredExpressionSetsResponse() + ); + client.innerApiCalls.listPreconfiguredExpressionSets = stubSimpleCall(expectedResponse); + const [response] = await client.listPreconfiguredExpressionSets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPreconfiguredExpressionSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPreconfiguredExpressionSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPreconfiguredExpressionSets without error using callback', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPreconfiguredExpressionSetsSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPreconfiguredExpressionSetsSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SecurityPoliciesListPreconfiguredExpressionSetsResponse() + ); + client.innerApiCalls.listPreconfiguredExpressionSets = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPreconfiguredExpressionSets( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISecurityPoliciesListPreconfiguredExpressionSetsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPreconfiguredExpressionSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPreconfiguredExpressionSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPreconfiguredExpressionSets with error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPreconfiguredExpressionSetsSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPreconfiguredExpressionSetsSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPreconfiguredExpressionSets = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listPreconfiguredExpressionSets(request), expectedError); + const actualRequest = (client.innerApiCalls.listPreconfiguredExpressionSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPreconfiguredExpressionSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPreconfiguredExpressionSets with closed client', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListPreconfiguredExpressionSetsSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListPreconfiguredExpressionSetsSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.listPreconfiguredExpressionSets(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('patchRule', () => { + it('invokes patchRule without error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRuleSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patchRule = stubSimpleCall(expectedResponse); + const [response] = await client.patchRule(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchRule without error using callback', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRuleSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patchRule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patchRule( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchRule with error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRuleSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patchRule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patchRule(request), expectedError); + const actualRequest = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patchRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patchRule with closed client', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchRuleSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchRuleSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patchRule(request), expectedError); + }); + }); + + describe('removeRule', () => { + it('invokes removeRule without error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveRuleSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeRule = stubSimpleCall(expectedResponse); + const [response] = await client.removeRule(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeRule without error using callback', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveRuleSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeRule = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeRule( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeRule with error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveRuleSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&security_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeRule = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeRule(request), expectedError); + const actualRequest = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeRule as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeRule with closed client', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveRuleSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveRuleSecurityPolicyRequest', ['securityPolicy']); + request.securityPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeRule(request), expectedError); + }); + }); + + describe('setLabels', () => { + it('invokes setLabels without error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsSecurityPolicyRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCall(expectedResponse); + const [response] = await client.setLabels(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels without error using callback', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsSecurityPolicyRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setLabels( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsSecurityPolicyRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setLabels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with closed client', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsSecurityPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsSecurityPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsSecurityPolicyRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setLabels(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPoliciesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPoliciesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPoliciesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.ISecurityPoliciesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.ISecurityPoliciesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISecurityPolicy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.SecurityPolicy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.SecurityPolicy) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.SecurityPolicy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.SecurityPolicy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SecurityPolicy()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ISecurityPolicy[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new securitypoliciesModule.v1.SecurityPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSecurityPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSecurityPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ISecurityPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_service_attachments_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_service_attachments_v1.ts new file mode 100644 index 00000000000..7b4b6f05a5b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_service_attachments_v1.ts @@ -0,0 +1,1458 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as serviceattachmentsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.ServiceAttachmentsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = serviceattachmentsModule.v1.ServiceAttachmentsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = serviceattachmentsModule.v1.ServiceAttachmentsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = serviceattachmentsModule.v1.ServiceAttachmentsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.serviceAttachmentsStub, undefined); + await client.initialize(); + assert(client.serviceAttachmentsStub); + }); + + it('has close method for the initialized client', done => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.serviceAttachmentsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.serviceAttachmentsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + 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 serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteServiceAttachmentRequest', ['serviceAttachment']); + request.serviceAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&service_attachment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteServiceAttachmentRequest', ['serviceAttachment']); + request.serviceAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&service_attachment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteServiceAttachmentRequest', ['serviceAttachment']); + request.serviceAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&service_attachment=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteServiceAttachmentRequest', ['serviceAttachment']); + request.serviceAttachment = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetServiceAttachmentRequest', ['serviceAttachment']); + request.serviceAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&service_attachment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.ServiceAttachment() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetServiceAttachmentRequest', ['serviceAttachment']); + request.serviceAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&service_attachment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.ServiceAttachment() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IServiceAttachment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetServiceAttachmentRequest', ['serviceAttachment']); + request.serviceAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&service_attachment=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetServiceAttachmentRequest', ['serviceAttachment']); + request.serviceAttachment = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyServiceAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyServiceAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyServiceAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicyServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicyServiceAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchServiceAttachmentRequest', ['serviceAttachment']); + request.serviceAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&service_attachment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchServiceAttachmentRequest', ['serviceAttachment']); + request.serviceAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&service_attachment=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchServiceAttachmentRequest', ['serviceAttachment']); + request.serviceAttachment = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&service_attachment=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchServiceAttachmentRequest', ['serviceAttachment']); + request.serviceAttachment = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyServiceAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyServiceAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyServiceAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicyServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicyServiceAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsServiceAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsServiceAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsServiceAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsServiceAttachmentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsServiceAttachmentRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsServiceAttachmentRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsServiceAttachmentRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListServiceAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListServiceAttachmentsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.ServiceAttachmentsScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.ServiceAttachmentsScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.ServiceAttachmentsScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IServiceAttachmentsScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListServiceAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListServiceAttachmentsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IServiceAttachmentsScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListServiceAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListServiceAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListServiceAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ServiceAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.ServiceAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.ServiceAttachment()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListServiceAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListServiceAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListServiceAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ServiceAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.ServiceAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.ServiceAttachment()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IServiceAttachment[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListServiceAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListServiceAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListServiceAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListServiceAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListServiceAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListServiceAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ServiceAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.ServiceAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.ServiceAttachment()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.ServiceAttachment[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.ServiceAttachment) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListServiceAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListServiceAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListServiceAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.ServiceAttachment[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.ServiceAttachment) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListServiceAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListServiceAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListServiceAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.ServiceAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.ServiceAttachment()), + generateSampleMessage(new protos.google.cloud.compute.v1.ServiceAttachment()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IServiceAttachment[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new serviceattachmentsModule.v1.ServiceAttachmentsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListServiceAttachmentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListServiceAttachmentsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListServiceAttachmentsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IServiceAttachment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_snapshots_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_snapshots_v1.ts new file mode 100644 index 00000000000..ab82e368c76 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_snapshots_v1.ts @@ -0,0 +1,1281 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as snapshotsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.SnapshotsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = snapshotsModule.v1.SnapshotsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = snapshotsModule.v1.SnapshotsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = snapshotsModule.v1.SnapshotsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new snapshotsModule.v1.SnapshotsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.snapshotsStub, undefined); + await client.initialize(); + assert(client.snapshotsStub); + }); + + it('has close method for the initialized client', done => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.snapshotsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.snapshotsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + 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 snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSnapshotRequest', ['snapshot']); + request.snapshot = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&snapshot=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSnapshotRequest', ['snapshot']); + request.snapshot = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&snapshot=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSnapshotRequest', ['snapshot']); + request.snapshot = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&snapshot=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSnapshotRequest', ['snapshot']); + request.snapshot = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSnapshotRequest', ['snapshot']); + request.snapshot = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&snapshot=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Snapshot() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSnapshotRequest', ['snapshot']); + request.snapshot = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&snapshot=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Snapshot() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISnapshot|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSnapshotRequest', ['snapshot']); + request.snapshot = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&snapshot=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSnapshotRequest', ['snapshot']); + request.snapshot = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicySnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySnapshotRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicySnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySnapshotRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicySnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySnapshotRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicySnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySnapshotRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSnapshotRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSnapshotRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSnapshotRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSnapshotRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicySnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySnapshotRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicySnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySnapshotRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicySnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySnapshotRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicySnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySnapshotRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('setLabels', () => { + it('invokes setLabels without error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsSnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsSnapshotRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCall(expectedResponse); + const [response] = await client.setLabels(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels without error using callback', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsSnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsSnapshotRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setLabels( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsSnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsSnapshotRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setLabels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with closed client', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsSnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsSnapshotRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setLabels(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSnapshotRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSnapshotRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSnapshotRequest', ['resource']); + request.resource = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&resource=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsSnapshotRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSnapshotRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSnapshotRequest', ['resource']); + request.resource = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSnapshotsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSnapshotsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Snapshot()), + generateSampleMessage(new protos.google.cloud.compute.v1.Snapshot()), + generateSampleMessage(new protos.google.cloud.compute.v1.Snapshot()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSnapshotsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSnapshotsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Snapshot()), + generateSampleMessage(new protos.google.cloud.compute.v1.Snapshot()), + generateSampleMessage(new protos.google.cloud.compute.v1.Snapshot()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISnapshot[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSnapshotsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSnapshotsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSnapshotsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSnapshotsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Snapshot()), + generateSampleMessage(new protos.google.cloud.compute.v1.Snapshot()), + generateSampleMessage(new protos.google.cloud.compute.v1.Snapshot()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Snapshot[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Snapshot) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSnapshotsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSnapshotsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Snapshot[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Snapshot) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSnapshotsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSnapshotsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Snapshot()), + generateSampleMessage(new protos.google.cloud.compute.v1.Snapshot()), + generateSampleMessage(new protos.google.cloud.compute.v1.Snapshot()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ISnapshot[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new snapshotsModule.v1.SnapshotsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSnapshotsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSnapshotsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ISnapshot[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_ssl_certificates_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_ssl_certificates_v1.ts new file mode 100644 index 00000000000..e40de082da5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_ssl_certificates_v1.ts @@ -0,0 +1,873 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as sslcertificatesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.SslCertificatesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = sslcertificatesModule.v1.SslCertificatesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = sslcertificatesModule.v1.SslCertificatesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = sslcertificatesModule.v1.SslCertificatesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.sslCertificatesStub, undefined); + await client.initialize(); + assert(client.sslCertificatesStub); + }); + + it('has close method for the initialized client', done => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.sslCertificatesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.sslCertificatesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + 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 sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSslCertificateRequest', ['sslCertificate']); + request.sslCertificate = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&ssl_certificate=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSslCertificateRequest', ['sslCertificate']); + request.sslCertificate = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&ssl_certificate=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSslCertificateRequest', ['sslCertificate']); + request.sslCertificate = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&ssl_certificate=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSslCertificateRequest', ['sslCertificate']); + request.sslCertificate = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSslCertificateRequest', ['sslCertificate']); + request.sslCertificate = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&ssl_certificate=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SslCertificate() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSslCertificateRequest', ['sslCertificate']); + request.sslCertificate = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&ssl_certificate=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SslCertificate() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISslCertificate|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSslCertificateRequest', ['sslCertificate']); + request.sslCertificate = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&ssl_certificate=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSslCertificateRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSslCertificateRequest', ['sslCertificate']); + request.sslCertificate = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSslCertificateRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSslCertificateRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSslCertificateRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSslCertificateRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSslCertificateRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListSslCertificatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListSslCertificatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificatesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificatesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificatesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.ISslCertificatesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListSslCertificatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListSslCertificatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.ISslCertificatesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSslCertificatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSslCertificatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSslCertificatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSslCertificatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISslCertificate[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSslCertificatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSslCertificatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSslCertificatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSslCertificatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.SslCertificate[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.SslCertificate) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSslCertificatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSslCertificatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.SslCertificate[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.SslCertificate) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSslCertificatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSslCertificatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslCertificate()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ISslCertificate[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new sslcertificatesModule.v1.SslCertificatesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSslCertificatesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSslCertificatesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ISslCertificate[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_ssl_policies_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_ssl_policies_v1.ts new file mode 100644 index 00000000000..c06eef6e5df --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_ssl_policies_v1.ts @@ -0,0 +1,1101 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as sslpoliciesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.SslPoliciesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = sslpoliciesModule.v1.SslPoliciesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = sslpoliciesModule.v1.SslPoliciesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = sslpoliciesModule.v1.SslPoliciesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.sslPoliciesStub, undefined); + await client.initialize(); + assert(client.sslPoliciesStub); + }); + + it('has close method for the initialized client', done => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.sslPoliciesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.sslPoliciesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + 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 sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&ssl_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&ssl_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&ssl_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&ssl_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SslPolicy() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&ssl_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SslPolicy() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISslPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&ssl_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSslPolicyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSslPolicyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSslPolicyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSslPolicyRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('listAvailableFeatures', () => { + it('invokes listAvailableFeatures without error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAvailableFeaturesSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAvailableFeaturesSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SslPoliciesListAvailableFeaturesResponse() + ); + client.innerApiCalls.listAvailableFeatures = stubSimpleCall(expectedResponse); + const [response] = await client.listAvailableFeatures(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listAvailableFeatures as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAvailableFeatures as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAvailableFeatures without error using callback', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAvailableFeaturesSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAvailableFeaturesSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.SslPoliciesListAvailableFeaturesResponse() + ); + client.innerApiCalls.listAvailableFeatures = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAvailableFeatures( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISslPoliciesListAvailableFeaturesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listAvailableFeatures as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAvailableFeatures as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAvailableFeatures with error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAvailableFeaturesSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAvailableFeaturesSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAvailableFeatures = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listAvailableFeatures(request), expectedError); + const actualRequest = (client.innerApiCalls.listAvailableFeatures as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAvailableFeatures as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAvailableFeatures with closed client', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListAvailableFeaturesSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListAvailableFeaturesSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.listAvailableFeatures(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&ssl_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&ssl_policy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&ssl_policy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchSslPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSslPolicyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSslPolicyRequest', ['sslPolicy']); + request.sslPolicy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.SslPoliciesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.SslPoliciesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.SslPoliciesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.ISslPoliciesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.ISslPoliciesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISslPolicy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.SslPolicy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.SslPolicy) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.SslPolicy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.SslPolicy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + generateSampleMessage(new protos.google.cloud.compute.v1.SslPolicy()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ISslPolicy[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new sslpoliciesModule.v1.SslPoliciesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSslPoliciesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSslPoliciesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ISslPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_subnetworks_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_subnetworks_v1.ts new file mode 100644 index 00000000000..50bf3d57d3b --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_subnetworks_v1.ts @@ -0,0 +1,1967 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as subnetworksModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.SubnetworksClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = subnetworksModule.v1.SubnetworksClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = subnetworksModule.v1.SubnetworksClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = subnetworksModule.v1.SubnetworksClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new subnetworksModule.v1.SubnetworksClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.subnetworksStub, undefined); + await client.initialize(); + assert(client.subnetworksStub); + }); + + it('has close method for the initialized client', done => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.subnetworksStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.subnetworksStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + 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 subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&subnetwork=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&subnetwork=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&subnetwork=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('expandIpCidrRange', () => { + it('invokes expandIpCidrRange without error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ExpandIpCidrRangeSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ExpandIpCidrRangeSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ExpandIpCidrRangeSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ExpandIpCidrRangeSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&subnetwork=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.expandIpCidrRange = stubSimpleCall(expectedResponse); + const [response] = await client.expandIpCidrRange(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.expandIpCidrRange as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.expandIpCidrRange as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes expandIpCidrRange without error using callback', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ExpandIpCidrRangeSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ExpandIpCidrRangeSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ExpandIpCidrRangeSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ExpandIpCidrRangeSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&subnetwork=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.expandIpCidrRange = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.expandIpCidrRange( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.expandIpCidrRange as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.expandIpCidrRange as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes expandIpCidrRange with error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ExpandIpCidrRangeSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ExpandIpCidrRangeSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ExpandIpCidrRangeSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ExpandIpCidrRangeSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&subnetwork=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.expandIpCidrRange = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.expandIpCidrRange(request), expectedError); + const actualRequest = (client.innerApiCalls.expandIpCidrRange as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.expandIpCidrRange as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes expandIpCidrRange with closed client', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ExpandIpCidrRangeSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ExpandIpCidrRangeSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ExpandIpCidrRangeSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.ExpandIpCidrRangeSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.expandIpCidrRange(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&subnetwork=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Subnetwork() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&subnetwork=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Subnetwork() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISubnetwork|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&subnetwork=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicySubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySubnetworkRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicySubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySubnetworkRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicySubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySubnetworkRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetIamPolicySubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetIamPolicySubnetworkRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSubnetworkRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSubnetworkRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSubnetworkRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertSubnetworkRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&subnetwork=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&subnetwork=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&subnetwork=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicySubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySubnetworkRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicySubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySubnetworkRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicySubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySubnetworkRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetIamPolicySubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetIamPolicySubnetworkRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('setPrivateIpGoogleAccess', () => { + it('invokes setPrivateIpGoogleAccess without error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetPrivateIpGoogleAccessSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetPrivateIpGoogleAccessSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetPrivateIpGoogleAccessSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetPrivateIpGoogleAccessSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&subnetwork=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setPrivateIpGoogleAccess = stubSimpleCall(expectedResponse); + const [response] = await client.setPrivateIpGoogleAccess(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setPrivateIpGoogleAccess as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setPrivateIpGoogleAccess as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setPrivateIpGoogleAccess without error using callback', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetPrivateIpGoogleAccessSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetPrivateIpGoogleAccessSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetPrivateIpGoogleAccessSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetPrivateIpGoogleAccessSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&subnetwork=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setPrivateIpGoogleAccess = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setPrivateIpGoogleAccess( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setPrivateIpGoogleAccess as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setPrivateIpGoogleAccess as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setPrivateIpGoogleAccess with error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetPrivateIpGoogleAccessSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetPrivateIpGoogleAccessSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetPrivateIpGoogleAccessSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetPrivateIpGoogleAccessSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&subnetwork=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setPrivateIpGoogleAccess = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setPrivateIpGoogleAccess(request), expectedError); + const actualRequest = (client.innerApiCalls.setPrivateIpGoogleAccess as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setPrivateIpGoogleAccess as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setPrivateIpGoogleAccess with closed client', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetPrivateIpGoogleAccessSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetPrivateIpGoogleAccessSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetPrivateIpGoogleAccessSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetPrivateIpGoogleAccessSubnetworkRequest', ['subnetwork']); + request.subnetwork = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setPrivateIpGoogleAccess(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSubnetworkRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSubnetworkRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSubnetworkRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsSubnetworkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSubnetworkRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSubnetworkRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsSubnetworkRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListSubnetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListSubnetworksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.SubnetworksScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.SubnetworksScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.SubnetworksScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.ISubnetworksScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListSubnetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListSubnetworksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.ISubnetworksScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSubnetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSubnetworksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSubnetworksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Subnetwork()), + generateSampleMessage(new protos.google.cloud.compute.v1.Subnetwork()), + generateSampleMessage(new protos.google.cloud.compute.v1.Subnetwork()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSubnetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSubnetworksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSubnetworksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Subnetwork()), + generateSampleMessage(new protos.google.cloud.compute.v1.Subnetwork()), + generateSampleMessage(new protos.google.cloud.compute.v1.Subnetwork()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ISubnetwork[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSubnetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSubnetworksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSubnetworksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSubnetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSubnetworksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSubnetworksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Subnetwork()), + generateSampleMessage(new protos.google.cloud.compute.v1.Subnetwork()), + generateSampleMessage(new protos.google.cloud.compute.v1.Subnetwork()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Subnetwork[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Subnetwork) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSubnetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSubnetworksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSubnetworksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Subnetwork[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Subnetwork) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSubnetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSubnetworksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSubnetworksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Subnetwork()), + generateSampleMessage(new protos.google.cloud.compute.v1.Subnetwork()), + generateSampleMessage(new protos.google.cloud.compute.v1.Subnetwork()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ISubnetwork[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListSubnetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSubnetworksRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListSubnetworksRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ISubnetwork[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listUsable', () => { + it('invokes listUsable without error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListUsableSubnetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListUsableSubnetworksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.UsableSubnetwork()), + generateSampleMessage(new protos.google.cloud.compute.v1.UsableSubnetwork()), + generateSampleMessage(new protos.google.cloud.compute.v1.UsableSubnetwork()), + ]; + client.innerApiCalls.listUsable = stubSimpleCall(expectedResponse); + const [response] = await client.listUsable(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listUsable as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listUsable as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listUsable without error using callback', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListUsableSubnetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListUsableSubnetworksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.UsableSubnetwork()), + generateSampleMessage(new protos.google.cloud.compute.v1.UsableSubnetwork()), + generateSampleMessage(new protos.google.cloud.compute.v1.UsableSubnetwork()), + ]; + client.innerApiCalls.listUsable = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listUsable( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IUsableSubnetwork[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listUsable as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listUsable as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listUsable with error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListUsableSubnetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListUsableSubnetworksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listUsable = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listUsable(request), expectedError); + const actualRequest = (client.innerApiCalls.listUsable as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listUsable as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listUsableStream without error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListUsableSubnetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListUsableSubnetworksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.UsableSubnetwork()), + generateSampleMessage(new protos.google.cloud.compute.v1.UsableSubnetwork()), + generateSampleMessage(new protos.google.cloud.compute.v1.UsableSubnetwork()), + ]; + client.descriptors.page.listUsable.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listUsableStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.UsableSubnetwork[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.UsableSubnetwork) => { + 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.listUsable.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listUsable, request)); + assert( + (client.descriptors.page.listUsable.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listUsableStream with error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListUsableSubnetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListUsableSubnetworksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listUsable.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listUsableStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.UsableSubnetwork[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.UsableSubnetwork) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listUsable.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listUsable, request)); + assert( + (client.descriptors.page.listUsable.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listUsable without error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListUsableSubnetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListUsableSubnetworksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.UsableSubnetwork()), + generateSampleMessage(new protos.google.cloud.compute.v1.UsableSubnetwork()), + generateSampleMessage(new protos.google.cloud.compute.v1.UsableSubnetwork()), + ]; + client.descriptors.page.listUsable.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IUsableSubnetwork[] = []; + const iterable = client.listUsableAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listUsable.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listUsable.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listUsable with error', async () => { + const client = new subnetworksModule.v1.SubnetworksClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListUsableSubnetworksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListUsableSubnetworksRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listUsable.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listUsableAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IUsableSubnetwork[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listUsable.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listUsable.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_grpc_proxies_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_grpc_proxies_v1.ts new file mode 100644 index 00000000000..2bc596c5ef7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_grpc_proxies_v1.ts @@ -0,0 +1,921 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as targetgrpcproxiesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.TargetGrpcProxiesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = targetgrpcproxiesModule.v1.TargetGrpcProxiesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = targetgrpcproxiesModule.v1.TargetGrpcProxiesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = targetgrpcproxiesModule.v1.TargetGrpcProxiesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.targetGrpcProxiesStub, undefined); + await client.initialize(); + assert(client.targetGrpcProxiesStub); + }); + + it('has close method for the initialized client', done => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.targetGrpcProxiesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.targetGrpcProxiesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + 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 targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetGrpcProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetGrpcProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetGrpcProxyRequest', ['targetGrpcProxy']); + request.targetGrpcProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_grpc_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetGrpcProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetGrpcProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetGrpcProxyRequest', ['targetGrpcProxy']); + request.targetGrpcProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_grpc_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetGrpcProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetGrpcProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetGrpcProxyRequest', ['targetGrpcProxy']); + request.targetGrpcProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_grpc_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetGrpcProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetGrpcProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetGrpcProxyRequest', ['targetGrpcProxy']); + request.targetGrpcProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetGrpcProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetGrpcProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetGrpcProxyRequest', ['targetGrpcProxy']); + request.targetGrpcProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_grpc_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetGrpcProxy() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetGrpcProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetGrpcProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetGrpcProxyRequest', ['targetGrpcProxy']); + request.targetGrpcProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_grpc_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetGrpcProxy() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetGrpcProxy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetGrpcProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetGrpcProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetGrpcProxyRequest', ['targetGrpcProxy']); + request.targetGrpcProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_grpc_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetGrpcProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetGrpcProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetGrpcProxyRequest', ['targetGrpcProxy']); + request.targetGrpcProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetGrpcProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetGrpcProxyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetGrpcProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetGrpcProxyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetGrpcProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetGrpcProxyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetGrpcProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetGrpcProxyRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchTargetGrpcProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetGrpcProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetGrpcProxyRequest', ['targetGrpcProxy']); + request.targetGrpcProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_grpc_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchTargetGrpcProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetGrpcProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetGrpcProxyRequest', ['targetGrpcProxy']); + request.targetGrpcProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_grpc_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchTargetGrpcProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetGrpcProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetGrpcProxyRequest', ['targetGrpcProxy']); + request.targetGrpcProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_grpc_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchTargetGrpcProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetGrpcProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetGrpcProxyRequest', ['targetGrpcProxy']); + request.targetGrpcProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetGrpcProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetGrpcProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetGrpcProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetGrpcProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetGrpcProxy()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetGrpcProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetGrpcProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetGrpcProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetGrpcProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetGrpcProxy()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetGrpcProxy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetGrpcProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetGrpcProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetGrpcProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetGrpcProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetGrpcProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetGrpcProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetGrpcProxy()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetGrpcProxy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetGrpcProxy) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetGrpcProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetGrpcProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetGrpcProxy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetGrpcProxy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetGrpcProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetGrpcProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetGrpcProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetGrpcProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetGrpcProxy()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ITargetGrpcProxy[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new targetgrpcproxiesModule.v1.TargetGrpcProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetGrpcProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetGrpcProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ITargetGrpcProxy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_http_proxies_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_http_proxies_v1.ts new file mode 100644 index 00000000000..96ac9f0a4ef --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_http_proxies_v1.ts @@ -0,0 +1,1113 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as targethttpproxiesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.TargetHttpProxiesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = targethttpproxiesModule.v1.TargetHttpProxiesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = targethttpproxiesModule.v1.TargetHttpProxiesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = targethttpproxiesModule.v1.TargetHttpProxiesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.targetHttpProxiesStub, undefined); + await client.initialize(); + assert(client.targetHttpProxiesStub); + }); + + it('has close method for the initialized client', done => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.targetHttpProxiesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.targetHttpProxiesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + 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 targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_http_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_http_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_http_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_http_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetHttpProxy() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_http_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetHttpProxy() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetHttpProxy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_http_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_http_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_http_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_http_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('setUrlMap', () => { + it('invokes setUrlMap without error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUrlMapTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_http_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setUrlMap = stubSimpleCall(expectedResponse); + const [response] = await client.setUrlMap(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setUrlMap without error using callback', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUrlMapTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_http_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setUrlMap = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setUrlMap( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setUrlMap with error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUrlMapTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_http_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setUrlMap = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setUrlMap(request), expectedError); + const actualRequest = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setUrlMap with closed client', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUrlMapTargetHttpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapTargetHttpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapTargetHttpProxyRequest', ['targetHttpProxy']); + request.targetHttpProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setUrlMap(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListTargetHttpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListTargetHttpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxiesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxiesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxiesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.ITargetHttpProxiesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListTargetHttpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListTargetHttpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.ITargetHttpProxiesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetHttpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetHttpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetHttpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetHttpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetHttpProxy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetHttpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetHttpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetHttpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetHttpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetHttpProxy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetHttpProxy) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetHttpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetHttpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetHttpProxy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetHttpProxy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetHttpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetHttpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpProxy()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ITargetHttpProxy[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new targethttpproxiesModule.v1.TargetHttpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetHttpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetHttpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ITargetHttpProxy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_https_proxies_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_https_proxies_v1.ts new file mode 100644 index 00000000000..7a5e888d2f0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_https_proxies_v1.ts @@ -0,0 +1,1593 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as targethttpsproxiesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.TargetHttpsProxiesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = targethttpsproxiesModule.v1.TargetHttpsProxiesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = targethttpsproxiesModule.v1.TargetHttpsProxiesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = targethttpsproxiesModule.v1.TargetHttpsProxiesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.targetHttpsProxiesStub, undefined); + await client.initialize(); + assert(client.targetHttpsProxiesStub); + }); + + it('has close method for the initialized client', done => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.targetHttpsProxiesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.targetHttpsProxiesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + 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 targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetHttpsProxy() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetHttpsProxy() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetHttpsProxy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('setCertificateMap', () => { + it('invokes setCertificateMap without error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetCertificateMapTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCertificateMapTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCertificateMapTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setCertificateMap = stubSimpleCall(expectedResponse); + const [response] = await client.setCertificateMap(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setCertificateMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setCertificateMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setCertificateMap without error using callback', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetCertificateMapTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCertificateMapTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCertificateMapTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setCertificateMap = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setCertificateMap( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setCertificateMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setCertificateMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setCertificateMap with error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetCertificateMapTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCertificateMapTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCertificateMapTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setCertificateMap = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setCertificateMap(request), expectedError); + const actualRequest = (client.innerApiCalls.setCertificateMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setCertificateMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setCertificateMap with closed client', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetCertificateMapTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCertificateMapTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCertificateMapTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setCertificateMap(request), expectedError); + }); + }); + + describe('setQuicOverride', () => { + it('invokes setQuicOverride without error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetQuicOverrideTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetQuicOverrideTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetQuicOverrideTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setQuicOverride = stubSimpleCall(expectedResponse); + const [response] = await client.setQuicOverride(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setQuicOverride as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setQuicOverride as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setQuicOverride without error using callback', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetQuicOverrideTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetQuicOverrideTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetQuicOverrideTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setQuicOverride = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setQuicOverride( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setQuicOverride as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setQuicOverride as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setQuicOverride with error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetQuicOverrideTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetQuicOverrideTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetQuicOverrideTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setQuicOverride = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setQuicOverride(request), expectedError); + const actualRequest = (client.innerApiCalls.setQuicOverride as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setQuicOverride as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setQuicOverride with closed client', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetQuicOverrideTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetQuicOverrideTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetQuicOverrideTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setQuicOverride(request), expectedError); + }); + }); + + describe('setSslCertificates', () => { + it('invokes setSslCertificates without error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslCertificatesTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setSslCertificates = stubSimpleCall(expectedResponse); + const [response] = await client.setSslCertificates(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSslCertificates without error using callback', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslCertificatesTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setSslCertificates = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setSslCertificates( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSslCertificates with error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslCertificatesTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setSslCertificates = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setSslCertificates(request), expectedError); + const actualRequest = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSslCertificates with closed client', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslCertificatesTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setSslCertificates(request), expectedError); + }); + }); + + describe('setSslPolicy', () => { + it('invokes setSslPolicy without error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslPolicyTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslPolicyTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslPolicyTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setSslPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setSslPolicy(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setSslPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSslPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSslPolicy without error using callback', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslPolicyTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslPolicyTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslPolicyTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setSslPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setSslPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setSslPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSslPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSslPolicy with error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslPolicyTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslPolicyTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslPolicyTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setSslPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setSslPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setSslPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSslPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSslPolicy with closed client', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslPolicyTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslPolicyTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslPolicyTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setSslPolicy(request), expectedError); + }); + }); + + describe('setUrlMap', () => { + it('invokes setUrlMap without error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUrlMapTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setUrlMap = stubSimpleCall(expectedResponse); + const [response] = await client.setUrlMap(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setUrlMap without error using callback', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUrlMapTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setUrlMap = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setUrlMap( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setUrlMap with error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUrlMapTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_https_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setUrlMap = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setUrlMap(request), expectedError); + const actualRequest = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setUrlMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setUrlMap with closed client', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetUrlMapTargetHttpsProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapTargetHttpsProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetUrlMapTargetHttpsProxyRequest', ['targetHttpsProxy']); + request.targetHttpsProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setUrlMap(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListTargetHttpsProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListTargetHttpsProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxiesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxiesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxiesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.ITargetHttpsProxiesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListTargetHttpsProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListTargetHttpsProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.ITargetHttpsProxiesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetHttpsProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetHttpsProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetHttpsProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetHttpsProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetHttpsProxy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetHttpsProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetHttpsProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetHttpsProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetHttpsProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetHttpsProxy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetHttpsProxy) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetHttpsProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetHttpsProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetHttpsProxy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetHttpsProxy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetHttpsProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetHttpsProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetHttpsProxy()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ITargetHttpsProxy[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new targethttpsproxiesModule.v1.TargetHttpsProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetHttpsProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetHttpsProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ITargetHttpsProxy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_instances_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_instances_v1.ts new file mode 100644 index 00000000000..bfb9a8281ef --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_instances_v1.ts @@ -0,0 +1,930 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as targetinstancesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.TargetInstancesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = targetinstancesModule.v1.TargetInstancesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = targetinstancesModule.v1.TargetInstancesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = targetinstancesModule.v1.TargetInstancesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new targetinstancesModule.v1.TargetInstancesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.targetInstancesStub, undefined); + await client.initialize(); + assert(client.targetInstancesStub); + }); + + it('has close method for the initialized client', done => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.targetInstancesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.targetInstancesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + 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 targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetInstanceRequest', ['targetInstance']); + request.targetInstance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&target_instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetInstanceRequest', ['targetInstance']); + request.targetInstance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&target_instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetInstanceRequest', ['targetInstance']); + request.targetInstance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&target_instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetInstanceRequest', ['targetInstance']); + request.targetInstance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetInstanceRequest', ['targetInstance']); + request.targetInstance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&target_instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetInstance() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetInstanceRequest', ['targetInstance']); + request.targetInstance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&target_instance=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetInstance() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetInstance|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetInstanceRequest', ['targetInstance']); + request.targetInstance = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&target_instance=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetInstanceRequest', ['targetInstance']); + request.targetInstance = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetInstanceRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetInstanceRequest', ['zone']); + request.zone = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListTargetInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListTargetInstancesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.TargetInstancesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.TargetInstancesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.TargetInstancesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.ITargetInstancesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListTargetInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListTargetInstancesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.ITargetInstancesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetInstancesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetInstance()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetInstancesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetInstance()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetInstance[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetInstancesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetInstancesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetInstance()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetInstance[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetInstance) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetInstancesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetInstance[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetInstance) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetInstancesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetInstance()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetInstance()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ITargetInstance[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new targetinstancesModule.v1.TargetInstancesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetInstancesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetInstancesRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ITargetInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_pools_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_pools_v1.ts new file mode 100644 index 00000000000..b0d2083cc8a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_pools_v1.ts @@ -0,0 +1,1722 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as targetpoolsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.TargetPoolsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = targetpoolsModule.v1.TargetPoolsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = targetpoolsModule.v1.TargetPoolsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = targetpoolsModule.v1.TargetPoolsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new targetpoolsModule.v1.TargetPoolsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.targetPoolsStub, undefined); + await client.initialize(); + assert(client.targetPoolsStub); + }); + + it('has close method for the initialized client', done => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.targetPoolsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.targetPoolsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + 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 targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + 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('addHealthCheck', () => { + it('invokes addHealthCheck without error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddHealthCheckTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddHealthCheckTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddHealthCheckTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddHealthCheckTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addHealthCheck = stubSimpleCall(expectedResponse); + const [response] = await client.addHealthCheck(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addHealthCheck as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addHealthCheck as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addHealthCheck without error using callback', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddHealthCheckTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddHealthCheckTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddHealthCheckTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddHealthCheckTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addHealthCheck = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addHealthCheck( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addHealthCheck as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addHealthCheck as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addHealthCheck with error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddHealthCheckTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddHealthCheckTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddHealthCheckTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddHealthCheckTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addHealthCheck = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addHealthCheck(request), expectedError); + const actualRequest = (client.innerApiCalls.addHealthCheck as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addHealthCheck as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addHealthCheck with closed client', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddHealthCheckTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddHealthCheckTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddHealthCheckTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddHealthCheckTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addHealthCheck(request), expectedError); + }); + }); + + describe('addInstance', () => { + it('invokes addInstance without error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddInstanceTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstanceTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstanceTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstanceTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addInstance = stubSimpleCall(expectedResponse); + const [response] = await client.addInstance(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.addInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addInstance without error using callback', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddInstanceTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstanceTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstanceTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstanceTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.addInstance = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addInstance( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addInstance with error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddInstanceTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstanceTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstanceTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstanceTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addInstance = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.addInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addInstance with closed client', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AddInstanceTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstanceTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstanceTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.AddInstanceTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addInstance(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetPool() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetPool() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetPool|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getHealth', () => { + it('invokes getHealth without error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetHealthTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetPoolInstanceHealth() + ); + client.innerApiCalls.getHealth = stubSimpleCall(expectedResponse); + const [response] = await client.getHealth(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getHealth without error using callback', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetHealthTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetPoolInstanceHealth() + ); + client.innerApiCalls.getHealth = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getHealth( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetPoolInstanceHealth|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getHealth with error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetHealthTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getHealth = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getHealth(request), expectedError); + const actualRequest = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getHealth as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getHealth with closed client', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetHealthTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetHealthTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getHealth(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetPoolRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetPoolRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetPoolRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetPoolRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('removeHealthCheck', () => { + it('invokes removeHealthCheck without error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveHealthCheckTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveHealthCheckTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveHealthCheckTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveHealthCheckTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeHealthCheck = stubSimpleCall(expectedResponse); + const [response] = await client.removeHealthCheck(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.removeHealthCheck as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeHealthCheck as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeHealthCheck without error using callback', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveHealthCheckTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveHealthCheckTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveHealthCheckTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveHealthCheckTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeHealthCheck = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeHealthCheck( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeHealthCheck as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeHealthCheck as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeHealthCheck with error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveHealthCheckTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveHealthCheckTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveHealthCheckTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveHealthCheckTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeHealthCheck = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeHealthCheck(request), expectedError); + const actualRequest = (client.innerApiCalls.removeHealthCheck as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeHealthCheck as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeHealthCheck with closed client', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveHealthCheckTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveHealthCheckTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveHealthCheckTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveHealthCheckTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeHealthCheck(request), expectedError); + }); + }); + + describe('removeInstance', () => { + it('invokes removeInstance without error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveInstanceTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstanceTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstanceTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstanceTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeInstance = stubSimpleCall(expectedResponse); + const [response] = await client.removeInstance(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.removeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeInstance without error using callback', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveInstanceTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstanceTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstanceTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstanceTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.removeInstance = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeInstance( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeInstance with error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveInstanceTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstanceTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstanceTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstanceTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeInstance = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.removeInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeInstance with closed client', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.RemoveInstanceTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstanceTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstanceTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.RemoveInstanceTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeInstance(request), expectedError); + }); + }); + + describe('setBackup', () => { + it('invokes setBackup without error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetBackupTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackupTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackupTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackupTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setBackup = stubSimpleCall(expectedResponse); + const [response] = await client.setBackup(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setBackup without error using callback', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetBackupTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackupTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackupTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackupTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setBackup = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setBackup( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setBackup with error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetBackupTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackupTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackupTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackupTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_pool=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setBackup = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setBackup(request), expectedError); + const actualRequest = (client.innerApiCalls.setBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setBackup with closed client', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetBackupTargetPoolRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackupTargetPoolRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackupTargetPoolRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackupTargetPoolRequest', ['targetPool']); + request.targetPool = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setBackup(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListTargetPoolsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListTargetPoolsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.TargetPoolsScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.TargetPoolsScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.TargetPoolsScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.ITargetPoolsScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListTargetPoolsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListTargetPoolsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.ITargetPoolsScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetPoolsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetPoolsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetPoolsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetPool()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetPool()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetPool()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetPoolsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetPoolsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetPoolsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetPool()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetPool()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetPool()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetPool[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetPoolsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetPoolsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetPoolsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetPoolsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetPoolsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetPoolsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetPool()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetPool()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetPool()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetPool[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetPool) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetPoolsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetPoolsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetPoolsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetPool[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetPool) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetPoolsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetPoolsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetPoolsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetPool()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetPool()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetPool()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ITargetPool[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new targetpoolsModule.v1.TargetPoolsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetPoolsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetPoolsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetPoolsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ITargetPool[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_ssl_proxies_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_ssl_proxies_v1.ts new file mode 100644 index 00000000000..92e9a07de03 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_ssl_proxies_v1.ts @@ -0,0 +1,1401 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as targetsslproxiesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.TargetSslProxiesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = targetsslproxiesModule.v1.TargetSslProxiesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = targetsslproxiesModule.v1.TargetSslProxiesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = targetsslproxiesModule.v1.TargetSslProxiesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.targetSslProxiesStub, undefined); + await client.initialize(); + assert(client.targetSslProxiesStub); + }); + + it('has close method for the initialized client', done => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.targetSslProxiesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.targetSslProxiesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + 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 targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetSslProxy() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetSslProxy() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetSslProxy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('setBackendService', () => { + it('invokes setBackendService without error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetBackendServiceTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackendServiceTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackendServiceTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setBackendService = stubSimpleCall(expectedResponse); + const [response] = await client.setBackendService(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setBackendService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setBackendService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setBackendService without error using callback', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetBackendServiceTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackendServiceTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackendServiceTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setBackendService = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setBackendService( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setBackendService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setBackendService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setBackendService with error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetBackendServiceTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackendServiceTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackendServiceTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setBackendService = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setBackendService(request), expectedError); + const actualRequest = (client.innerApiCalls.setBackendService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setBackendService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setBackendService with closed client', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetBackendServiceTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackendServiceTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackendServiceTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setBackendService(request), expectedError); + }); + }); + + describe('setCertificateMap', () => { + it('invokes setCertificateMap without error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetCertificateMapTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCertificateMapTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCertificateMapTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setCertificateMap = stubSimpleCall(expectedResponse); + const [response] = await client.setCertificateMap(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setCertificateMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setCertificateMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setCertificateMap without error using callback', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetCertificateMapTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCertificateMapTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCertificateMapTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setCertificateMap = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setCertificateMap( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setCertificateMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setCertificateMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setCertificateMap with error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetCertificateMapTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCertificateMapTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCertificateMapTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setCertificateMap = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setCertificateMap(request), expectedError); + const actualRequest = (client.innerApiCalls.setCertificateMap as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setCertificateMap as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setCertificateMap with closed client', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetCertificateMapTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCertificateMapTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetCertificateMapTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setCertificateMap(request), expectedError); + }); + }); + + describe('setProxyHeader', () => { + it('invokes setProxyHeader without error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetProxyHeaderTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetProxyHeaderTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetProxyHeaderTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setProxyHeader = stubSimpleCall(expectedResponse); + const [response] = await client.setProxyHeader(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setProxyHeader as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setProxyHeader as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setProxyHeader without error using callback', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetProxyHeaderTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetProxyHeaderTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetProxyHeaderTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setProxyHeader = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setProxyHeader( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setProxyHeader as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setProxyHeader as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setProxyHeader with error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetProxyHeaderTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetProxyHeaderTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetProxyHeaderTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setProxyHeader = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setProxyHeader(request), expectedError); + const actualRequest = (client.innerApiCalls.setProxyHeader as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setProxyHeader as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setProxyHeader with closed client', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetProxyHeaderTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetProxyHeaderTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetProxyHeaderTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setProxyHeader(request), expectedError); + }); + }); + + describe('setSslCertificates', () => { + it('invokes setSslCertificates without error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslCertificatesTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setSslCertificates = stubSimpleCall(expectedResponse); + const [response] = await client.setSslCertificates(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSslCertificates without error using callback', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslCertificatesTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setSslCertificates = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setSslCertificates( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSslCertificates with error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslCertificatesTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setSslCertificates = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setSslCertificates(request), expectedError); + const actualRequest = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSslCertificates as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSslCertificates with closed client', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslCertificatesTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslCertificatesTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setSslCertificates(request), expectedError); + }); + }); + + describe('setSslPolicy', () => { + it('invokes setSslPolicy without error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslPolicyTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslPolicyTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslPolicyTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setSslPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setSslPolicy(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setSslPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSslPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSslPolicy without error using callback', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslPolicyTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslPolicyTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslPolicyTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setSslPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setSslPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setSslPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSslPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSslPolicy with error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslPolicyTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslPolicyTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslPolicyTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_ssl_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setSslPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setSslPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setSslPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setSslPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setSslPolicy with closed client', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetSslPolicyTargetSslProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslPolicyTargetSslProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetSslPolicyTargetSslProxyRequest', ['targetSslProxy']); + request.targetSslProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setSslPolicy(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetSslProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetSslProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetSslProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetSslProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetSslProxy()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetSslProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetSslProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetSslProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetSslProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetSslProxy()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetSslProxy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetSslProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetSslProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetSslProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetSslProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetSslProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetSslProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetSslProxy()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetSslProxy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetSslProxy) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetSslProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetSslProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetSslProxy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetSslProxy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetSslProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetSslProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetSslProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetSslProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetSslProxy()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ITargetSslProxy[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new targetsslproxiesModule.v1.TargetSslProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetSslProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetSslProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ITargetSslProxy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_tcp_proxies_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_tcp_proxies_v1.ts new file mode 100644 index 00000000000..55ddfa8fd95 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_tcp_proxies_v1.ts @@ -0,0 +1,1113 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as targettcpproxiesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.TargetTcpProxiesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = targettcpproxiesModule.v1.TargetTcpProxiesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = targettcpproxiesModule.v1.TargetTcpProxiesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = targettcpproxiesModule.v1.TargetTcpProxiesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.targetTcpProxiesStub, undefined); + await client.initialize(); + assert(client.targetTcpProxiesStub); + }); + + it('has close method for the initialized client', done => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.targetTcpProxiesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.targetTcpProxiesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + 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 targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_tcp_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_tcp_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_tcp_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_tcp_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetTcpProxy() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_tcp_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetTcpProxy() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetTcpProxy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_tcp_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('setBackendService', () => { + it('invokes setBackendService without error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetBackendServiceTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackendServiceTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackendServiceTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_tcp_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setBackendService = stubSimpleCall(expectedResponse); + const [response] = await client.setBackendService(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setBackendService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setBackendService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setBackendService without error using callback', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetBackendServiceTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackendServiceTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackendServiceTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_tcp_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setBackendService = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setBackendService( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setBackendService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setBackendService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setBackendService with error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetBackendServiceTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackendServiceTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackendServiceTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_tcp_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setBackendService = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setBackendService(request), expectedError); + const actualRequest = (client.innerApiCalls.setBackendService as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setBackendService as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setBackendService with closed client', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetBackendServiceTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackendServiceTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetBackendServiceTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setBackendService(request), expectedError); + }); + }); + + describe('setProxyHeader', () => { + it('invokes setProxyHeader without error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetProxyHeaderTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetProxyHeaderTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetProxyHeaderTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_tcp_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setProxyHeader = stubSimpleCall(expectedResponse); + const [response] = await client.setProxyHeader(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setProxyHeader as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setProxyHeader as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setProxyHeader without error using callback', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetProxyHeaderTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetProxyHeaderTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetProxyHeaderTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_tcp_proxy=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setProxyHeader = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setProxyHeader( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setProxyHeader as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setProxyHeader as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setProxyHeader with error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetProxyHeaderTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetProxyHeaderTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetProxyHeaderTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&target_tcp_proxy=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setProxyHeader = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setProxyHeader(request), expectedError); + const actualRequest = (client.innerApiCalls.setProxyHeader as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setProxyHeader as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setProxyHeader with closed client', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetProxyHeaderTargetTcpProxyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetProxyHeaderTargetTcpProxyRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetProxyHeaderTargetTcpProxyRequest', ['targetTcpProxy']); + request.targetTcpProxy = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setProxyHeader(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListTargetTcpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListTargetTcpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxiesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxiesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxiesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.ITargetTcpProxiesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListTargetTcpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListTargetTcpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.ITargetTcpProxiesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetTcpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetTcpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetTcpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetTcpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetTcpProxy[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetTcpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetTcpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetTcpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetTcpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetTcpProxy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetTcpProxy) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetTcpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetTcpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetTcpProxy[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetTcpProxy) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetTcpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetTcpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetTcpProxy()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ITargetTcpProxy[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new targettcpproxiesModule.v1.TargetTcpProxiesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetTcpProxiesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetTcpProxiesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ITargetTcpProxy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_vpn_gateways_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_vpn_gateways_v1.ts new file mode 100644 index 00000000000..7b2f8f68419 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_target_vpn_gateways_v1.ts @@ -0,0 +1,1062 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as targetvpngatewaysModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.TargetVpnGatewaysClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = targetvpngatewaysModule.v1.TargetVpnGatewaysClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = targetvpngatewaysModule.v1.TargetVpnGatewaysClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = targetvpngatewaysModule.v1.TargetVpnGatewaysClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.targetVpnGatewaysStub, undefined); + await client.initialize(); + assert(client.targetVpnGatewaysStub); + }); + + it('has close method for the initialized client', done => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.targetVpnGatewaysStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.targetVpnGatewaysStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + 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 targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetVpnGatewayRequest', ['targetVpnGateway']); + request.targetVpnGateway = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_vpn_gateway=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetVpnGatewayRequest', ['targetVpnGateway']); + request.targetVpnGateway = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_vpn_gateway=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetVpnGatewayRequest', ['targetVpnGateway']); + request.targetVpnGateway = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_vpn_gateway=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteTargetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteTargetVpnGatewayRequest', ['targetVpnGateway']); + request.targetVpnGateway = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetVpnGatewayRequest', ['targetVpnGateway']); + request.targetVpnGateway = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_vpn_gateway=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetVpnGateway() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetVpnGatewayRequest', ['targetVpnGateway']); + request.targetVpnGateway = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_vpn_gateway=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TargetVpnGateway() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetVpnGateway|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetVpnGatewayRequest', ['targetVpnGateway']); + request.targetVpnGateway = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&target_vpn_gateway=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetTargetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetTargetVpnGatewayRequest', ['targetVpnGateway']); + request.targetVpnGateway = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertTargetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertTargetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('setLabels', () => { + it('invokes setLabels without error', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsTargetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsTargetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsTargetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsTargetVpnGatewayRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCall(expectedResponse); + const [response] = await client.setLabels(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels without error using callback', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsTargetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsTargetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsTargetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsTargetVpnGatewayRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setLabels( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with error', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsTargetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsTargetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsTargetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsTargetVpnGatewayRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setLabels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with closed client', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsTargetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsTargetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsTargetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsTargetVpnGatewayRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setLabels(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListTargetVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListTargetVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.TargetVpnGatewaysScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.TargetVpnGatewaysScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.TargetVpnGatewaysScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.ITargetVpnGatewaysScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListTargetVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListTargetVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.ITargetVpnGatewaysScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetVpnGatewaysRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetVpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetVpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetVpnGateway()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetVpnGatewaysRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetVpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetVpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetVpnGateway()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITargetVpnGateway[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetVpnGatewaysRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetVpnGatewaysRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetVpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetVpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetVpnGateway()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetVpnGateway[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetVpnGateway) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetVpnGatewaysRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.TargetVpnGateway[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.TargetVpnGateway) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetVpnGatewaysRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.TargetVpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetVpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.TargetVpnGateway()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.ITargetVpnGateway[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new targetvpngatewaysModule.v1.TargetVpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListTargetVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListTargetVpnGatewaysRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.ITargetVpnGateway[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_url_maps_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_url_maps_v1.ts new file mode 100644 index 00000000000..a56a7a3d1eb --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_url_maps_v1.ts @@ -0,0 +1,1353 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as urlmapsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.UrlMapsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = urlmapsModule.v1.UrlMapsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = urlmapsModule.v1.UrlMapsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = urlmapsModule.v1.UrlMapsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new urlmapsModule.v1.UrlMapsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.urlMapsStub, undefined); + await client.initialize(); + assert(client.urlMapsStub); + }); + + it('has close method for the initialized client', done => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.urlMapsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.urlMapsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + 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 urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.UrlMap() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.UrlMap() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IUrlMap|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertUrlMapRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertUrlMapRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertUrlMapRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertUrlMapRequest', ['project']); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('invalidateCache', () => { + it('invokes invalidateCache without error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InvalidateCacheUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InvalidateCacheUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InvalidateCacheUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.invalidateCache = stubSimpleCall(expectedResponse); + const [response] = await client.invalidateCache(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.invalidateCache as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.invalidateCache as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes invalidateCache without error using callback', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InvalidateCacheUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InvalidateCacheUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InvalidateCacheUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.invalidateCache = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.invalidateCache( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.invalidateCache as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.invalidateCache as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes invalidateCache with error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InvalidateCacheUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InvalidateCacheUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InvalidateCacheUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.invalidateCache = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.invalidateCache(request), expectedError); + const actualRequest = (client.innerApiCalls.invalidateCache as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.invalidateCache as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes invalidateCache with closed client', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InvalidateCacheUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InvalidateCacheUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InvalidateCacheUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.invalidateCache(request), expectedError); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.PatchUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.PatchUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.UpdateUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.UpdateUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('validate', () => { + it('invokes validate without error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ValidateUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.UrlMapsValidateResponse() + ); + client.innerApiCalls.validate = stubSimpleCall(expectedResponse); + const [response] = await client.validate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.validate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.validate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes validate without error using callback', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ValidateUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.UrlMapsValidateResponse() + ); + client.innerApiCalls.validate = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.validate( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IUrlMapsValidateResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.validate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.validate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes validate with error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ValidateUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&url_map=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.validate = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.validate(request), expectedError); + const actualRequest = (client.innerApiCalls.validate as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.validate as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes validate with closed client', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ValidateUrlMapRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateUrlMapRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ValidateUrlMapRequest', ['urlMap']); + request.urlMap = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.validate(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListUrlMapsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListUrlMapsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.UrlMapsScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.UrlMapsScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.UrlMapsScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IUrlMapsScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListUrlMapsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListUrlMapsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IUrlMapsScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListUrlMapsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListUrlMapsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListUrlMapsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListUrlMapsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IUrlMap[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListUrlMapsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListUrlMapsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListUrlMapsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListUrlMapsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.UrlMap[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.UrlMap) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListUrlMapsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListUrlMapsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.UrlMap[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.UrlMap) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListUrlMapsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListUrlMapsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + generateSampleMessage(new protos.google.cloud.compute.v1.UrlMap()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IUrlMap[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new urlmapsModule.v1.UrlMapsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListUrlMapsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListUrlMapsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IUrlMap[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_vpn_gateways_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_vpn_gateways_v1.ts new file mode 100644 index 00000000000..0ea52b6774a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_vpn_gateways_v1.ts @@ -0,0 +1,1326 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as vpngatewaysModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.VpnGatewaysClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = vpngatewaysModule.v1.VpnGatewaysClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = vpngatewaysModule.v1.VpnGatewaysClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = vpngatewaysModule.v1.VpnGatewaysClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.vpnGatewaysStub, undefined); + await client.initialize(); + assert(client.vpnGatewaysStub); + }); + + it('has close method for the initialized client', done => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.vpnGatewaysStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.vpnGatewaysStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + 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 vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnGatewayRequest', ['vpnGateway']); + request.vpnGateway = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&vpn_gateway=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnGatewayRequest', ['vpnGateway']); + request.vpnGateway = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&vpn_gateway=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnGatewayRequest', ['vpnGateway']); + request.vpnGateway = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&vpn_gateway=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnGatewayRequest', ['vpnGateway']); + request.vpnGateway = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnGatewayRequest', ['vpnGateway']); + request.vpnGateway = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&vpn_gateway=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.VpnGateway() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnGatewayRequest', ['vpnGateway']); + request.vpnGateway = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&vpn_gateway=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.VpnGateway() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IVpnGateway|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnGatewayRequest', ['vpnGateway']); + request.vpnGateway = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&vpn_gateway=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnGatewayRequest', ['vpnGateway']); + request.vpnGateway = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('getStatus', () => { + it('invokes getStatus without error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetStatusVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetStatusVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetStatusVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetStatusVpnGatewayRequest', ['vpnGateway']); + request.vpnGateway = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&vpn_gateway=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.VpnGatewaysGetStatusResponse() + ); + client.innerApiCalls.getStatus = stubSimpleCall(expectedResponse); + const [response] = await client.getStatus(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getStatus as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getStatus as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getStatus without error using callback', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetStatusVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetStatusVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetStatusVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetStatusVpnGatewayRequest', ['vpnGateway']); + request.vpnGateway = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&vpn_gateway=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.VpnGatewaysGetStatusResponse() + ); + client.innerApiCalls.getStatus = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getStatus( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IVpnGatewaysGetStatusResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getStatus as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getStatus as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getStatus with error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetStatusVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetStatusVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetStatusVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetStatusVpnGatewayRequest', ['vpnGateway']); + request.vpnGateway = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&vpn_gateway=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getStatus = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getStatus(request), expectedError); + const actualRequest = (client.innerApiCalls.getStatus as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getStatus as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getStatus with closed client', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetStatusVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetStatusVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetStatusVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetStatusVpnGatewayRequest', ['vpnGateway']); + request.vpnGateway = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getStatus(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('setLabels', () => { + it('invokes setLabels without error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnGatewayRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCall(expectedResponse); + const [response] = await client.setLabels(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels without error using callback', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnGatewayRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setLabels( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnGatewayRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setLabels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with closed client', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnGatewayRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setLabels(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsVpnGatewayRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsVpnGatewayRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.TestPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.ITestPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsVpnGatewayRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.TestIamPermissionsVpnGatewayRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsVpnGatewayRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsVpnGatewayRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.TestIamPermissionsVpnGatewayRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.VpnGatewaysScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.VpnGatewaysScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.VpnGatewaysScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IVpnGatewaysScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IVpnGatewaysScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnGatewaysRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.VpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.VpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.VpnGateway()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnGatewaysRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.VpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.VpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.VpnGateway()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IVpnGateway[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnGatewaysRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnGatewaysRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.VpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.VpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.VpnGateway()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.VpnGateway[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.VpnGateway) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnGatewaysRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.VpnGateway[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.VpnGateway) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnGatewaysRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.VpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.VpnGateway()), + generateSampleMessage(new protos.google.cloud.compute.v1.VpnGateway()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IVpnGateway[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new vpngatewaysModule.v1.VpnGatewaysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListVpnGatewaysRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnGatewaysRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnGatewaysRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IVpnGateway[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_vpn_tunnels_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_vpn_tunnels_v1.ts new file mode 100644 index 00000000000..e08c0a6850c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_vpn_tunnels_v1.ts @@ -0,0 +1,1062 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as vpntunnelsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.VpnTunnelsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = vpntunnelsModule.v1.VpnTunnelsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = vpntunnelsModule.v1.VpnTunnelsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = vpntunnelsModule.v1.VpnTunnelsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.vpnTunnelsStub, undefined); + await client.initialize(); + assert(client.vpnTunnelsStub); + }); + + it('has close method for the initialized client', done => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.vpnTunnelsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.vpnTunnelsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + 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 vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteVpnTunnelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnTunnelRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnTunnelRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnTunnelRequest', ['vpnTunnel']); + request.vpnTunnel = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&vpn_tunnel=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteVpnTunnelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnTunnelRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnTunnelRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnTunnelRequest', ['vpnTunnel']); + request.vpnTunnel = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&vpn_tunnel=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteVpnTunnelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnTunnelRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnTunnelRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnTunnelRequest', ['vpnTunnel']); + request.vpnTunnel = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&vpn_tunnel=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteVpnTunnelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnTunnelRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnTunnelRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteVpnTunnelRequest', ['vpnTunnel']); + request.vpnTunnel = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetVpnTunnelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnTunnelRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnTunnelRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnTunnelRequest', ['vpnTunnel']); + request.vpnTunnel = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&vpn_tunnel=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.VpnTunnel() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetVpnTunnelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnTunnelRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnTunnelRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnTunnelRequest', ['vpnTunnel']); + request.vpnTunnel = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&vpn_tunnel=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.VpnTunnel() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IVpnTunnel|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetVpnTunnelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnTunnelRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnTunnelRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnTunnelRequest', ['vpnTunnel']); + request.vpnTunnel = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&vpn_tunnel=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetVpnTunnelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnTunnelRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnTunnelRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetVpnTunnelRequest', ['vpnTunnel']); + request.vpnTunnel = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertVpnTunnelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertVpnTunnelRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertVpnTunnelRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertVpnTunnelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertVpnTunnelRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertVpnTunnelRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertVpnTunnelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertVpnTunnelRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertVpnTunnelRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.InsertVpnTunnelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertVpnTunnelRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.InsertVpnTunnelRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('setLabels', () => { + it('invokes setLabels without error', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsVpnTunnelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnTunnelRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnTunnelRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnTunnelRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCall(expectedResponse); + const [response] = await client.setLabels(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels without error using callback', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsVpnTunnelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnTunnelRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnTunnelRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnTunnelRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.setLabels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setLabels( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with error', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsVpnTunnelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnTunnelRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnTunnelRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnTunnelRequest', ['resource']); + request.resource = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&resource=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setLabels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setLabels(request), expectedError); + const actualRequest = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setLabels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setLabels with closed client', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.SetLabelsVpnTunnelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnTunnelRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnTunnelRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.SetLabelsVpnTunnelRequest', ['resource']); + request.resource = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setLabels(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListVpnTunnelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListVpnTunnelsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1.VpnTunnelsScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1.VpnTunnelsScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1.VpnTunnelsScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1.IVpnTunnelsScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.AggregatedListVpnTunnelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.AggregatedListVpnTunnelsRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1.IVpnTunnelsScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListVpnTunnelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnTunnelsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnTunnelsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.VpnTunnel()), + generateSampleMessage(new protos.google.cloud.compute.v1.VpnTunnel()), + generateSampleMessage(new protos.google.cloud.compute.v1.VpnTunnel()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListVpnTunnelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnTunnelsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnTunnelsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.VpnTunnel()), + generateSampleMessage(new protos.google.cloud.compute.v1.VpnTunnel()), + generateSampleMessage(new protos.google.cloud.compute.v1.VpnTunnel()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IVpnTunnel[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListVpnTunnelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnTunnelsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnTunnelsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListVpnTunnelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnTunnelsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnTunnelsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.VpnTunnel()), + generateSampleMessage(new protos.google.cloud.compute.v1.VpnTunnel()), + generateSampleMessage(new protos.google.cloud.compute.v1.VpnTunnel()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.VpnTunnel[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.VpnTunnel) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListVpnTunnelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnTunnelsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnTunnelsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.VpnTunnel[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.VpnTunnel) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListVpnTunnelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnTunnelsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnTunnelsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.VpnTunnel()), + generateSampleMessage(new protos.google.cloud.compute.v1.VpnTunnel()), + generateSampleMessage(new protos.google.cloud.compute.v1.VpnTunnel()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IVpnTunnel[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new vpntunnelsModule.v1.VpnTunnelsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListVpnTunnelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnTunnelsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListVpnTunnelsRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IVpnTunnel[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_zone_operations_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_zone_operations_v1.ts new file mode 100644 index 00000000000..3f20b014d1c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_zone_operations_v1.ts @@ -0,0 +1,870 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as zoneoperationsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.ZoneOperationsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = zoneoperationsModule.v1.ZoneOperationsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = zoneoperationsModule.v1.ZoneOperationsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = zoneoperationsModule.v1.ZoneOperationsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.zoneOperationsStub, undefined); + await client.initialize(); + assert(client.zoneOperationsStub); + }); + + it('has close method for the initialized client', done => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.zoneOperationsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.zoneOperationsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + 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 zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteZoneOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteZoneOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteZoneOperationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteZoneOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&operation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteZoneOperationResponse() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteZoneOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteZoneOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteZoneOperationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteZoneOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&operation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteZoneOperationResponse() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IDeleteZoneOperationResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteZoneOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteZoneOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteZoneOperationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteZoneOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&operation=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.DeleteZoneOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteZoneOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteZoneOperationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.DeleteZoneOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetZoneOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneOperationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&operation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetZoneOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneOperationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&operation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetZoneOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneOperationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&operation=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetZoneOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneOperationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('wait', () => { + it('invokes wait without error', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.WaitZoneOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitZoneOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitZoneOperationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitZoneOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&operation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.wait = stubSimpleCall(expectedResponse); + const [response] = await client.wait(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes wait without error using callback', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.WaitZoneOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitZoneOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitZoneOperationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitZoneOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&operation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Operation() + ); + client.innerApiCalls.wait = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.wait( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes wait with error', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.WaitZoneOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitZoneOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitZoneOperationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitZoneOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}&operation=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.wait = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.wait(request), expectedError); + const actualRequest = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes wait with closed client', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.WaitZoneOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitZoneOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitZoneOperationRequest', ['zone']); + request.zone = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1.WaitZoneOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.wait(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListZoneOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZoneOperationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZoneOperationsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListZoneOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZoneOperationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZoneOperationsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IOperation[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListZoneOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZoneOperationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZoneOperationsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListZoneOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZoneOperationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZoneOperationsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Operation[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Operation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListZoneOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZoneOperationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZoneOperationsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Operation[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Operation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListZoneOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZoneOperationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZoneOperationsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + generateSampleMessage(new protos.google.cloud.compute.v1.Operation()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IOperation[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new zoneoperationsModule.v1.ZoneOperationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListZoneOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZoneOperationsRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZoneOperationsRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/test/gapic_zones_v1.ts b/owl-bot-staging/google-cloud-compute/v1/test/gapic_zones_v1.ts new file mode 100644 index 00000000000..fd0dde21d47 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/test/gapic_zones_v1.ts @@ -0,0 +1,573 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as zonesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1.ZonesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = zonesModule.v1.ZonesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = zonesModule.v1.ZonesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = zonesModule.v1.ZonesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new zonesModule.v1.ZonesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new zonesModule.v1.ZonesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new zonesModule.v1.ZonesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.zonesStub, undefined); + await client.initialize(); + assert(client.zonesStub); + }); + + it('has close method for the initialized client', done => { + const client = new zonesModule.v1.ZonesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.zonesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new zonesModule.v1.ZonesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.zonesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new zonesModule.v1.ZonesClient({ + auth: googleAuth, + 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 zonesModule.v1.ZonesClient({ + auth: googleAuth, + 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('get', () => { + it('invokes get without error', async () => { + const client = new zonesModule.v1.ZonesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetZoneRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Zone() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new zonesModule.v1.ZonesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetZoneRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1.Zone() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IZone|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new zonesModule.v1.ZonesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetZoneRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneRequest', ['zone']); + request.zone = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}&zone=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new zonesModule.v1.ZonesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.GetZoneRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1.GetZoneRequest', ['zone']); + request.zone = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new zonesModule.v1.ZonesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListZonesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZonesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Zone()), + generateSampleMessage(new protos.google.cloud.compute.v1.Zone()), + generateSampleMessage(new protos.google.cloud.compute.v1.Zone()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new zonesModule.v1.ZonesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListZonesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZonesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Zone()), + generateSampleMessage(new protos.google.cloud.compute.v1.Zone()), + generateSampleMessage(new protos.google.cloud.compute.v1.Zone()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1.IZone[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new zonesModule.v1.ZonesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListZonesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZonesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new zonesModule.v1.ZonesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListZonesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZonesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Zone()), + generateSampleMessage(new protos.google.cloud.compute.v1.Zone()), + generateSampleMessage(new protos.google.cloud.compute.v1.Zone()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Zone[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Zone) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new zonesModule.v1.ZonesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListZonesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZonesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1.Zone[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1.Zone) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new zonesModule.v1.ZonesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListZonesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZonesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1.Zone()), + generateSampleMessage(new protos.google.cloud.compute.v1.Zone()), + generateSampleMessage(new protos.google.cloud.compute.v1.Zone()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1.IZone[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new zonesModule.v1.ZonesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1.ListZonesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1.ListZonesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1.IZone[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1/tsconfig.json b/owl-bot-staging/google-cloud-compute/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-compute/v1/webpack.config.js b/owl-bot-staging/google-cloud-compute/v1/webpack.config.js new file mode 100644 index 00000000000..41891302b1d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 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. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'AcceleratorTypes', + filename: './accelerator-types.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/owl-bot-staging/google-cloud-compute/v1small/.eslintignore b/owl-bot-staging/google-cloud-compute/v1small/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-compute/v1small/.eslintrc.json b/owl-bot-staging/google-cloud-compute/v1small/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-compute/v1small/.gitignore b/owl-bot-staging/google-cloud-compute/v1small/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-compute/v1small/.jsdoc.js b/owl-bot-staging/google-cloud-compute/v1small/.jsdoc.js new file mode 100644 index 00000000000..6a4f1a5196c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 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'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2023 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/compute-small', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-compute/v1small/.mocharc.js b/owl-bot-staging/google-cloud-compute/v1small/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 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. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/google-cloud-compute/v1small/.prettierrc.js b/owl-bot-staging/google-cloud-compute/v1small/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 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. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-compute/v1small/README.md b/owl-bot-staging/google-cloud-compute/v1small/README.md new file mode 100644 index 00000000000..3383cb94ba5 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/README.md @@ -0,0 +1 @@ +Compute: Nodejs Client diff --git a/owl-bot-staging/google-cloud-compute/v1small/linkinator.config.json b/owl-bot-staging/google-cloud-compute/v1small/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/google-cloud-compute/v1small/package.json b/owl-bot-staging/google-cloud-compute/v1small/package.json new file mode 100644 index 00000000000..90b2a6444a0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/compute-small", + "version": "0.1.0", + "description": "Compute client for Node.js", + "repository": "googleapis/nodejs-compute", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google compute", + "compute", + "addresses", + "region operations" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1small/protos/google/cloud/compute/v1small/compute_small.proto b/owl-bot-staging/google-cloud-compute/v1small/protos/google/cloud/compute/v1small/compute_small.proto new file mode 100644 index 00000000000..a7fbb4d6bad --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/protos/google/cloud/compute/v1small/compute_small.proto @@ -0,0 +1,740 @@ +// Copyright 2020 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. + +// Generated by the disco-to-proto3-converter. DO NOT EDIT! +// Source Discovery file: compute.v1small.json +// Source file revision: 20200302 +// API name: compute +// API version: v1small + +syntax = "proto3"; + +package google.cloud.compute.v1small; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/extended_operations.proto"; + +// +// File Options +// +option csharp_namespace = "Google.Cloud.Compute.V1Small"; +option go_package = "google.golang.org/genproto/googleapis/cloud/compute/v1small;compute"; +option java_multiple_files = true; +option java_package = "com.google.cloud.compute.v1small"; +option php_namespace = "Google\\Cloud\\Compute\\V1small"; +option ruby_package = "Google::Cloud::Compute::V1small"; + +// +// Messages +// +// Use global external addresses for GFE-based external HTTP(S) load balancers in Premium Tier. +// +// Use global internal addresses for reserved peering network range. +// +// Use regional external addresses for the following resources: +// +// - External IP addresses for VM instances - Regional external forwarding rules - Cloud NAT external IP addresses - GFE based LBs in Standard Tier - Network LBs in Premium or Standard Tier - Cloud VPN gateways (both Classic and HA) +// +// Use regional internal IP addresses for subnet IP ranges (primary and secondary). This includes: +// +// - Internal IP addresses for VM instances - Alias IP ranges of VM instances (/32 only) - Regional internal forwarding rules - Internal TCP/UDP load balancer addresses - Internal HTTP(S) load balancer addresses - Cloud DNS inbound forwarding IP addresses +// +// For more information, read reserved IP address. +// +// (== resource_for {$api_version}.addresses ==) (== resource_for {$api_version}.globalAddresses ==) +message Address { + // The type of address to reserve, either INTERNAL or EXTERNAL. If unspecified, defaults to EXTERNAL. + enum AddressType { + // A value indicating that the enum field is not set. + UNDEFINED_ADDRESS_TYPE = 0; + + EXTERNAL = 35607499; + + INTERNAL = 279295677; + + UNSPECIFIED_TYPE = 53933922; + + } + + // The IP version that will be used by this address. Valid options are IPV4 or IPV6. This can only be specified for a global address. + enum IpVersion { + // A value indicating that the enum field is not set. + UNDEFINED_IP_VERSION = 0; + + IPV4 = 2254341; + + IPV6 = 2254343; + + UNSPECIFIED_VERSION = 21850000; + + } + + // This signifies the networking tier used for configuring this address and can only take the following values: PREMIUM or STANDARD. Global forwarding rules can only be Premium Tier. Regional forwarding rules can be either Premium or Standard Tier. Standard Tier addresses applied to regional forwarding rules can be used with any external load balancer. Regional forwarding rules in Premium Tier can only be used with a network load balancer. + // + // If this field is not specified, it is assumed to be PREMIUM. + enum NetworkTier { + // A value indicating that the enum field is not set. + UNDEFINED_NETWORK_TIER = 0; + + PREMIUM = 399530551; + + STANDARD = 484642493; + + } + + // The purpose of this resource, which can be one of the following values: + // - `GCE_ENDPOINT` for addresses that are used by VM instances, alias IP ranges, internal load balancers, and similar resources. + // - `DNS_RESOLVER` for a DNS resolver address in a subnetwork + // - `VPC_PEERING` for addresses that are reserved for VPC peer networks. + // - `NAT_AUTO` for addresses that are external IP addresses automatically reserved for Cloud NAT. + enum Purpose { + // A value indicating that the enum field is not set. + UNDEFINED_PURPOSE = 0; + + DNS_RESOLVER = 476114556; + + GCE_ENDPOINT = 230515243; + + NAT_AUTO = 163666477; + + VPC_PEERING = 400800170; + + } + + // [Output Only] The status of the address, which can be one of RESERVING, RESERVED, or IN_USE. An address that is RESERVING is currently in the process of being reserved. A RESERVED address is currently reserved and available to use. An IN_USE address is currently being used by another resource and is not available. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + IN_USE = 17393485; + + RESERVED = 432241448; + + RESERVING = 514587225; + + } + + // The static IP address represented by this resource. + optional string address = 462920692; + + // The type of address to reserve, either INTERNAL or EXTERNAL. If unspecified, defaults to EXTERNAL. + // Check the AddressType enum for the list of possible values. + optional string address_type = 264307877; + + // [Output Only] Creation timestamp in RFC3339 text format. + optional string creation_timestamp = 30525366; + + // An optional description of this resource. Provide this field when you create the resource. + optional string description = 422937596; + + // [Output Only] The unique identifier for the resource. This identifier is defined by the server. + optional uint64 id = 3355; + + // The IP version that will be used by this address. Valid options are IPV4 or IPV6. This can only be specified for a global address. + // Check the IpVersion enum for the list of possible values. + optional string ip_version = 294959552; + + // [Output Only] Type of the resource. Always compute#address for addresses. + optional string kind = 3292052; + + // Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`. The first character must be a lowercase letter, and all following characters (except for the last character) must be a dash, lowercase letter, or digit. The last character must be a lowercase letter or digit. + optional string name = 3373707; + + // The URL of the network in which to reserve the address. This field can only be used with INTERNAL type with the VPC_PEERING purpose. + optional string network = 232872494; + + // This signifies the networking tier used for configuring this address and can only take the following values: PREMIUM or STANDARD. Global forwarding rules can only be Premium Tier. Regional forwarding rules can be either Premium or Standard Tier. Standard Tier addresses applied to regional forwarding rules can be used with any external load balancer. Regional forwarding rules in Premium Tier can only be used with a network load balancer. + // + // If this field is not specified, it is assumed to be PREMIUM. + // Check the NetworkTier enum for the list of possible values. + optional string network_tier = 517397843; + + // The prefix length if the resource reprensents an IP range. + optional int32 prefix_length = 453565747; + + // The purpose of this resource, which can be one of the following values: + // - `GCE_ENDPOINT` for addresses that are used by VM instances, alias IP ranges, internal load balancers, and similar resources. + // - `DNS_RESOLVER` for a DNS resolver address in a subnetwork + // - `VPC_PEERING` for addresses that are reserved for VPC peer networks. + // - `NAT_AUTO` for addresses that are external IP addresses automatically reserved for Cloud NAT. + // Check the Purpose enum for the list of possible values. + optional string purpose = 316407070; + + // [Output Only] The URL of the region where the regional address resides. This field is not applicable to global addresses. You must specify this field as part of the HTTP request URL. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] The status of the address, which can be one of RESERVING, RESERVED, or IN_USE. An address that is RESERVING is currently in the process of being reserved. A RESERVED address is currently reserved and available to use. An IN_USE address is currently being used by another resource and is not available. + // Check the Status enum for the list of possible values. + optional string status = 181260274; + + // The URL of the subnetwork in which to reserve the address. If an IP address is specified, it must be within the subnetwork's IP range. This field can only be used with INTERNAL type with a GCE_ENDPOINT or DNS_RESOLVER purpose. + optional string subnetwork = 307827694; + + // [Output Only] The URLs of the resources that are using this address. + repeated string users = 111578632; + +} + +// +message AddressAggregatedList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of AddressesScopedList resources. + map items = 100526016; + + // [Output Only] Type of resource. Always compute#addressAggregatedList for aggregated lists of addresses. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// Contains a list of addresses. +message AddressList { + // [Output Only] Unique identifier for the resource; defined by the server. + optional string id = 3355; + + // A list of Address resources. + repeated Address items = 100526016; + + // [Output Only] Type of resource. Always compute#addressList for lists of addresses. + optional string kind = 3292052; + + // [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. + optional string next_page_token = 79797525; + + // [Output Only] Server-defined URL for this resource. + optional string self_link = 456214797; + + // [Output Only] Informational warning message. + optional Warning warning = 50704284; + +} + +// +message AddressesScopedList { + // [Output Only] A list of addresses contained in this scope. + repeated Address addresses = 337673122; + + // [Output Only] Informational warning which replaces the list of addresses when the list is empty. + optional Warning warning = 50704284; + +} + +// A request message for Addresses.AggregatedList. See the method description for details. +message AggregatedListAddressesRequest { + // A filter expression that filters resources listed in the response. The expression must specify the field name, a comparison operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The comparison operator must be either `=`, `!=`, `>`, or `<`. + // + // For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. + // + // You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. + // + // To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` + optional string filter = 336120696; + + // Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + optional bool include_all_scopes = 391327988; + + // The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. + // + // You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. + // + // Currently, only sorting by `name` or `creationTimestamp desc` is supported. + optional string order_by = 160562920; + + // Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + +} + +// +message Data { + // [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding). + optional string key = 106079; + + // [Output Only] A warning data value corresponding to the key. + optional string value = 111972721; + +} + +// A request message for Addresses.Delete. See the method description for details. +message DeleteAddressRequest { + // Name of the address resource to delete. + string address = 462920692 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. + // + // For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. + // + // The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// [Output Only] If errors are generated during processing of the operation, this field will be populated. +message Error { + // [Output Only] The array of errors encountered while processing this operation. + repeated Errors errors = 315977579; + +} + +// +message Errors { + // [Output Only] The error type identifier for this error. + optional string code = 3059181; + + // [Output Only] Indicates the field in the request that caused the error. This property is optional. + optional string location = 290430901; + + // [Output Only] An optional, human-readable error message. + optional string message = 418054151; + +} + +// A request message for RegionOperations.Get. See the method description for details. +message GetRegionOperationRequest { + // Name of the Operations resource to return. + string operation = 52090215 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_response_field) = "name" + ]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// A request message for Addresses.Insert. See the method description for details. +message InsertAddressRequest { + // The body resource for this request + Address address_resource = 483888121 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "project" + ]; + + // Name of the region for this request. + string region = 138946292 [ + (google.api.field_behavior) = REQUIRED, + (google.cloud.operation_request_field) = "region" + ]; + + // An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. + // + // For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. + // + // The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000). + optional string request_id = 37109963; + +} + +// A request message for Addresses.List. See the method description for details. +message ListAddressesRequest { + // A filter expression that filters resources listed in the response. The expression must specify the field name, a comparison operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The comparison operator must be either =, !=, >, or <. + // + // For example, if you are filtering Compute Engine instances, you can exclude instances named example-instance by specifying name != example-instance. + // + // You can also filter nested fields. For example, you could specify scheduling.automaticRestart = false to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. + // + // To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake"). By default, each expression is an AND expression. However, you can include AND and OR expressions explicitly. For example, (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true). + optional string filter = 336120696; + + // The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. Acceptable values are 0 to 500, inclusive. (Default: 500) + optional uint32 max_results = 54715419; + + // Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. + // + // You can also sort results in descending order based on the creation timestamp using orderBy="creationTimestamp desc". This sorts results based on the creationTimestamp field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. + // + // Currently, only sorting by name or creationTimestamp desc is supported. + string order_by = 160562920 [(google.api.field_behavior) = REQUIRED]; + + // Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. + optional string page_token = 19994697; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// Represents an Operation resource. +// +// Google Compute Engine has three Operation resources: +// +// * [Global](/compute/docs/reference/rest/{$api_version}/globalOperations) * [Regional](/compute/docs/reference/rest/{$api_version}/regionOperations) * [Zonal](/compute/docs/reference/rest/{$api_version}/zoneOperations) +// +// You can use an operation resource to manage asynchronous API requests. For more information, read Handling API responses. +// +// Operations can be global, regional or zonal. +// - For global operations, use the globalOperations resource. +// - For regional operations, use the regionOperations resource. +// - For zonal operations, use the zoneOperations resource. +// +// For more information, read Global, Regional, and Zonal Resources. (== resource_for {$api_version}.globalOperations ==) (== resource_for {$api_version}.regionOperations ==) (== resource_for {$api_version}.zoneOperations ==) +message Operation { + // [Output Only] The status of the operation, which can be one of the following: PENDING, RUNNING, or DONE. + enum Status { + // A value indicating that the enum field is not set. + UNDEFINED_STATUS = 0; + + DONE = 2104194; + + PENDING = 35394935; + + RUNNING = 121282975; + + } + + // [Output Only] The value of `requestId` if you provided it in the request. Not present otherwise. + optional string client_operation_id = 297240295; + + // [Deprecated] This field is deprecated. + optional string creation_timestamp = 30525366; + + // [Output Only] A textual description of the operation, which is set when the operation is created. + optional string description = 422937596; + + // [Output Only] The time that this operation was completed. This value is in RFC3339 text format. + optional string end_time = 114938801; + + // [Output Only] If errors are generated during processing of the operation, this field will be populated. + optional Error error = 96784904; + + // [Output Only] If the operation fails, this field contains the HTTP error message that was returned, such as NOT FOUND. + optional string http_error_message = 202521945 [(google.cloud.operation_field) = ERROR_MESSAGE]; + + // [Output Only] If the operation fails, this field contains the HTTP error status code that was returned. For example, a 404 means the resource was not found. + optional int32 http_error_status_code = 312345196 [(google.cloud.operation_field) = ERROR_CODE]; + + // [Output Only] The unique identifier for the operation. This identifier is defined by the server. + optional uint64 id = 3355; + + // [Output Only] The time that this operation was requested. This value is in RFC3339 text format. + optional string insert_time = 433722515; + + // [Output Only] Type of the resource. Always compute#operation for Operation resources. + optional string kind = 3292052; + + // [Output Only] Name of the operation. + optional string name = 3373707 [(google.cloud.operation_field) = NAME]; + + // [Output Only] The type of operation, such as insert, update, or delete, and so on. + optional string operation_type = 177650450; + + // [Output Only] An optional progress indicator that ranges from 0 to 100. There is no requirement that this be linear or support any granularity of operations. This should not be used to guess when the operation will be complete. This number should monotonically increase as the operation progresses. + optional int32 progress = 72663597; + + // [Output Only] The URL of the region where the operation resides. Only applicable when performing regional operations. + optional string region = 138946292; + + // [Output Only] Server-defined URL for the resource. + optional string self_link = 456214797; + + // [Output Only] The time that this operation was started by the server. This value is in RFC3339 text format. + optional string start_time = 37467274; + + // [Output Only] The status of the operation, which can be one of the following: PENDING, RUNNING, or DONE. + optional Status status = 181260274 [(google.cloud.operation_field) = STATUS]; + + // [Output Only] An optional textual description of the current status of the operation. + optional string status_message = 297428154; + + // [Output Only] The unique target ID, which identifies a specific incarnation of the target resource. + optional uint64 target_id = 258165385; + + // [Output Only] The URL of the resource that the operation modifies. For operations related to creating a snapshot, this points to the persistent disk that the snapshot was created from. + optional string target_link = 62671336; + + // [Output Only] User who requested the operation, for example: user@example.com. + optional string user = 3599307; + + // [Output Only] If warning messages are generated during processing of the operation, this field will be populated. + repeated Warnings warnings = 498091095; + + // [Output Only] The URL of the zone where the operation resides. Only applicable when performing per-zone operations. + optional string zone = 3744684; + +} + +// A request message for RegionOperations.Wait. See the method description for details. +message WaitRegionOperationRequest { + // Name of the Operations resource to return. + string operation = 52090215 [(google.api.field_behavior) = REQUIRED]; + + // Project ID for this request. + string project = 227560217 [(google.api.field_behavior) = REQUIRED]; + + // Name of the region for this request. + string region = 138946292 [(google.api.field_behavior) = REQUIRED]; + +} + +// [Output Only] Informational warning message. +message Warning { + // [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. + enum Code { + // A value indicating that the enum field is not set. + UNDEFINED_CODE = 0; + + CLEANUP_FAILED = 150308440; + + DEPRECATED_RESOURCE_USED = 391835586; + + DEPRECATED_TYPE_USED = 346526230; + + DISK_SIZE_LARGER_THAN_IMAGE_SIZE = 369442967; + + EXPERIMENTAL_TYPE_USED = 451954443; + + EXTERNAL_API_WARNING = 175546307; + + FIELD_VALUE_OVERRIDEN = 329669423; + + INJECTED_KERNELS_DEPRECATED = 417377419; + + MISSING_TYPE_DEPENDENCY = 344505463; + + NEXT_HOP_ADDRESS_NOT_ASSIGNED = 324964999; + + NEXT_HOP_CANNOT_IP_FORWARD = 383382887; + + NEXT_HOP_INSTANCE_NOT_FOUND = 464250446; + + NEXT_HOP_INSTANCE_NOT_ON_NETWORK = 243758146; + + NEXT_HOP_NOT_RUNNING = 417081265; + + NOT_CRITICAL_ERROR = 105763924; + + NO_RESULTS_ON_PAGE = 30036744; + + REQUIRED_TOS_AGREEMENT = 3745539; + + RESOURCE_IN_USE_BY_OTHER_RESOURCE_WARNING = 496728641; + + RESOURCE_NOT_DELETED = 168598460; + + SCHEMA_VALIDATION_IGNORED = 275245642; + + SINGLE_INSTANCE_PROPERTY_TEMPLATE = 268305617; + + UNDECLARED_PROPERTIES = 390513439; + + UNREACHABLE = 13328052; + + } + + // [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. + // Check the Code enum for the list of possible values. + optional string code = 3059181; + + // [Output Only] Metadata about this warning in key: value format. For example: + // "data": [ { "key": "scope", "value": "zones/us-east1-d" } + repeated Data data = 3076010; + + // [Output Only] A human-readable description of the warning code. + optional string message = 418054151; + +} + +// +message Warnings { + // [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. + enum Code { + // A value indicating that the enum field is not set. + UNDEFINED_CODE = 0; + + CLEANUP_FAILED = 150308440; + + DEPRECATED_RESOURCE_USED = 391835586; + + DEPRECATED_TYPE_USED = 346526230; + + DISK_SIZE_LARGER_THAN_IMAGE_SIZE = 369442967; + + EXPERIMENTAL_TYPE_USED = 451954443; + + EXTERNAL_API_WARNING = 175546307; + + FIELD_VALUE_OVERRIDEN = 329669423; + + INJECTED_KERNELS_DEPRECATED = 417377419; + + MISSING_TYPE_DEPENDENCY = 344505463; + + NEXT_HOP_ADDRESS_NOT_ASSIGNED = 324964999; + + NEXT_HOP_CANNOT_IP_FORWARD = 383382887; + + NEXT_HOP_INSTANCE_NOT_FOUND = 464250446; + + NEXT_HOP_INSTANCE_NOT_ON_NETWORK = 243758146; + + NEXT_HOP_NOT_RUNNING = 417081265; + + NOT_CRITICAL_ERROR = 105763924; + + NO_RESULTS_ON_PAGE = 30036744; + + REQUIRED_TOS_AGREEMENT = 3745539; + + RESOURCE_IN_USE_BY_OTHER_RESOURCE_WARNING = 496728641; + + RESOURCE_NOT_DELETED = 168598460; + + SCHEMA_VALIDATION_IGNORED = 275245642; + + SINGLE_INSTANCE_PROPERTY_TEMPLATE = 268305617; + + UNDECLARED_PROPERTIES = 390513439; + + UNREACHABLE = 13328052; + + } + + // [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. + // Check the Code enum for the list of possible values. + optional string code = 3059181; + + // [Output Only] Metadata about this warning in key: value format. For example: + // "data": [ { "key": "scope", "value": "zones/us-east1-d" } + repeated Data data = 3076010; + + // [Output Only] A human-readable description of the warning code. + optional string message = 418054151; + +} + +// +// Services +// +// The Addresses API. +service Addresses { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves an aggregated list of addresses. + rpc AggregatedList(AggregatedListAddressesRequest) returns (AddressAggregatedList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/aggregated/addresses" + }; + option (google.api.method_signature) = "project"; + } + + // Deletes the specified address resource. + rpc Delete(DeleteAddressRequest) returns (Operation) { + option (google.api.http) = { + delete: "/compute/v1/projects/{project}/regions/{region}/addresses/{address}" + }; + option (google.api.method_signature) = "project,region,address"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Creates an address resource in the specified project by using the data included in the request. + rpc Insert(InsertAddressRequest) returns (Operation) { + option (google.api.http) = { + body: "address_resource" + post: "/compute/v1/projects/{project}/regions/{region}/addresses" + }; + option (google.api.method_signature) = "project,region,address_resource"; + option (google.cloud.operation_service) = "RegionOperations"; + } + + // Retrieves a list of addresses contained within the specified region. + rpc List(ListAddressesRequest) returns (AddressList) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/addresses" + }; + option (google.api.method_signature) = "project,region,order_by"; + } + +} + +// The RegionOperations API. +service RegionOperations { + option (google.api.default_host) = + "compute.googleapis.com"; + + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/compute.readonly," + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/cloud-platform"; + + // Retrieves the specified region-specific Operations resource. + rpc Get(GetRegionOperationRequest) returns (Operation) { + option (google.api.http) = { + get: "/compute/v1/projects/{project}/regions/{region}/operations/{operation}" + }; + option (google.api.method_signature) = "project,region,operation"; + option (google.cloud.operation_polling_method) = true; + } + + // Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the `GET` method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be `DONE` or still in progress. + // + // This method is called on a best-effort basis. Specifically: + // - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. + // - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. + rpc Wait(WaitRegionOperationRequest) returns (Operation) { + option (google.api.http) = { + post: "/compute/v1/projects/projects/{project}/regions/{region}/operations/{operation}/wait" + }; + option (google.api.method_signature) = "project,region,operation"; + } + +} + diff --git a/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/addresses.aggregated_list.js b/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/addresses.aggregated_list.js new file mode 100644 index 00000000000..b8f114be595 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/addresses.aggregated_list.js @@ -0,0 +1,88 @@ +// Copyright 2023 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(project) { + // [START compute_v1small_generated_Addresses_AggregatedList_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. + */ + /** + * A filter expression that filters resources listed in the response. The expression must specify the field name, a comparison operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The comparison operator must be either `=`, `!=`, `>`, or `<`. + * For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. + * You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. + * To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` + */ + // const filter = 'abc123' + /** + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + */ + // const includeAllScopes = true + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. + * You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. + * Currently, only sorting by `name` or `creationTimestamp desc` is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + + // Imports the Compute library + const {AddressesClient} = require('@google-cloud/compute-small').v1small; + + // Instantiates a client + const computeClient = new AddressesClient(); + + async function callAggregatedList() { + // Construct request + const request = { + project, + }; + + // Run request + const iterable = await computeClient.aggregatedListAsync(request); + for await (const [key, value] of iterable) { + console.log(response); + } + } + + callAggregatedList(); + // [END compute_v1small_generated_Addresses_AggregatedList_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/addresses.delete.js b/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/addresses.delete.js new file mode 100644 index 00000000000..6e7f1c6bd67 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/addresses.delete.js @@ -0,0 +1,77 @@ +// Copyright 2023 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(address, project, region) { + // [START compute_v1small_generated_Addresses_Delete_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. + */ + /** + * Name of the address resource to delete. + */ + // const address = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. + * For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {AddressesClient} = require('@google-cloud/compute-small').v1small; + + // Instantiates a client + const computeClient = new AddressesClient(); + + async function callDelete() { + // Construct request + const request = { + address, + project, + region, + }; + + // Run request + const response = await computeClient.delete(request); + console.log(response); + } + + callDelete(); + // [END compute_v1small_generated_Addresses_Delete_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/addresses.insert.js b/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/addresses.insert.js new file mode 100644 index 00000000000..3d4b3b533b0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/addresses.insert.js @@ -0,0 +1,77 @@ +// Copyright 2023 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(addressResource, project, region) { + // [START compute_v1small_generated_Addresses_Insert_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. + */ + /** + * The body resource for this request + */ + // const addressResource = {} + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + /** + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. + * For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Compute library + const {AddressesClient} = require('@google-cloud/compute-small').v1small; + + // Instantiates a client + const computeClient = new AddressesClient(); + + async function callInsert() { + // Construct request + const request = { + addressResource, + project, + region, + }; + + // Run request + const response = await computeClient.insert(request); + console.log(response); + } + + callInsert(); + // [END compute_v1small_generated_Addresses_Insert_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/addresses.list.js b/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/addresses.list.js new file mode 100644 index 00000000000..84fb118fc0a --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/addresses.list.js @@ -0,0 +1,90 @@ +// Copyright 2023 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(orderBy, project, region) { + // [START compute_v1small_generated_Addresses_List_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. + */ + /** + * A filter expression that filters resources listed in the response. The expression must specify the field name, a comparison operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The comparison operator must be either =, !=, >, or <. + * For example, if you are filtering Compute Engine instances, you can exclude instances named example-instance by specifying name != example-instance. + * You can also filter nested fields. For example, you could specify scheduling.automaticRestart = false to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. + * To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake"). By default, each expression is an AND expression. However, you can include AND and OR expressions explicitly. For example, (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true). + */ + // const filter = 'abc123' + /** + * The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. Acceptable values are 0 to 500, inclusive. (Default: 500) + */ + // const maxResults = 1234 + /** + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. + * You can also sort results in descending order based on the creation timestamp using orderBy="creationTimestamp desc". This sorts results based on the creationTimestamp field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. + * Currently, only sorting by name or creationTimestamp desc is supported. + */ + // const orderBy = 'abc123' + /** + * Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. + */ + // const pageToken = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {AddressesClient} = require('@google-cloud/compute-small').v1small; + + // Instantiates a client + const computeClient = new AddressesClient(); + + async function callList() { + // Construct request + const request = { + orderBy, + project, + region, + }; + + // Run request + const iterable = await computeClient.listAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callList(); + // [END compute_v1small_generated_Addresses_List_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/region_operations.get.js b/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/region_operations.get.js new file mode 100644 index 00000000000..839be7f06bd --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/region_operations.get.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(operation, project, region) { + // [START compute_v1small_generated_RegionOperations_Get_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. + */ + /** + * Name of the Operations resource to return. + */ + // const operation = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionOperationsClient} = require('@google-cloud/compute-small').v1small; + + // Instantiates a client + const computeClient = new RegionOperationsClient(); + + async function callGet() { + // Construct request + const request = { + operation, + project, + region, + }; + + // Run request + const response = await computeClient.get(request); + console.log(response); + } + + callGet(); + // [END compute_v1small_generated_RegionOperations_Get_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/region_operations.wait.js b/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/region_operations.wait.js new file mode 100644 index 00000000000..667a0657081 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/region_operations.wait.js @@ -0,0 +1,71 @@ +// Copyright 2023 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(operation, project, region) { + // [START compute_v1small_generated_RegionOperations_Wait_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. + */ + /** + * Name of the Operations resource to return. + */ + // const operation = 'abc123' + /** + * Project ID for this request. + */ + // const project = 'my-project' + /** + * Name of the region for this request. + */ + // const region = 'us-central1' + + // Imports the Compute library + const {RegionOperationsClient} = require('@google-cloud/compute-small').v1small; + + // Instantiates a client + const computeClient = new RegionOperationsClient(); + + async function callWait() { + // Construct request + const request = { + operation, + project, + region, + }; + + // Run request + const response = await computeClient.wait(request); + console.log(response); + } + + callWait(); + // [END compute_v1small_generated_RegionOperations_Wait_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/snippet_metadata.google.cloud.compute.v1small.json b/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/snippet_metadata.google.cloud.compute.v1small.json new file mode 100644 index 00000000000..8ab2078f221 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/samples/generated/v1small/snippet_metadata.google.cloud.compute.v1small.json @@ -0,0 +1,335 @@ +{ + "clientLibrary": { + "name": "nodejs-compute", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.compute.v1small", + "version": "v1small" + } + ] + }, + "snippets": [ + { + "regionTag": "compute_v1small_generated_Addresses_AggregatedList_async", + "title": "Addresses aggregatedList Sample", + "origin": "API_DEFINITION", + "description": " Retrieves an aggregated list of addresses.", + "canonical": true, + "file": "addresses.aggregated_list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1small.Addresses.AggregatedList", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "include_all_scopes", + "type": "TYPE_BOOL" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1small.AddressAggregatedList", + "client": { + "shortName": "AddressesClient", + "fullName": "google.cloud.compute.v1small.AddressesClient" + }, + "method": { + "shortName": "AggregatedList", + "fullName": "google.cloud.compute.v1small.Addresses.AggregatedList", + "service": { + "shortName": "Addresses", + "fullName": "google.cloud.compute.v1small.Addresses" + } + } + } + }, + { + "regionTag": "compute_v1small_generated_Addresses_Delete_async", + "title": "Addresses delete Sample", + "origin": "API_DEFINITION", + "description": " Deletes the specified address resource.", + "canonical": true, + "file": "addresses.delete.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1small.Addresses.Delete", + "async": true, + "parameters": [ + { + "name": "address", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1small.Operation", + "client": { + "shortName": "AddressesClient", + "fullName": "google.cloud.compute.v1small.AddressesClient" + }, + "method": { + "shortName": "Delete", + "fullName": "google.cloud.compute.v1small.Addresses.Delete", + "service": { + "shortName": "Addresses", + "fullName": "google.cloud.compute.v1small.Addresses" + } + } + } + }, + { + "regionTag": "compute_v1small_generated_Addresses_Insert_async", + "title": "Addresses insert Sample", + "origin": "API_DEFINITION", + "description": " Creates an address resource in the specified project by using the data included in the request.", + "canonical": true, + "file": "addresses.insert.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1small.Addresses.Insert", + "async": true, + "parameters": [ + { + "name": "address_resource", + "type": ".google.cloud.compute.v1small.Address" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1small.Operation", + "client": { + "shortName": "AddressesClient", + "fullName": "google.cloud.compute.v1small.AddressesClient" + }, + "method": { + "shortName": "Insert", + "fullName": "google.cloud.compute.v1small.Addresses.Insert", + "service": { + "shortName": "Addresses", + "fullName": "google.cloud.compute.v1small.Addresses" + } + } + } + }, + { + "regionTag": "compute_v1small_generated_Addresses_List_async", + "title": "Addresses list Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a list of addresses contained within the specified region.", + "canonical": true, + "file": "addresses.list.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 82, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "List", + "fullName": "google.cloud.compute.v1small.Addresses.List", + "async": true, + "parameters": [ + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "max_results", + "type": "TYPE_UINT32" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1small.AddressList", + "client": { + "shortName": "AddressesClient", + "fullName": "google.cloud.compute.v1small.AddressesClient" + }, + "method": { + "shortName": "List", + "fullName": "google.cloud.compute.v1small.Addresses.List", + "service": { + "shortName": "Addresses", + "fullName": "google.cloud.compute.v1small.Addresses" + } + } + } + }, + { + "regionTag": "compute_v1small_generated_RegionOperations_Get_async", + "title": "Addresses get Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the specified region-specific Operations resource.", + "canonical": true, + "file": "region_operations.get.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1small.RegionOperations.Get", + "async": true, + "parameters": [ + { + "name": "operation", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1small.Operation", + "client": { + "shortName": "RegionOperationsClient", + "fullName": "google.cloud.compute.v1small.RegionOperationsClient" + }, + "method": { + "shortName": "Get", + "fullName": "google.cloud.compute.v1small.RegionOperations.Get", + "service": { + "shortName": "RegionOperations", + "fullName": "google.cloud.compute.v1small.RegionOperations" + } + } + } + }, + { + "regionTag": "compute_v1small_generated_RegionOperations_Wait_async", + "title": "Addresses wait Sample", + "origin": "API_DEFINITION", + "description": " Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the `GET` method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`.", + "canonical": true, + "file": "region_operations.wait.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Wait", + "fullName": "google.cloud.compute.v1small.RegionOperations.Wait", + "async": true, + "parameters": [ + { + "name": "operation", + "type": "TYPE_STRING" + }, + { + "name": "project", + "type": "TYPE_STRING" + }, + { + "name": "region", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.compute.v1small.Operation", + "client": { + "shortName": "RegionOperationsClient", + "fullName": "google.cloud.compute.v1small.RegionOperationsClient" + }, + "method": { + "shortName": "Wait", + "fullName": "google.cloud.compute.v1small.RegionOperations.Wait", + "service": { + "shortName": "RegionOperations", + "fullName": "google.cloud.compute.v1small.RegionOperations" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-compute/v1small/src/index.ts b/owl-bot-staging/google-cloud-compute/v1small/src/index.ts new file mode 100644 index 00000000000..6721c4c8744 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2023 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 v1small from './v1small'; +const AddressesClient = v1small.AddressesClient; +type AddressesClient = v1small.AddressesClient; +const RegionOperationsClient = v1small.RegionOperationsClient; +type RegionOperationsClient = v1small.RegionOperationsClient; +export {v1small, AddressesClient, RegionOperationsClient}; +export default {v1small, AddressesClient, RegionOperationsClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-compute/v1small/src/v1small/addresses_client.ts b/owl-bot-staging/google-cloud-compute/v1small/src/v1small/addresses_client.ts new file mode 100644 index 00000000000..af0217eddab --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/src/v1small/addresses_client.ts @@ -0,0 +1,799 @@ +// Copyright 2023 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, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1small/addresses_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './addresses_client_config.json'; +const version = require('../../../package.json').version; + +/** + * + * Services + * + * The Addresses API. + * @class + * @memberof v1small + */ +export class AddressesClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + addressesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of AddressesClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new AddressesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof AddressesClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // 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 = { + aggregatedList: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items'), + list: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'items') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1small.Addresses', 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.addressesStub) { + return this.addressesStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1small.Addresses. + this.addressesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1small.Addresses') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1small.Addresses, + 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 addressesStubMethods = + ['aggregatedList', 'delete', 'insert', 'list']; + for (const methodName of addressesStubMethods) { + const callPromise = this.addressesStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.addressesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute', + '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 -- + // ------------------- +/** + * Deletes the specified address resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.address + * Name of the address resource to delete. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. + * + * For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1small/addresses.delete.js + * region_tag:compute_v1small_generated_Addresses_Delete_async + */ + delete( + request?: protos.google.cloud.compute.v1small.IDeleteAddressRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1small.IOperation|undefined, {}|undefined + ]>; + delete( + request: protos.google.cloud.compute.v1small.IDeleteAddressRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IDeleteAddressRequest|null|undefined, + {}|null|undefined>): void; + delete( + request: protos.google.cloud.compute.v1small.IDeleteAddressRequest, + callback: Callback< + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IDeleteAddressRequest|null|undefined, + {}|null|undefined>): void; + delete( + request?: protos.google.cloud.compute.v1small.IDeleteAddressRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IDeleteAddressRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IDeleteAddressRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1small.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'address': request.address ?? '', + }); + this.initialize(); + return this.innerApiCalls.delete(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } +/** + * Creates an address resource in the specified project by using the data included in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.compute.v1small.Address} request.addressResource + * The body resource for this request + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. + * + * For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000). + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * This method is considered to be in beta. This means while + * stable it is still a work-in-progress and under active development, + * and might get backwards-incompatible changes at any time. + * `.promise()` is not supported yet. + * @example include:samples/generated/v1small/addresses.insert.js + * region_tag:compute_v1small_generated_Addresses_Insert_async + */ + insert( + request?: protos.google.cloud.compute.v1small.IInsertAddressRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.cloud.compute.v1small.IOperation|undefined, {}|undefined + ]>; + insert( + request: protos.google.cloud.compute.v1small.IInsertAddressRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IInsertAddressRequest|null|undefined, + {}|null|undefined>): void; + insert( + request: protos.google.cloud.compute.v1small.IInsertAddressRequest, + callback: Callback< + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IInsertAddressRequest|null|undefined, + {}|null|undefined>): void; + insert( + request?: protos.google.cloud.compute.v1small.IInsertAddressRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IInsertAddressRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IInsertAddressRequest|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.cloud.compute.v1small.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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.insert(request, options, callback) + .then(([response, operation, rawResponse]: [protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation, protos.google.cloud.compute.v1.IOperation]) => { + return [ + { latestResponse: response, done: false, name: response.id, metadata: null, result: {}}, + operation, + rawResponse + ]; + }); + } + + +/** + * Retrieves an aggregated list of addresses. + * + * `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.filter + * A filter expression that filters resources listed in the response. The expression must specify the field name, a comparison operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The comparison operator must be either `=`, `!=`, `>`, or `<`. + * + * For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. + * + * You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. + * + * To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` + * @param {boolean} request.includeAllScopes + * Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. + * + * You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. + * + * Currently, only sorting by `name` or `creationTimestamp desc` is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * as tuple [string, {@link google.cloud.compute.v1small.AddressesScopedList | AddressesScopedList}]. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1small/addresses.aggregated_list.js + * region_tag:compute_v1small_generated_Addresses_AggregatedList_async + */ + aggregatedListAsync( + request?: protos.google.cloud.compute.v1small.IAggregatedListAddressesRequest, + options?: CallOptions): + AsyncIterable<[string, protos.google.cloud.compute.v1small.IAddressesScopedList]>{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + }); + const defaultCallSettings = this._defaults['aggregatedList']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.aggregatedList.asyncIterate( + this.innerApiCalls['aggregatedList'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable<[string, protos.google.cloud.compute.v1small.IAddressesScopedList]>; + } + /** + * Retrieves a list of addresses contained within the specified region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. The expression must specify the field name, a comparison operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The comparison operator must be either =, !=, >, or <. + * + * For example, if you are filtering Compute Engine instances, you can exclude instances named example-instance by specifying name != example-instance. + * + * You can also filter nested fields. For example, you could specify scheduling.automaticRestart = false to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. + * + * To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake"). By default, each expression is an AND expression. However, you can include AND and OR expressions explicitly. For example, (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true). + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. Acceptable values are 0 to 500, inclusive. (Default: 500) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. + * + * You can also sort results in descending order based on the creation timestamp using orderBy="creationTimestamp desc". This sorts results based on the creationTimestamp field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. + * + * Currently, only sorting by name or creationTimestamp desc is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @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 google.cloud.compute.v1small.Address | Address}. + * 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + list( + request?: protos.google.cloud.compute.v1small.IListAddressesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1small.IAddress[], + protos.google.cloud.compute.v1small.IListAddressesRequest|null, + protos.google.cloud.compute.v1small.IAddressList + ]>; + list( + request: protos.google.cloud.compute.v1small.IListAddressesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.compute.v1small.IListAddressesRequest, + protos.google.cloud.compute.v1small.IAddressList|null|undefined, + protos.google.cloud.compute.v1small.IAddress>): void; + list( + request: protos.google.cloud.compute.v1small.IListAddressesRequest, + callback: PaginationCallback< + protos.google.cloud.compute.v1small.IListAddressesRequest, + protos.google.cloud.compute.v1small.IAddressList|null|undefined, + protos.google.cloud.compute.v1small.IAddress>): void; + list( + request?: protos.google.cloud.compute.v1small.IListAddressesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.compute.v1small.IListAddressesRequest, + protos.google.cloud.compute.v1small.IAddressList|null|undefined, + protos.google.cloud.compute.v1small.IAddress>, + callback?: PaginationCallback< + protos.google.cloud.compute.v1small.IListAddressesRequest, + protos.google.cloud.compute.v1small.IAddressList|null|undefined, + protos.google.cloud.compute.v1small.IAddress>): + Promise<[ + protos.google.cloud.compute.v1small.IAddress[], + protos.google.cloud.compute.v1small.IListAddressesRequest|null, + protos.google.cloud.compute.v1small.IAddressList + ]>|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + this.initialize(); + return this.innerApiCalls.list(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. The expression must specify the field name, a comparison operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The comparison operator must be either =, !=, >, or <. + * + * For example, if you are filtering Compute Engine instances, you can exclude instances named example-instance by specifying name != example-instance. + * + * You can also filter nested fields. For example, you could specify scheduling.automaticRestart = false to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. + * + * To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake"). By default, each expression is an AND expression. However, you can include AND and OR expressions explicitly. For example, (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true). + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. Acceptable values are 0 to 500, inclusive. (Default: 500) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. + * + * You can also sort results in descending order based on the creation timestamp using orderBy="creationTimestamp desc". This sorts results based on the creationTimestamp field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. + * + * Currently, only sorting by name or creationTimestamp desc is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @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 google.cloud.compute.v1small.Address | Address} 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 `listAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listStream( + request?: protos.google.cloud.compute.v1small.IListAddressesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.createStream( + this.innerApiCalls.list as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `list`, 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.filter + * A filter expression that filters resources listed in the response. The expression must specify the field name, a comparison operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The comparison operator must be either =, !=, >, or <. + * + * For example, if you are filtering Compute Engine instances, you can exclude instances named example-instance by specifying name != example-instance. + * + * You can also filter nested fields. For example, you could specify scheduling.automaticRestart = false to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. + * + * To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake"). By default, each expression is an AND expression. However, you can include AND and OR expressions explicitly. For example, (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true). + * @param {number} request.maxResults + * The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. Acceptable values are 0 to 500, inclusive. (Default: 500) + * @param {string} request.orderBy + * Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. + * + * You can also sort results in descending order based on the creation timestamp using orderBy="creationTimestamp desc". This sorts results based on the creationTimestamp field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. + * + * Currently, only sorting by name or creationTimestamp desc is supported. + * @param {string} request.pageToken + * Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.compute.v1small.Address | Address}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1small/addresses.list.js + * region_tag:compute_v1small_generated_Addresses_List_async + */ + listAsync( + request?: protos.google.cloud.compute.v1small.IListAddressesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'project': request.project ?? '', + 'region': request.region ?? '', + }); + const defaultCallSettings = this._defaults['list']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.list.asyncIterate( + this.innerApiCalls['list'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + + /** + * 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.addressesStub && !this._terminated) { + return this.addressesStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1small/src/v1small/addresses_client_config.json b/owl-bot-staging/google-cloud-compute/v1small/src/v1small/addresses_client_config.json new file mode 100644 index 00000000000..41405894155 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/src/v1small/addresses_client_config.json @@ -0,0 +1,42 @@ +{ + "interfaces": { + "google.cloud.compute.v1small.Addresses": { + "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": { + "AggregatedList": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Delete": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Insert": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "List": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1small/src/v1small/addresses_proto_list.json b/owl-bot-staging/google-cloud-compute/v1small/src/v1small/addresses_proto_list.json new file mode 100644 index 00000000000..532a0c3e758 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/src/v1small/addresses_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1small/compute_small.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1small/src/v1small/gapic_metadata.json b/owl-bot-staging/google-cloud-compute/v1small/src/v1small/gapic_metadata.json new file mode 100644 index 00000000000..54ef73b752f --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/src/v1small/gapic_metadata.json @@ -0,0 +1,105 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.compute.v1small", + "libraryPackage": "@google-cloud/compute-small", + "services": { + "Addresses": { + "clients": { + "grpc": { + "libraryClient": "AddressesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "AddressesClient", + "rpcs": { + "Delete": { + "methods": [ + "delete" + ] + }, + "Insert": { + "methods": [ + "insert" + ] + }, + "AggregatedList": { + "methods": [ + "aggregatedList", + "aggregatedListStream", + "aggregatedListAsync" + ] + }, + "List": { + "methods": [ + "list", + "listStream", + "listAsync" + ] + } + } + } + } + }, + "RegionOperations": { + "clients": { + "grpc": { + "libraryClient": "RegionOperationsClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "Wait": { + "methods": [ + "wait" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RegionOperationsClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "Wait": { + "methods": [ + "wait" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1small/src/v1small/index.ts b/owl-bot-staging/google-cloud-compute/v1small/src/v1small/index.ts new file mode 100644 index 00000000000..92ff51aab96 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/src/v1small/index.ts @@ -0,0 +1,20 @@ +// Copyright 2023 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. ** + +export {AddressesClient} from './addresses_client'; +export {RegionOperationsClient} from './region_operations_client'; diff --git a/owl-bot-staging/google-cloud-compute/v1small/src/v1small/region_operations_client.ts b/owl-bot-staging/google-cloud-compute/v1small/src/v1small/region_operations_client.ts new file mode 100644 index 00000000000..c7e6e494fd4 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/src/v1small/region_operations_client.ts @@ -0,0 +1,467 @@ +// Copyright 2023 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} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1small/region_operations_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './region_operations_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The RegionOperations API. + * @class + * @memberof v1small + */ +export class RegionOperationsClient { + 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}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + regionOperationsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RegionOperationsClient. + * + * @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://developers.google.com/identity/protocols/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RegionOperationsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RegionOperationsClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + // Implicitely set 'rest' value for the apis use rest as transport (eg. googleapis-discovery apis). + if (!opts) { + opts = {fallback: 'rest'}; + } else { + opts.fallback = opts.fallback ?? 'rest'; + } + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.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 defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && '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 if (opts.fallback === 'rest' ) { + 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); + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.compute.v1small.RegionOperations', 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.regionOperationsStub) { + return this.regionOperationsStub; + } + + // Put together the "service stub" for + // google.cloud.compute.v1small.RegionOperations. + this.regionOperationsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.compute.v1small.RegionOperations') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.compute.v1small.RegionOperations, + 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 regionOperationsStubMethods = + ['get', 'wait']; + for (const methodName of regionOperationsStubMethods) { + const callPromise = this.regionOperationsStub.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 = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.regionOperationsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'compute.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'compute.googleapis.com'; + } + + /** + * 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/compute.readonly', + 'https://www.googleapis.com/auth/compute', + '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 -- + // ------------------- +/** + * Retrieves the specified region-specific Operations resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Name of the Operations resource to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @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.compute.v1small.Operation | Operation}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1small/region_operations.get.js + * region_tag:compute_v1small_generated_RegionOperations_Get_async + */ + get( + request?: protos.google.cloud.compute.v1small.IGetRegionOperationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IGetRegionOperationRequest|undefined, {}|undefined + ]>; + get( + request: protos.google.cloud.compute.v1small.IGetRegionOperationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IGetRegionOperationRequest|null|undefined, + {}|null|undefined>): void; + get( + request: protos.google.cloud.compute.v1small.IGetRegionOperationRequest, + callback: Callback< + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IGetRegionOperationRequest|null|undefined, + {}|null|undefined>): void; + get( + request?: protos.google.cloud.compute.v1small.IGetRegionOperationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IGetRegionOperationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IGetRegionOperationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IGetRegionOperationRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'operation': request.operation ?? '', + }); + this.initialize(); + return this.innerApiCalls.get(request, options, callback); + } +/** + * Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the `GET` method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be `DONE` or still in progress. + * + * This method is called on a best-effort basis. Specifically: + * - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. + * - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Name of the Operations resource to return. + * @param {string} request.project + * Project ID for this request. + * @param {string} request.region + * Name of the region for this request. + * @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.compute.v1small.Operation | Operation}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1small/region_operations.wait.js + * region_tag:compute_v1small_generated_RegionOperations_Wait_async + */ + wait( + request?: protos.google.cloud.compute.v1small.IWaitRegionOperationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IWaitRegionOperationRequest|undefined, {}|undefined + ]>; + wait( + request: protos.google.cloud.compute.v1small.IWaitRegionOperationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IWaitRegionOperationRequest|null|undefined, + {}|null|undefined>): void; + wait( + request: protos.google.cloud.compute.v1small.IWaitRegionOperationRequest, + callback: Callback< + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IWaitRegionOperationRequest|null|undefined, + {}|null|undefined>): void; + wait( + request?: protos.google.cloud.compute.v1small.IWaitRegionOperationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IWaitRegionOperationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IWaitRegionOperationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.compute.v1small.IOperation, + protos.google.cloud.compute.v1small.IWaitRegionOperationRequest|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({ + 'project': request.project ?? '', + 'region': request.region ?? '', + 'operation': request.operation ?? '', + }); + this.initialize(); + return this.innerApiCalls.wait(request, options, callback); + } + + + /** + * 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.regionOperationsStub && !this._terminated) { + return this.regionOperationsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1small/src/v1small/region_operations_client_config.json b/owl-bot-staging/google-cloud-compute/v1small/src/v1small/region_operations_client_config.json new file mode 100644 index 00000000000..88fa3adfccc --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/src/v1small/region_operations_client_config.json @@ -0,0 +1,34 @@ +{ + "interfaces": { + "google.cloud.compute.v1small.RegionOperations": { + "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": { + "Get": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Wait": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-compute/v1small/src/v1small/region_operations_proto_list.json b/owl-bot-staging/google-cloud-compute/v1small/src/v1small/region_operations_proto_list.json new file mode 100644 index 00000000000..532a0c3e758 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/src/v1small/region_operations_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/compute/v1small/compute_small.proto" +] diff --git a/owl-bot-staging/google-cloud-compute/v1small/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-compute/v1small/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..3872037383d --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2023 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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const compute = require('@google-cloud/compute-small'); + +function main() { + const addressesClient = new compute.AddressesClient(); + const regionOperationsClient = new compute.RegionOperationsClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-compute/v1small/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-compute/v1small/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..70b38ba7c59 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2023 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 {AddressesClient, RegionOperationsClient} from '@google-cloud/compute-small'; + +// check that the client class type name can be used +function doStuffWithAddressesClient(client: AddressesClient) { + client.close(); +} +function doStuffWithRegionOperationsClient(client: RegionOperationsClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const addressesClient = new AddressesClient(); + doStuffWithAddressesClient(addressesClient); + // check that the client instance can be created + const regionOperationsClient = new RegionOperationsClient(); + doStuffWithRegionOperationsClient(regionOperationsClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-compute/v1small/system-test/install.ts b/owl-bot-staging/google-cloud-compute/v1small/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2023 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 {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-compute/v1small/test/gapic_addresses_v1small.ts b/owl-bot-staging/google-cloud-compute/v1small/test/gapic_addresses_v1small.ts new file mode 100644 index 00000000000..6e5f084ab7c --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/test/gapic_addresses_v1small.ts @@ -0,0 +1,798 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as addressesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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 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('v1small.AddressesClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = addressesModule.v1small.AddressesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = addressesModule.v1small.AddressesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = addressesModule.v1small.AddressesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new addressesModule.v1small.AddressesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new addressesModule.v1small.AddressesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new addressesModule.v1small.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.addressesStub, undefined); + await client.initialize(); + assert(client.addressesStub); + }); + + it('has close method for the initialized client', done => { + const client = new addressesModule.v1small.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.addressesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new addressesModule.v1small.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.addressesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new addressesModule.v1small.AddressesClient({ + auth: googleAuth, + 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 addressesModule.v1small.AddressesClient({ + auth: googleAuth, + 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('delete', () => { + it('invokes delete without error', async () => { + const client = new addressesModule.v1small.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.DeleteAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.DeleteAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.DeleteAddressRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1small.DeleteAddressRequest', ['address']); + request.address = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&address=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1small.Operation() + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = new addressesModule.v1small.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.DeleteAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.DeleteAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.DeleteAddressRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1small.DeleteAddressRequest', ['address']); + request.address = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&address=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1small.Operation() + ); + client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1small.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = new addressesModule.v1small.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.DeleteAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.DeleteAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.DeleteAddressRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1small.DeleteAddressRequest', ['address']); + request.address = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&address=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = new addressesModule.v1small.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.DeleteAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.DeleteAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.DeleteAddressRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1small.DeleteAddressRequest', ['address']); + request.address = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new addressesModule.v1small.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.InsertAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.InsertAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.InsertAddressRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1small.Operation() + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response.latestResponse, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = new addressesModule.v1small.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.InsertAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.InsertAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.InsertAddressRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1small.Operation() + ); + client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1small.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = new addressesModule.v1small.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.InsertAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.InsertAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.InsertAddressRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = new addressesModule.v1small.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.InsertAddressRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.InsertAddressRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.InsertAddressRequest', ['region']); + request.region = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('aggregatedList', () => { + + it('uses async iteration with aggregatedList without error', async () => { + const client = new addressesModule.v1small.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.AggregatedListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.AggregatedListAddressesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedResponse = [ + ['tuple_key_1', generateSampleMessage(new protos.google.cloud.compute.v1small.AddressesScopedList())], + ['tuple_key_2', generateSampleMessage(new protos.google.cloud.compute.v1small.AddressesScopedList())], + ['tuple_key_3', generateSampleMessage(new protos.google.cloud.compute.v1small.AddressesScopedList())], + ]; + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: Array<[string, protos.google.cloud.compute.v1small.IAddressesScopedList]> = []; + const iterable = client.aggregatedListAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with aggregatedList with error', async () => { + const client = new addressesModule.v1small.AddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.AggregatedListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.AggregatedListAddressesRequest', ['project']); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregatedList.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregatedListAsync(request); + await assert.rejects(async () => { + const responses: Array<[string, protos.google.cloud.compute.v1small.IAddressesScopedList]> = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.aggregatedList.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new addressesModule.v1small.AddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.ListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.ListAddressesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.ListAddressesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1small.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1small.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1small.Address()), + ]; + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = new addressesModule.v1small.AddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.ListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.ListAddressesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.ListAddressesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1small.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1small.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1small.Address()), + ]; + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1small.IAddress[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = new addressesModule.v1small.AddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.ListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.ListAddressesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.ListAddressesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listStream without error', async () => { + const client = new addressesModule.v1small.AddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.ListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.ListAddressesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.ListAddressesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1small.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1small.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1small.Address()), + ]; + client.descriptors.page.list.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1small.Address[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1small.Address) => { + 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.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listStream with error', async () => { + const client = new addressesModule.v1small.AddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.ListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.ListAddressesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.ListAddressesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.compute.v1small.Address[] = []; + stream.on('data', (response: protos.google.cloud.compute.v1small.Address) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.list.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.list, request)); + assert( + (client.descriptors.page.list.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list without error', async () => { + const client = new addressesModule.v1small.AddressesClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.ListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.ListAddressesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.ListAddressesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.compute.v1small.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1small.Address()), + generateSampleMessage(new protos.google.cloud.compute.v1small.Address()), + ]; + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.compute.v1small.IAddress[] = []; + const iterable = client.listAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with list with error', async () => { + const client = new addressesModule.v1small.AddressesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.ListAddressesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.ListAddressesRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.ListAddressesRequest', ['region']); + request.region = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}`; + const expectedError = new Error('expected'); + client.descriptors.page.list.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.compute.v1small.IAddress[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.list.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1small/test/gapic_region_operations_v1small.ts b/owl-bot-staging/google-cloud-compute/v1small/test/gapic_region_operations_v1small.ts new file mode 100644 index 00000000000..c371579b2b0 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/test/gapic_region_operations_v1small.ts @@ -0,0 +1,425 @@ +// Copyright 2023 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, beforeEach, afterEach} from 'mocha'; +import * as regionoperationsModule from '../src'; + +import {GoogleAuth, protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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); +} + +describe('v1small.RegionOperationsClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon.stub().resolves({Authorization: 'Bearer SOME_TOKEN'}), + }) + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = regionoperationsModule.v1small.RegionOperationsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = regionoperationsModule.v1small.RegionOperationsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = regionoperationsModule.v1small.RegionOperationsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new regionoperationsModule.v1small.RegionOperationsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new regionoperationsModule.v1small.RegionOperationsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new regionoperationsModule.v1small.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionOperationsStub, undefined); + await client.initialize(); + assert(client.regionOperationsStub); + }); + + it('has close method for the initialized client', done => { + const client = new regionoperationsModule.v1small.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + assert(client.regionOperationsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new regionoperationsModule.v1small.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + assert.strictEqual(client.regionOperationsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new regionoperationsModule.v1small.RegionOperationsClient({ + auth: googleAuth, + 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 regionoperationsModule.v1small.RegionOperationsClient({ + auth: googleAuth, + 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('get', () => { + it('invokes get without error', async () => { + const client = new regionoperationsModule.v1small.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.GetRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.GetRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.GetRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1small.GetRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&operation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1small.Operation() + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = new regionoperationsModule.v1small.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.GetRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.GetRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.GetRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1small.GetRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&operation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1small.Operation() + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1small.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = new regionoperationsModule.v1small.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.GetRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.GetRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.GetRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1small.GetRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&operation=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = new regionoperationsModule.v1small.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.GetRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.GetRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.GetRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1small.GetRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('wait', () => { + it('invokes wait without error', async () => { + const client = new regionoperationsModule.v1small.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.WaitRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.WaitRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.WaitRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1small.WaitRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&operation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1small.Operation() + ); + client.innerApiCalls.wait = stubSimpleCall(expectedResponse); + const [response] = await client.wait(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes wait without error using callback', async () => { + const client = new regionoperationsModule.v1small.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.WaitRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.WaitRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.WaitRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1small.WaitRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&operation=${defaultValue3}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.compute.v1small.Operation() + ); + client.innerApiCalls.wait = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.wait( + request, + (err?: Error|null, result?: protos.google.cloud.compute.v1small.IOperation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes wait with error', async () => { + const client = new regionoperationsModule.v1small.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.WaitRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.WaitRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.WaitRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1small.WaitRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1}®ion=${defaultValue2}&operation=${defaultValue3}`; + const expectedError = new Error('expected'); + client.innerApiCalls.wait = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.wait(request), expectedError); + const actualRequest = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.wait as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes wait with closed client', async () => { + const client = new regionoperationsModule.v1small.RegionOperationsClient({ + auth: googleAuth, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.compute.v1small.WaitRegionOperationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.compute.v1small.WaitRegionOperationRequest', ['project']); + request.project = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.cloud.compute.v1small.WaitRegionOperationRequest', ['region']); + request.region = defaultValue2; + const defaultValue3 = + getTypeDefaultValue('.google.cloud.compute.v1small.WaitRegionOperationRequest', ['operation']); + request.operation = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.wait(request), expectedError); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-compute/v1small/tsconfig.json b/owl-bot-staging/google-cloud-compute/v1small/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-compute/v1small/webpack.config.js b/owl-bot-staging/google-cloud-compute/v1small/webpack.config.js new file mode 100644 index 00000000000..e5f87460510 --- /dev/null +++ b/owl-bot-staging/google-cloud-compute/v1small/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 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. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'Addresses', + filename: './addresses.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +};